TheBoegl / gradle-launch4j

A gradle-plugin to create windows executables with launch4j
Apache License 2.0
298 stars 40 forks source link

`copyConfigurable` shows a warning #150

Closed KlemenDEV closed 1 year ago

KlemenDEV commented 1 year ago

In the 3.0.0 update,

copyConfigurable = []

generates the following fault Edit: IntelliJ warning:

Cannot set the value of read-only property 'copyConfigurable' for task ':createExe' of type edu.sc.seis.launch4j.tasks.Launch4jLibraryTask.

making it impossible to define custom copyConfigurable and also breaking examples from README.md.

KlemenDEV commented 1 year ago

I have also noticed some other parameters are marked as final now and give a warning in eg. IDEA, such as classpath and jvmOptions.

TheBoegl commented 1 year ago

Have you tried replacing the deprecated task configuration createExe{...} with the launch4j{...} extension?

TheBoegl commented 1 year ago

@KlemenDEV I cannot reproduce this. Could you please add a code snippet or link to the mentioned readme section?

KlemenDEV commented 1 year ago

@KlemenDEV I cannot reproduce this. Could you please add a code snippet or link to the mentioned readme section?

Here is the code snippet that one can reproduce this with:

createExe {
    copyConfigurable = []

   ...
}

Have you tried replacing the deprecated task configuration createExe with the launch4j extension?

Yes, I wanted to use "modern" approach and not the legacy method, however, I have tried the following two things:

  1. I tried replacing it with launch4j and I get those warnings:

image

so seems in this case, classpath and jvmOptions are final and produce warnings which is also probably not ok.

  1. Tried adding custom Launch4jLibraryTask task
tasks.register<edu.sc.seis.launch4j.tasks.Launch4jLibraryTask>("testTask") {
...
}

but I get the following error:

Could not get unknown property 'register' for task set of type org.gradle.api.internal.tasks.DefaultTaskContainer.

I also tried to import Launch4jLibraryTask like

import edu.sc.seis.launch4j.tasks.Launch4jLibraryTask

but this produces the following error:

unable to resolve class edu.sc.seis.launch4j.tasks.Launch4jLibraryTask

I have also found that I am not the only one having problems with importing or using Launch4jLibraryTask: https://stackoverflow.com/questions/75859510/gradle-launch4j-cant-create-launch4jlibrarytask-due-to-project-afterevaluate-e. The plugin is loaded properly in plugins block and also launch4j and createExe are detected, so there must be something else preventing from importing Launch4jLibraryTask

I have been using 2.5.4 without problems, but in 3.0.0 I just can't find a configuration to make this work. createExe has problem with copyConfigurable, launch4j task with final fields and creating custom Launch4jLibraryTask does not seem to work either.

I guess we will stick with 2.5.4 for now until something is figured out or done on this area.

thc202 commented 1 year ago

Being a Property you should call their methods rather than assigning to it. e.g. jvmOptions.set(…)

KlemenDEV commented 1 year ago

I see. I guess we can use method 1. then. Any idea why

unable to resolve class edu.sc.seis.launch4j.tasks.Launch4jLibraryTask

would happen?

KlemenDEV commented 1 year ago

Being a Property you should call their methods rather than assigning to it. e.g. jvmOptions.set(…)

launch4j {
    ...
    classpath.set(["./lib/*"])
}

yields exe not working and the following debug log ( --l4j-debug):

Info: Classpath not defined.

So even set does not work

TheBoegl commented 1 year ago

Take a look here how the syntax for creating custom tasks is.

I'll take a look at the warning that IntelliJ shows in your screen grab above. To really help you please submit a runnable and self contained example i.e. a build.gradle file demonstrating the issue you're experiencing.

TheBoegl commented 1 year ago

We should probably add setter methods for the HasMultipleValues<T> properties.

KlemenDEV commented 1 year ago

So here is a demo setup showing the following 3 bugs present in the plugin:

  1. see build.gradle: "warnings emitted for classpath and jvmOptions"
  2. see build.gradle and subfile.gradle: unable to resolve class edu.sc.seis.launch4j.tasks.Launch4jLibraryTask when using Launch4jLibraryTask from another .gradle file applied to the build.gradle
  3. see test.exe: generated with configuration from build.gradle. If put next to folder called "jdk" that contains valid JDK, the and executed with "test.exe --l4j-debug", log attached in the zip is generated stating "Classpath not defined." despite it being set in the build.gradle settings

demo.zip

etschelp commented 1 year ago

I can also confirm that setting the classpath property yields no effects. Here is what I do:

launch4j {
    mainClassName = "com.something..."
    classpath.set([
            "additional1/*",
            "additional2/*"
    ])
}

When I print the classpath in my main method I see that everything within the libraryDir is included, but I do not see my additional resources.

When I look into the extension I see that the classpath property is not annotated with @Input, could this be the reason for the property not being mapped?

TheBoegl commented 1 year ago

@KlemenDEV thanks for your example project. All the issues you've found should be fixed as shown in Issue150Test.groovy To create a new LibraryTask in a separate gradle file you have to add the plugin again to the classpath of that file:

buildscript {
    repositories{
        gradlePluginPortal()
    }
    dependencies {
        classpath 'edu.sc.seis.launch4j:launch4j:3.0.1'
    }
}
import edu.sc.seis.launch4j.tasks.Launch4jLibraryTask

tasks.register('createFastStart', Launch4jLibraryTask) {
...

works in your provided example project but fails in the test case as the test environment is not setup to handle this.

TheBoegl commented 1 year ago

Thanks to @etschelp for pointing out the annotation issue. It will be released with the next version 3.0.2, but can be tested now from my artifactory, although I don't see it as a big problem. If you do mind, please open another issue and we'll address it right away.

etschelp commented 1 year ago

I just tested this with the 3.0.1 release, and the classpath property now works as expected. Thanks for fixing this so quickly.

KlemenDEV commented 1 year ago

I can also confirm it works fine now and no warning is emitted in IDEA