From 41bf054319635ca10573ad884a22d83199d3534b Mon Sep 17 00:00:00 2001 From: FibreFoX Date: Sun, 5 Feb 2017 22:36:13 +0100 Subject: [PATCH] implemented useLibFolderContentForManifestClasspath --- README.md | 3 +++ .../javafx/JavaFXGradlePluginExtension.java | 10 ++++---- .../javafx/tasks/workers/JfxJarWorker.java | 24 +++++++++++++++++-- 3 files changed, 30 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index cbac25f..5bd12e6 100644 --- a/README.md +++ b/README.md @@ -97,6 +97,8 @@ jfx { addPackagerJar = true copyAdditionalAppResourcesToJar = false skipCopyingDependencies = false + useLibFolderContentForManifestClasspath = false + fixedManifestClasspath = null // gradle jfxNative identifier = null // String - setting this for windows-bundlers makes it possible to generate upgradeable installers (using same GUID) @@ -276,6 +278,7 @@ New: * added property to skip `nativeReleaseVersion` rewriting, just set `skipNativeVersionNumberSanitizing = true` inside the jfx-block * added `skipCopyingDependencies` to make it possible to NOT copying dependencies, but they are added to the classpath inside the manifest like normal * added `fixedManifestClasspath` for setting the classpath-entry inside the generated manifest-file in the main jfx-jar, this is already possible for secondary launchers by setting `classpath` within the configuration-block of the secondary launcher +* added `useLibFolderContentForManifestClasspath` for creating the manifest-entriy for the classpath, depending on the content of the lib-folder, makes it possible to have files not being inside dependencies being present there (which got copied beforehand) Changes: * reimplemented `additionalBundlerResources`, now searching for folders with the name of the used bundler, makes it possible to adjust nearly all bundlers now (for Mac a special replacement-class was created, as the default one did not provide any way to add more files) diff --git a/src/main/java/de/dynamicfiles/projects/gradle/plugins/javafx/JavaFXGradlePluginExtension.java b/src/main/java/de/dynamicfiles/projects/gradle/plugins/javafx/JavaFXGradlePluginExtension.java index e2b18dd..108258b 100644 --- a/src/main/java/de/dynamicfiles/projects/gradle/plugins/javafx/JavaFXGradlePluginExtension.java +++ b/src/main/java/de/dynamicfiles/projects/gradle/plugins/javafx/JavaFXGradlePluginExtension.java @@ -45,7 +45,7 @@ public class JavaFXGradlePluginExtension { // private boolean classpathExcludesTransient = true; private boolean copyAdditionalAppResourcesToJar = false; private boolean skipCopyingDependencies = false; - private boolean useLibFolderForManifestClasspath = false; + private boolean useLibFolderContentForManifestClasspath = false; private String fixedManifestClasspath = null; // NativeMojo @@ -229,12 +229,12 @@ public void setSkipCopyingDependencies(boolean skipCopyingDependencies) { this.skipCopyingDependencies = skipCopyingDependencies; } - public boolean isUseLibFolderForManifestClasspath() { - return useLibFolderForManifestClasspath; + public boolean isUseLibFolderContentForManifestClasspath() { + return useLibFolderContentForManifestClasspath; } - public void setUseLibFolderForManifestClasspath(boolean useLibFolderForManifestClasspath) { - this.useLibFolderForManifestClasspath = useLibFolderForManifestClasspath; + public void setUseLibFolderContentForManifestClasspath(boolean useLibFolderContentForManifestClasspath) { + this.useLibFolderContentForManifestClasspath = useLibFolderContentForManifestClasspath; } public String getFixedManifestClasspath() { diff --git a/src/main/java/de/dynamicfiles/projects/gradle/plugins/javafx/tasks/workers/JfxJarWorker.java b/src/main/java/de/dynamicfiles/projects/gradle/plugins/javafx/tasks/workers/JfxJarWorker.java index 2170594..b5712ed 100644 --- a/src/main/java/de/dynamicfiles/projects/gradle/plugins/javafx/tasks/workers/JfxJarWorker.java +++ b/src/main/java/de/dynamicfiles/projects/gradle/plugins/javafx/tasks/workers/JfxJarWorker.java @@ -133,14 +133,34 @@ public void jfxjar(Project project) { project.getLogger().info("Skipped copying runtime dependencies"); } - if( !foundLibs.isEmpty() ){ - createJarParams.setClasspath(ext.getLibFolderName() + "/" + String.join(" " + ext.getLibFolderName() + "/", foundLibs)); + if( ext.isUseLibFolderContentForManifestClasspath() ){ + StringBuilder scannedClasspath = new StringBuilder(); + try{ + Files.walkFileTree(libDir.toPath(), new SimpleFileVisitor() { + @Override + public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException { + scannedClasspath.append(file.toString().replace("\\", "/")).append(" "); + return super.visitFile(file, attrs); + } + }); + } catch(IOException ioex){ + project.getLogger().warn("Got problem while scanning lib-folder", ioex); + } + createJarParams.setClasspath(scannedClasspath.toString()); + } else { + if( !foundLibs.isEmpty() ){ + createJarParams.setClasspath(ext.getLibFolderName() + "/" + String.join(" " + ext.getLibFolderName() + "/", foundLibs)); + } } Optional.ofNullable(ext.getFixedManifestClasspath()).ifPresent(manifestClasspath -> { if( manifestClasspath.trim().isEmpty() ){ return; } createJarParams.setClasspath(manifestClasspath); + + if( ext.isUseLibFolderContentForManifestClasspath() ){ + project.getLogger().warn("You specified to use the content of the lib-folder AND specified a fixed classpath. The fixed classpath will get taken."); + } }); // https://docs.oracle.com/javase/8/docs/technotes/guides/deploy/manifest.html#JSDPG896