Reputation: 26858
I am starting out with Gradle. I have written my build script, but now Gradle claims always it is UP-TO-DATE, but I manually deleted the output folder, so it is no longer up to date. I tried with '--rerun-tasks
', 'clean
' or 'cleanSomeTask
' but it keeps saying UP-TO-DATE.
I also tried removing the .gradle
directory that gets created in the project folder, but still the same. Is there anything else I can try?
My build file has a custom name, so I always specify the '-b
' option to point to that file, I don't know if that is important or not.
This is my build file (modbus-script.gradle
):
import java.text.SimpleDateFormat
defaultTasks 'packageAll'
apply plugin: 'base'
apply plugin: 'java'
def buildFolderName = 'target/modbus'
def buildFolder = new File( buildFolderName )
def buildFolderZipSource = "${buildFolderName}/zip-source"
def scriptSrcLocation = 'src/main/script/com/company/script/groovy/modbus'
def scriptSrcName = 'Modbus.groovy'
repositories {
mavenCentral()
maven {
url 'http://nexus:8081/nexus/content/groups/public'
}
}
dependencies {
compile group: 'net.wimpi', name: 'jamod', version: '1.2.3'
compile group: 'org.rxtx', name:'rxtx', version: '2.1.7'
}
def buildTime() {
def df = new SimpleDateFormat("yyyyMMdd'T'HHmm")
df.setTimeZone(TimeZone.getTimeZone("UTC"))
return df.format(new Date())
}
task prepare {
println "Preparing..."
buildFolder.mkdirs()
}
task copyGroovyScript(dependsOn: prepare, type: Copy) << {
from "${scriptSrcLocation}/${scriptSrcName}"
into buildFolderZipSource
}
task copyDependencies(dependsOn: copyGroovyScript, type: Copy) << {
from sourceSets.main.compileClasspath
into "${buildFolderZipSource}/groovy-plugin-lib"
}
task packageAll(dependsOn: copyDependencies, type:Zip) << {
archiveName "modbus-${buildTime()}.zip"
destinationDir buildFolder
from buildFolder
}
Upvotes: 0
Views: 122
Reputation: 28653
The different tasks are marked as up-to-date because gradle things there is nothing to copy. Running the build with -i
will provide you further information why a task is marked as up-to-date.
The problem why those tasks are marked as up-to-date is that you use <<
when declaring your tasks. This means you're adding a task action instead of configuring your task. Get rid of the <<
's in your build script and try again.
Upvotes: 1