#!/bin/bash

echo "Building v2 license decoder without signature checks"
javac Version2LicenseDecoder.java -cp .:src/atlassian-extras-2.2.2.jar:src/commons-codec-1.4.jar
echo "Removing previous cracked jars"
rm -rf cracked
echo "Copying source jars"
mkdir -p cracked
cp -v src/atlassian-extras-*.jar src/atlassian-universal-plugin-manager-plugin-*.jar src/atlassian-extras-decoder-v2-*.jar cracked
echo "Patching jars"
cd cracked
mkdir -p com/atlassian/extras/decoder/v2
cp ../Version2LicenseDecoder.class com/atlassian/extras/decoder/v2
for jar in atlassian-extras-*.jar atlassian-universal-plugin-manager-plugin-*.jar atlassian-extras-decoder-v2-*.jar; do
    echo " - patching $jar"
    jar ufv $jar com/atlassian/extras/decoder/v2/Version2LicenseDecoder.class
done
echo "Removing temporary files"
rm -rf com
