From 51738c6b9dce50a101730c8a410692f561383f76 Mon Sep 17 00:00:00 2001 From: FibreFoX Date: Tue, 26 Jan 2016 21:39:57 +0100 Subject: [PATCH] changed the way how the "current working path" is managed * should fix #11 * should fix #12 * should even fix #13 --- .../gradle/plugins/javafx/tasks/JfxJarTask.java | 8 +------- .../gradle/plugins/javafx/tasks/JfxNativeTask.java | 14 +++++++------- .../gradle/plugins/javafx/tasks/JfxTask.java | 11 +---------- 3 files changed, 9 insertions(+), 24 deletions(-) diff --git a/src/main/java/de/dynamicfiles/projects/gradle/plugins/javafx/tasks/JfxJarTask.java b/src/main/java/de/dynamicfiles/projects/gradle/plugins/javafx/tasks/JfxJarTask.java index 3b45997..f8388ec 100644 --- a/src/main/java/de/dynamicfiles/projects/gradle/plugins/javafx/tasks/JfxJarTask.java +++ b/src/main/java/de/dynamicfiles/projects/gradle/plugins/javafx/tasks/JfxJarTask.java @@ -93,13 +93,7 @@ public void jfxjar() { } createJarParams.setManifestAttrs(manifestAttributes); - final File libDir; - if( isDaemonMode() ){ - libDir = new File(new File(project.getProjectDir(), ext.getJfxAppOutputDir()), "lib"); - } else { - libDir = new File(ext.getJfxAppOutputDir(), "lib"); - } - + final File libDir = new File(new File(project.getProjectDir(), ext.getJfxAppOutputDir()), "lib"); if( !libDir.exists() && !libDir.mkdirs() ){ throw new GradleException("Unable to create app lib dir: " + libDir); } diff --git a/src/main/java/de/dynamicfiles/projects/gradle/plugins/javafx/tasks/JfxNativeTask.java b/src/main/java/de/dynamicfiles/projects/gradle/plugins/javafx/tasks/JfxNativeTask.java index 202d1af..a8f26b8 100644 --- a/src/main/java/de/dynamicfiles/projects/gradle/plugins/javafx/tasks/JfxNativeTask.java +++ b/src/main/java/de/dynamicfiles/projects/gradle/plugins/javafx/tasks/JfxNativeTask.java @@ -102,12 +102,12 @@ public void jfxnative() { }); Optional.ofNullable(ext.getAdditionalAppResources()) .filter(appRessourcesString -> appRessourcesString != null) - .map(appRessourcesString -> new File(appRessourcesString)) + .map(appRessourcesString -> new File(project.getProjectDir(), appRessourcesString)) .filter(File::exists) .ifPresent(appResources -> { project.getLogger().info("Copying additional app ressources..."); try{ - Path targetFolder = new File(ext.getJfxAppOutputDir()).toPath(); + Path targetFolder = new File(project.getProjectDir(), ext.getJfxAppOutputDir()).toPath(); Path sourceFolder = appResources.toPath(); Files.walkFileTree(appResources.toPath(), new FileVisitor() { @@ -146,7 +146,7 @@ public FileVisitResult postVisitDirectory(Path source, IOException ioe) throws I // adding all resource-files Set resourceFiles = new HashSet<>(); try{ - Files.walk(new File(ext.getJfxAppOutputDir()).toPath()) + Files.walk(new File(project.getProjectDir(), ext.getJfxAppOutputDir()).toPath()) .map(p -> p.toFile()) .filter(File::isFile) .filter(File::canRead) @@ -157,7 +157,7 @@ public FileVisitResult postVisitDirectory(Path source, IOException ioe) throws I } catch(IOException e){ project.getLogger().warn("There was a problem while processing application files.", e); } - params.put(StandardBundlerParam.APP_RESOURCES.getID(), new RelativeFileSet(new File(ext.getJfxAppOutputDir()), resourceFiles)); + params.put(StandardBundlerParam.APP_RESOURCES.getID(), new RelativeFileSet(new File(project.getProjectDir(), ext.getJfxAppOutputDir()), resourceFiles)); Collection duplicateKeys = new HashSet<>(); Optional.ofNullable(ext.getBundleArguments()).ifPresent(bArguments -> { @@ -270,7 +270,7 @@ public FileVisitResult postVisitDirectory(Path source, IOException ioe) throws I try{ Map paramsToBundleWith = new HashMap<>(params); if( b.validate(paramsToBundleWith) ){ - b.execute(paramsToBundleWith, new File(ext.getNativeOutputDir())); + b.execute(paramsToBundleWith, new File(project.getProjectDir(), ext.getNativeOutputDir())); // Workaround for "Native package for Ubuntu doesn't work" // https://github.com/javafx-maven-plugin/javafx-maven-plugin/issues/124 @@ -344,8 +344,8 @@ private void applyNativeLauncherWorkaround(Project project, String nativeOutputD } // rename .cfg-file (makes it able to create running applications again, even within installer) String newConfigFileName = appName.substring(0, appName.lastIndexOf(".")); - File nativeOutputDir = new File(nativeOutputDirString); - Path appPath = nativeOutputDir.toPath().resolve(appName).resolve("app"); + File nativeOutputDir = new File(project.getProjectDir(), nativeOutputDirString); + Path appPath = nativeOutputDir.toPath().toAbsolutePath().resolve(appName).resolve("app"); String configfileExtension = ".cfg"; Path oldConfigFile = appPath.resolve(appName + configfileExtension); try{ diff --git a/src/main/java/de/dynamicfiles/projects/gradle/plugins/javafx/tasks/JfxTask.java b/src/main/java/de/dynamicfiles/projects/gradle/plugins/javafx/tasks/JfxTask.java index cfa6b57..797170c 100644 --- a/src/main/java/de/dynamicfiles/projects/gradle/plugins/javafx/tasks/JfxTask.java +++ b/src/main/java/de/dynamicfiles/projects/gradle/plugins/javafx/tasks/JfxTask.java @@ -35,10 +35,7 @@ protected void addDeployDirToSystemClassloader(Project project, String deployDir // add deployDir to system classpath if( deployDir != null ){ - File targetDeployDir = new File(deployDir); - if( isDaemonMode() ){ - targetDeployDir = new File(project.getProjectDir(), deployDir); - } + File targetDeployDir = new File(project.getProjectDir(), deployDir); if( !targetDeployDir.exists() ){ project.getLogger().info("Adding 'deploy' directory wasn't successful, because it does not exist! (" + targetDeployDir.getAbsolutePath() + ")"); return; @@ -55,10 +52,4 @@ protected void addDeployDirToSystemClassloader(Project project, String deployDir } } } - - protected boolean isDaemonMode() { - // when gradle runs within daemon-mode, the current folder is not the project-folder (as it is on non-daemon-mode). - String javaCommand = System.getProperty("sun.java.command"); - return javaCommand != null && javaCommand.startsWith("org.gradle.launcher.daemon"); - } }