I'm trying to use http://launch4j.sourceforge.net/ through this Gradle plugin https://github.com/TheBoegl/gradle-launch4j.
When I do gradle clean launch4j
I get the following output.
:clean
:compileJava
:processResources UP-TO-DATE
:classes
:jar
:copyL4jLib
:generateXmlConfig
:createExeWithBin SKIPPED
:unzipL4jBin
:copyL4jBinLib
:createExeWithJar FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':createExeWithJar'.
> meta-tagger.exe not created:
launch4j: Icon doesn't exist.
I do not understand why copyResources is not run. Clearly :copyL4jLib is executed. Shouldn't Gradle figure out that copyResources comes before it and execute it first?
Here is my gradle -version info.
Gradle 2.10
Build time: 2015-12-21 21:15:04 UTC
Build number: none
Revision: 276bdcded730f53aa8c11b479986aafa58e124a6
Groovy: 2.4.4
Ant: Apache Ant(TM) version 1.9.3 compiled on December 23 2013
JVM: 1.8.0_66 (Oracle Corporation 25.66-b18)
OS: Windows 7 6.1 amd64
And here is my build script.
plugins {
id 'edu.sc.seis.launch4j' version '1.6.1'
id 'java'
}
repositories {
mavenLocal()
mavenCentral()
jcenter()
}
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
task copyResources(type: Copy) {
from 'src/main/wrapper-resources/'
into 'build/launch4j'
}
copyL4jLib {
dependsOn copyResources
}
launch4j {
mainClassName = 'com.mpinnegar.Main'
icon = 'favicon.ico'
headerType = 'console'
errTitle = 'Image Tagger'
stayAlive = true
}
tasks.copyL4jLib.dependsOn copyResources
It seems the plugin is doing something weired. First it creates the task (see https://github.com/TheBoegl/gradle-launch4j/blob/develop/src/main/groovy/edu/sc/seis/launch4j/Launch4jPlugin.groovy#L50) and then replaces the task in an afterEvaluate
block (see https://github.com/TheBoegl/gradle-launch4j/blob/develop/src/main/groovy/edu/sc/seis/launch4j/Launch4jPlugin.groovy#L122)
To workaround this issue you should be able to put your task dependency setup in a afterEvaluate
block to ensure you're configuring the replaced
task:
afterEvaluate {
copyL4jLib.dependsOn copyResources
}