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

VIN

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?
    }
}
GreenSaguaro

Try this in your plugin:

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

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

How to update the Shadow Plugin from gradle?

How to execute a specific plugin/Mojo from a pom.xml programmatically?

How to execute a main class in a jar from gradle using the 'java' command

How do I execute ant.java properly from gradle?

Gradle -- execute multiple commands from task

Execute gradle build task from any location

How to execute git command from build.gradle?

How to move a gradle function from build.gradle into a plugin?

Gradle Artifactory Plugin - How to publish artifacts from multiple modules in a project?

how to execute 'gradle build' command from gradle.build script

How can I apply the Gradle Versions Plugin from an initscript?

How can I make my Gradle plugin auto-execute its tasks?

How to turn a Gradle Script Plugin into a Binary Plugin

How to configure Gradle Java plugin from a custom Gradle plugin

How to execute shell from Active Choices Plugin groovy script in Jenkins

How to use plugin version from gradle.properties in Gradle Kotlin DSL?

Debug / Execute Discourse plugin from command line

Add repository from Gradle plugin

Is there a way to configure Gradle plugin to execute task with build?

Unable to execute SQL files using flyway plugin in gradle

How to use gradle plugin configuration in the plugin apply?

How to invoke Annotation Processor from Gradle plugin

Execute task from standalone gradle file

How can you override an existing Gradle plugin from a local repository?

How to execute SBT plugin's tasks from within IntelliJ IDEA CE?

How do I execute a Gradle plugin task before another one?

How can I read the gradle sonar runner properties from a gradle plugin?

How to use gradle Artifactory plugin in gradle subproject

Execute WordPress Plugin From Token?