TheBoegl / gradle-launch4j

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

Doesn't seem to work #28

Closed javydreamercsw closed 8 years ago

javydreamercsw commented 8 years ago

I guess it's due to the lack of experience, but the task has no output to help debugging either. Here's the script I'm using. hope it helps somehow to find my issue.

task assembleGameExe <<{ launch4j { mainClassName = 'pcgen.system.Main' icon = "${projectDir}/installers/win-installer/Local/pcgen.ico" outfile = "${projectDir}/code/pcgen.exe" jreMaxVersion = '1.8.9' jdkPreference = 'preferJre' initialHeapSize = 128 maxHeapSize = 512 stayAlive = false bundledJre64Bit = true jar = "${projectDir}/pcgen.jar" dontWrapJar = true bundledJrePath = 'jre' } }

I don't see the exe file being created. Just this output:

Executing: gradle :assembleGameExe Arguments: [-c, /home/javier/Desktop/PCGen/settings.gradle]

:assembleGameExe

BUILD SUCCESSFUL

Total time: 3.101 secs

TheBoegl commented 8 years ago

@javydreamercsw You seem to be barking up the wrong tree. Change your configuration as follows: build.gradle:

launch4j {
    mainClassName = 'pcgen.system.Main'
    icon = "${projectDir}/installers/win-installer/Local/pcgen.ico"
    outfile = "${projectDir}/code/pcgen.exe"
    jreMaxVersion = '1.8.9'
    jdkPreference = 'preferJre'
    initialHeapSize = 128
    maxHeapSize = 512
    stayAlive = false
    bundledJre64Bit = true
    jar = "${projectDir}/pcgen.jar"
    dontWrapJar = true
   bundledJrePath = 'jre'
}

Then just call the launch4j task createExe.

javydreamercsw commented 8 years ago

Still don't understand what's the difference between yours and mine. Have no clue what you mean by:

Then just call the launch4j task createExe.

javydreamercsw commented 8 years ago

Made some progress, now I'm getting this error:

FAILURE: Build failed with an exception.

Was unable to find anything in the documentation.

TheBoegl commented 8 years ago

This error is due to the following line jar = "${projectDir}/pcgen.jar". Usually when you distribute your application, you like to place the jar relative to the executable. Hence, Launch4j enforces this, because your "${projectDir}" folder may no even exist on a 'target pc' for your application. Try removing the jar definition - the line above - and check if that works. This plugin then uses the jar created by the jar task.

javydreamercsw commented 8 years ago

Now I got this error:

FAILURE: Build failed with an exception.

This is the path in this variable created by the tool:

/media/javier/5CEC724EEC722306/Netbeans/pcgen/code/pcgen.exe

I'll move my project out of my external drive, but I shouldn't need to...

javydreamercsw commented 8 years ago

It did work in creating the exe, but I need it tu use the specified JRE.

With the launch4j app I can use a property like this:

pcgen.jar

But with the plugin it gives me error:

Even using the generated configuration file works under launch4j app but fails on the script.

TheBoegl commented 8 years ago

Replace your last commit javydreamercsw/pcgen@a66ac26090d58a6db977850574c124b71bab9e04

//See: https://github.com/TheBoegl/gradle-launch4j
//task createWindowsExe {
//    new File("${projectDir}/code/pcgen.exe").delete()
//    launch4j {
//        mainClassName = 'pcgen.system.Main'
//        icon = "${projectDir}/installers/win-installer/Local/pcgen.ico"
//        outfile = "${projectDir}/code/pcgen.exe"
//        jreMinVersion = '1.8.0'
//        jreMaxVersion = '1.8.9'
//        jdkPreference = 'preferJre'
//        initialHeapSize = 128
//        maxHeapSize = 512
//        stayAlive = false
//        jar = "pcgen.jar"
//        bundledJre64Bit = true
//        dontWrapJar = true
//        bundledJrePath = 'jre'
//    }
//}

with

//See: https://github.com/TheBoegl/gradle-launch4j
launch4j {
    mainClassName = 'pcgen.system.Main'
    icon = "${projectDir}/installers/win-installer/Local/pcgen.ico"
    outfile = "pcgen.exe"
    jreMinVersion = '1.8.0'
    jreMaxVersion = '1.8.9'
    jdkPreference = 'preferJre'
    initialHeapSize = 128
    maxHeapSize = 512
    stayAlive = false
    bundledJre64Bit = true
    dontWrapJar = true
    bundledJrePath = 'jre'
}

Then just call ./gradlew createExe and copy the created pcgen.exe and lib folder to your destination folder. Though this can be automated, try it this way first...

javydreamercsw commented 8 years ago

Looks like that did the trick!

javydreamercsw commented 8 years ago

Still feels like your plugin goes thru the work of copying dependencies, etc when it's configured not to wrap the jar.

TheBoegl commented 8 years ago

It has to! Wrapping the jar -- in the launch4j sense -- means to include it into the executable. Nonetheless the dependencies of that jar, wrapped or not, should be available while executing the exe. Hence, they are located next to the executable in a default location named lib.

javydreamercsw commented 8 years ago

I see. Looks like I need to tweak my files more. Looks like they did this folder manually. Thanks!