我有一个插件,我需要根据任务是否要运行来切换属性。这是必需的,因为在 ide (intellij) 中运行时,需要禁用此标志,而如果运行特定的运行时任务,则需要启用此标志。
我试过了
gradle.taskGraph.whenReady { if (it.hasTask(tasks.runtime)) {
javafx.configuration = "compileOnly"
}
}
但这给了我一个错误
Cannot change dependencies of dependency configuration ':implementation' after it has been included in dependency resolution.
有没有什么方法可以根据任务更早地(在插件配置期间)设置这个属性,或者有更好的方法来完成这个?