Skip to content

Commit

Permalink
changed the way how the "current working path" is managed
Browse files Browse the repository at this point in the history
* should fix #11
* should fix #12
* should even fix #13
  • Loading branch information
FibreFoX committed Jan 26, 2016
1 parent 414f48a commit 51738c6
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<Path>() {

Expand Down Expand Up @@ -146,7 +146,7 @@ public FileVisitResult postVisitDirectory(Path source, IOException ioe) throws I
// adding all resource-files
Set<File> 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)
Expand All @@ -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<String> duplicateKeys = new HashSet<>();
Optional.ofNullable(ext.getBundleArguments()).ifPresent(bArguments -> {
Expand Down Expand Up @@ -270,7 +270,7 @@ public FileVisitResult postVisitDirectory(Path source, IOException ioe) throws I
try{
Map<String, ? super Object> 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
Expand Down Expand Up @@ -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{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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");
}
}

0 comments on commit 51738c6

Please sign in to comment.