简体   繁体   中英

Add a dependency on a task before the task is defined in Gradle

I want to create a task that dependsOn compileDebugJava . However, the Java plugin creates the compileDebugJava task after I declare my dependency and Gradle returns:

Task with path 'compileDebugJava' not found in project

So, is it possible to state my dependency for a task that will be created later?

Gradle has syntax for that:

task yourTask(dependsOn: 'compileDebugJava') {
    doLast {
        ...
    }
}

Note that the following equivalent syntax using the << operator has been deprecated:

task yourTask(dependsOn: 'compileDebugJava') << {
    ...
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM