javafx-gradle-plugin icon indicating copy to clipboard operation
javafx-gradle-plugin copied to clipboard

java.nio.file.NoSuchFileException when running jfxNative in Windows

Open frnusmartobjects opened this issue 5 years ago • 6 comments

I am developing in Windows 10, using IntelliJ IDEA 2018.2.1, JDK version jdk1.8.0_181

I have a multimodule project and whenever I try to run the jfxNative task to generate a native Windows bundle I am getting for each module an error such as

Couldn't copy dependency project :my_module_1 java.nio.file.NoSuchFileException: C:\Users\dev\my_module_1\build\libs\my_module_1.jar at sun.nio.fs.WindowsException.translateToIOException(WindowsException.java:79) at sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:97) at sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:102) at sun.nio.fs.WindowsFileCopy.copy(WindowsFileCopy.java:99) at sun.nio.fs.WindowsFileSystemProvider.copy(WindowsFileSystemProvider.java:278) at java.nio.file.Files.copy(Files.java:1274) at de.dynamicfiles.projects.gradle.plugins.javafx.tasks.workers.JfxJarWorker.lambda$null$5(JfxJarWorker.java:235) at java.lang.Iterable.forEach(Iterable.java:75) at de.dynamicfiles.projects.gradle.plugins.javafx.tasks.workers.JfxJarWorker.lambda$copyModuleDependencies$6(JfxJarWorker.java:231) at java.lang.Iterable.forEach(Iterable.java:75) at de.dynamicfiles.projects.gradle.plugins.javafx.tasks.workers.JfxJarWorker.copyModuleDependencies(JfxJarWorker.java:229) at de.dynamicfiles.projects.gradle.plugins.javafx.tasks.workers.JfxJarWorker.jfxjar(JfxJarWorker.java:122) at de.dynamicfiles.projects.gradle.plugins.javafx.tasks.JfxJarTask.jfxjar(JfxJarTask.java:32) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:73) at org.gradle.api.internal.project.taskfactory.StandardTaskAction.doExecute(StandardTaskAction.java:46) at org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:39) at org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:26) at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:794) at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:761) at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$1.run(ExecuteActionsTaskExecuter.java:131) at org.gradle.internal.operations.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:317)

My jfx task is as follows:

jfx {
    mainClass = "com.mycompanysname.apackage.anotherpackage.MainApplication"
    vendor = "My Company's Name"
    appName = "My App Name"
    skipNativeVersionNumberSanitizing = true
    nativeReleaseVersion = version.replace('.', '_')

    needShortcut = true
    needMenu = true

    bundleArguments = [
            systemWide: true
    ]
}

I've read issue #12 and the person there has the same problem except that I am having it while running no matter how: In the IDE, using gradlew with daemon or using gradlew without daemon.

The only way I have to fix this is going to each individual project and running the jar task. Is this the standard way of doing it or is it a bug?

frnusmartobjects avatar Aug 14 '18 17:08 frnusmartobjects

You might need to adjust the order of the projects depending on each other. To avoid some misconfiguration, please use afterEvaluate { project -> } as this plugin does change the jfx-tasks after the project got evaluated. (This was done because of detecting missing jfx-classes)

FibreFoX avatar Aug 14 '18 18:08 FibreFoX

Thank you very much for you fast response. I am not very experienced in gradle, so if it isn't a problem for you, could you explain a bit more what you mean with "adjust the order of the projects" and how should I use afterEvaluate { project -> } ?

What I had in mind is craete a task that runs before jfx, but I am not sure how to accomplish this and also when I add any dependsOn to the jfx task it says that it can't find the task it should depend to

frnusmartobjects avatar Aug 14 '18 18:08 frnusmartobjects

Aditionally, what do you mean with "detecting missing jfx-classes"? What kind of classes could be missing, for example custom components?

frnusmartobjects avatar Aug 14 '18 18:08 frnusmartobjects

Gradle maintains it's own order of processing your build-instructions. As they (the authors of Gradle) think that they do know better, they are giving you a way for controlling the ordering, you might want to lookup this inside the documentation: https://docs.gradle.org/current/userguide/build_lifecycle.html

Regarding the detection: when a java class gets instanciated, all import-instructions are getting resolved, but when working with OpenJDK, you are missing the JavaFX-parts (as they are not part of the main-standard). The so called OracleJDK (the JDK which is distributed by Oracle itself) does contain the core JDK + the JavaFX addendum part (they will change this with JDK11 again).

So in order to have the tasks being available as buildscript extensions, I rewrote some parts after that evaluation-process happened,, but changed that approach in later versions of this plugin, because it made a lot of trouble.

Just a small reminder: https://github.com/FibreFoX/javafx-gradle-plugin/issues/119 This plugin will get replaced by a different plugin (I really hope to have this prior JDK11 .... but personal life makes it very hard to get time for this)

FibreFoX avatar Aug 14 '18 19:08 FibreFoX

@frnusmartobjects any progress on your side?

FibreFoX avatar Aug 15 '18 18:08 FibreFoX

@FibreFoX Hi, thanks for the follow up. Not for now. I decided to run the jar task manually for each project since I am a bit short in time, although when I have more time I will investigate how to automate this, and I will post here the followup

frnusmartobjects avatar Aug 15 '18 18:08 frnusmartobjects