// Path: src/main/java/de/dynamicfiles/projects/gradle/plugins/javafx/tasks/internal/JavaDetectionTools.java
// public class JavaDetectionTools {
// 
//     public static final boolean IS_JAVA_8 = isJavaVersion(8);
//     public static final boolean IS_JAVA_9 = !IS_JAVA_8 && isJavaVersion(9) || isJavaVersion(9, true);
// 
//     public static boolean isJavaVersion(int oracleJavaVersion, boolean noVersionOne) {
//         String javaVersion = System.getProperty("java.version");
//         if( noVersionOne ){
//             return javaVersion.startsWith(String.valueOf(oracleJavaVersion));
//         }
//         return javaVersion.startsWith("1." + oracleJavaVersion);
//     }
// 
//     public static boolean isJavaVersion(int oracleJavaVersion) {
//         return isJavaVersion(oracleJavaVersion, false);
//     }
// 
//     public static boolean isAtLeastOracleJavaUpdateVersion(int updateNumber) {
//         String javaVersion = System.getProperty("java.version");
//         String[] javaVersionSplitted = javaVersion.split("_");
//         if( javaVersionSplitted.length <= 1 ){
//             return false;
//         }
//         String javaUpdateVersionRaw = javaVersionSplitted[1];
//         // required for any non-oracle JDK like the openjdk, as the reported version might result something like "1.8.0_45-internal"
//         String javaUpdateVersion = javaUpdateVersionRaw.replaceAll("[^\\d]", "");
//         return Integer.parseInt(javaUpdateVersion, 10) >= updateNumber;
//     }
// }


import com.oracle.tools.packager.BundlerParamInfo;
import com.oracle.tools.packager.IOUtils;
import com.oracle.tools.packager.Log;
import com.oracle.tools.packager.StandardBundlerParam;
import static com.oracle.tools.packager.StandardBundlerParam.APP_NAME;
import static com.oracle.tools.packager.StandardBundlerParam.BUILD_ROOT;
import static com.oracle.tools.packager.StandardBundlerParam.VERBOSE;
import com.oracle.tools.packager.mac.MacAppBundler;
import com.oracle.tools.packager.mac.MacBaseInstallerBundler;
import de.dynamicfiles.projects.gradle.plugins.javafx.tasks.internal.JavaDetectionTools;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.nio.file.FileVisitResult;
import java.nio.file.FileVisitor;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.StandardCopyOption;
import java.nio.file.attribute.BasicFileAttributes;
import java.text.MessageFormat;
import java.util.HashMap;
import java.util.Map;
import java.util.Optional;
import java.util.ResourceBundle;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicReference;
            BUILD_ROOT.fetchFrom(p);
            prepareConfigFiles(p);
            rootDirectory = new File(outputDirectory, APP_NAME.fetchFrom(p) + ".app");
            // this is the root of evil, because we can't just "pre-copy" all additional files needed
            IOUtils.deleteRecursive(rootDirectory);
            // recreate
            rootDirectory.mkdirs();

            // this mac app bundler gets called by other mac installer bundlers
            if( !dependentTask ){
                Log.info(MessageFormat.format(I18N.getString("message.creating-app-bundle"), rootDirectory.getAbsolutePath()));
            }

            File contentsDirectory = new File(rootDirectory, "Contents");
            contentsDirectory.mkdirs();
            File macOSDirectory = new File(contentsDirectory, "MacOS");
            macOSDirectory.mkdirs();
            File javaDirectory = new File(contentsDirectory, "Java");
            javaDirectory.mkdirs();
            File plugInsDirectory = new File(contentsDirectory, "PlugIns");
            File resourcesDirectory = new File(contentsDirectory, "Resources");
            resourcesDirectory.mkdirs();

            File pkgInfoFile = new File(contentsDirectory, "PkgInfo");
            pkgInfoFile.createNewFile();
            writePkgInfo(pkgInfoFile);

            File executableFile = new File(macOSDirectory, getLauncherName(p));
            IOUtils.copyFromURL(RAW_EXECUTABLE_URL.fetchFrom(p), executableFile);

// Path: src/main/java/de/dynamicfiles/projects/gradle/plugins/javafx/tasks/internal/JavaDetectionTools.java
// public class JavaDetectionTools {
// 
//     public static final boolean IS_JAVA_8 = isJavaVersion(8);
//     public static final boolean IS_JAVA_9 = !IS_JAVA_8 && isJavaVersion(9) || isJavaVersion(9, true);
// 
//     public static boolean isJavaVersion(int oracleJavaVersion, boolean noVersionOne) {
//         String javaVersion = System.getProperty("java.version");
//         if( noVersionOne ){
//             return javaVersion.startsWith(String.valueOf(oracleJavaVersion));
//         }
//         return javaVersion.startsWith("1." + oracleJavaVersion);
//     }
// 
//     public static boolean isJavaVersion(int oracleJavaVersion) {
//         return isJavaVersion(oracleJavaVersion, false);
//     }
// 
//     public static boolean isAtLeastOracleJavaUpdateVersion(int updateNumber) {
//         String javaVersion = System.getProperty("java.version");
//         String[] javaVersionSplitted = javaVersion.split("_");
//         if( javaVersionSplitted.length <= 1 ){
//             return false;
//         }
//         String javaUpdateVersionRaw = javaVersionSplitted[1];
//         // required for any non-oracle JDK like the openjdk, as the reported version might result something like "1.8.0_45-internal"
//         String javaUpdateVersion = javaUpdateVersionRaw.replaceAll("[^\\d]", "");
//         return Integer.parseInt(javaUpdateVersion, 10) >= updateNumber;
//     }
// }


// Path: src/main/java/de/dynamicfiles/projects/gradle/plugins/javafx/tasks/workarounds/MacAppBundlerWithAdditionalResources.java
import com.oracle.tools.packager.BundlerParamInfo;
import com.oracle.tools.packager.IOUtils;
import com.oracle.tools.packager.Log;
import com.oracle.tools.packager.StandardBundlerParam;
import static com.oracle.tools.packager.StandardBundlerParam.APP_NAME;
import static com.oracle.tools.packager.StandardBundlerParam.BUILD_ROOT;
import static com.oracle.tools.packager.StandardBundlerParam.VERBOSE;
import com.oracle.tools.packager.mac.MacAppBundler;
import com.oracle.tools.packager.mac.MacBaseInstallerBundler;
import de.dynamicfiles.projects.gradle.plugins.javafx.tasks.internal.JavaDetectionTools;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.nio.file.FileVisitResult;
import java.nio.file.FileVisitor;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.StandardCopyOption;
import java.nio.file.attribute.BasicFileAttributes;
import java.text.MessageFormat;
import java.util.HashMap;
import java.util.Map;
import java.util.Optional;
import java.util.ResourceBundle;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicReference;

            BUILD_ROOT.fetchFrom(p);
            prepareConfigFiles(p);
            rootDirectory = new File(outputDirectory, APP_NAME.fetchFrom(p) + ".app");
            // this is the root of evil, because we can't just "pre-copy" all additional files needed
            IOUtils.deleteRecursive(rootDirectory);
            // recreate
            rootDirectory.mkdirs();

            // this mac app bundler gets called by other mac installer bundlers
            if( !dependentTask ){
                Log.info(MessageFormat.format(I18N.getString("message.creating-app-bundle"), rootDirectory.getAbsolutePath()));
            }

            File contentsDirectory = new File(rootDirectory, "Contents");
            contentsDirectory.mkdirs();
            File macOSDirectory = new File(contentsDirectory, "MacOS");
            macOSDirectory.mkdirs();
            File javaDirectory = new File(contentsDirectory, "Java");
            javaDirectory.mkdirs();
            File plugInsDirectory = new File(contentsDirectory, "PlugIns");
            File resourcesDirectory = new File(contentsDirectory, "Resources");
            resourcesDirectory.mkdirs();

            File pkgInfoFile = new File(contentsDirectory, "PkgInfo");
            pkgInfoFile.createNewFile();
            writePkgInfo(pkgInfoFile);

            File executableFile = new File(macOSDirectory, getLauncherName(p));
            IOUtils.copyFromURL(RAW_EXECUTABLE_URL.fetchFrom(p), executableFile);

            if( JavaDetectionTools.IS_JAVA_8 && JavaDetectionTools.isAtLeastOracleJavaUpdateVersion(40) ){