Calling gradle sync from Idea plugin programmatically
Answered
Hi
Our plugin overwrites some gradle files, e.g. sets non-default build variants.
How to programmatically call gradle sync from plugin so that the user does not need to manually click on this yellow banner
Unfortunately http://stackoverflow.com/q/28185682 does not help in my case.
Thank you
Please sign in to leave a comment.
You can try the following api: com.intellij.openapi.externalSystem.util.ExternalSystemUtil#refreshProject
For me
worked perfectly fine for Android Studio and it perfectly suits my purpose.
also worked somehow even with the Idea, but it updated the build variants only when I clicked on these to change.
Спасибо!
Vladislav Soroka: In latest APIs GradleConstants is not present. Can you share updated snippet please?
org.jetbrains.plugins.gradle.util.GradleConstants is part of Gradle plugin
ExternalSystemUtil.refreshProject(
project, GradleConstants.SYSTEM_ID, rootProjectPath, false,
ProgressExecutionMode.IN_BACKGROUND_ASYNC);
Brings the problem: requires plugin 'com.intellij.gradle' to be installed
Altough i have:
plugin.xml: <depends>com.intellij.gradle</depends>
and build.gradle.kts:
intellij {
version.set("2023.1.3")
type.set("IC") // Target IDE Platform
plugins.set(listOf("java", "com.intellij.java", "com.intellij.gradle"))
}