2015-12-22 178 views
1

我試圖通過此Gradle插件https://github.com/TheBoegl/gradle-launch4j使用http://launch4j.sourceforge.net/Gradle任務不執行其依賴項

當我做gradle clean launch4j我得到以下輸出。

: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. 

我不明白爲什麼copyResources沒有運行。很明顯:copyL4jLib被執行。 Gradle不應該知道copyResources先於它並且先執行它嗎?

這是我的gradle -version信息。

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 

這裏是我的構建腳本。

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 

回答

3

看來這個插件正在做一些事情。首先,它會創建任務(見https://github.com/TheBoegl/gradle-launch4j/blob/develop/src/main/groovy/edu/sc/seis/launch4j/Launch4jPlugin.groovy#L50),然後替換任務的afterEvaluate塊(參見https://github.com/TheBoegl/gradle-launch4j/blob/develop/src/main/groovy/edu/sc/seis/launch4j/Launch4jPlugin.groovy#L122

要解決這個問題,你應該能夠把你的任務相關的設置在afterEvaluate塊,以確保您配置replaced任務:

afterEvaluate { 
    copyL4jLib.dependsOn copyResources  
} 
相關問題