I have a plugin where I need to toggle a property base on whether a task is going to run or not. This is needed because when running in ide (intellij) this flag needs to be disabled whereas if the specific runtime task is run this flag needs to be enabled.
I've tried
gradle.taskGraph.whenReady { if (it.hasTask(tasks.runtime)) {
javafx.configuration = "compileOnly"
}
}
but this gives me a error
Cannot change dependencies of dependency configuration ':implementation' after it has been included in dependency resolution.
Is there any way to set this property earlier (during plugin configuration) based on tasks or a better way to complete this?
In build script you can evaluate following properties which IDE adds:
idea.active
property that IDE sets when you run Gradle tasks from IDE;
idea.sync.active
property which is added by IDE when IDE reloads project from Gradle build scripts.
For example: System.getProperty('idea.active')
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With