Force task execution in Gradle

不打扰是莪最后的温柔 提交于 2019-12-04 06:34:57

Tasks have to be configured in the configuration phase. However, you are configuring it in a task action (<< { ... }), which runs in the execution phase. Because you are configuring the task too late, Gradle determines that it has nothing to do and prints UP-TO-DATE.

Below is a correct solution. Again, I recommend to use doLast instead of << because it leads to a more regular syntax and is less likely added/omitted accidentally.

task backupFile(type: Copy) {
    from file(adjusting_file.replaceAll("\"", "")) 
    into file(backupDestinationDirectory + "/main/")
    doLast {
        println "[INFO] Main file backed up"
    }
}    
Leonardo Ampuero

I have been trying to do this for many days. I have to create many intermidate jars on the processResource step. Following one needs to be created on the processResource step.

processResources.dependsOn(packageOxygenApplet)  //doesn't work

task packageOxygenApplet (type: Jar) {

    println '** Generating JAR..: ' + rsuiteOxygenAppletJarName
        from(sourceSets.main.output) {
            include "org/worldbank/rsuite/oxygen/**"
        }
        baseName = rsuiteOxygenAppletJarName

        manifest {
            attributes("Build-By": oxygenUsername,
                "Specification-Title": "Oxygen World Bank Plugin")
        }
        destinationDir = file("src/main/resources/WebContent/oxygen")

}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!