Home > Net >  How to execute "./gradlew build --refresh-dependencies" from gradle plugin
How to execute "./gradlew build --refresh-dependencies" from gradle plugin

Time:04-20

I'm trying to write my own gradle plugin in Kotlin. It executes fine, but I want the build task to be run with --refresh-dependencies argument, such that the final outcome is the equivalent of

./gradlew build --refresh-dependencies
./gradlew publishToMavenLocal

Here is my custom plugin:

class PublishManager : Plugin<Project> {
    override fun apply(target: Project) {
        target.task("syncAndPublish") {
            doLast {}
        }.dependsOn("publishToMavenLocal")
         .dependsOn("build") // HOW TO ADD -refresh-dependencies HERE?
    }
}

CodePudding user response:

Try this in your plugin:

target.gradle.beforeProject {
    gradle.startParameter.isRefreshDependencies = true
}
  • Related