Gradle - Intellij automatically adds import for RPM plugin
How do I turn off the auto-import feature for Gradle? Every time I add the plugin:
apply plugin: 'rpm'
Inellij automatically inserts this import at the top of my build.gradle:
import org.apache.tools.ant.taskdefs.optional.Rpm
This breaks my script and I can't get it to stop adding it. How can I make this stop happening?
请先登录再写评论。
Hello,
I'm afraid I can't reproduce the problem at local environment.
Is there a completion popup when you're typing 'rmp'?
Do you have 'IDE Settings | Editor | Auto Import | Add unambiguous imports on the fly' enabled?
Can you provide a screencast that illustrates the problem?
Denis
Thanks Denis for looking into this. Actually, it looks like it is not the apply plugin statement but the RPM task that causes the import. So if this is in the build.gradle it causes the import to happen:
task rpm(dependsOn: jar, type: Rpm) {
}
The way I got it to stop doing that is by removing the Groovy SDK from the module.
I checked my auto-import settings and I did have checked to add unambiguous imports on the fly. This is usually exactly what I want but in this case, it is adding the wrong import and breaking the script (import org.apache.tools.ant.taskdefs.optional.Rpm)
So it looks like I have 2 options: remove the groovy SDK or uncheck the configuration for adding unambiguous imports. I will remove the groovy SDK since I am only using it for gradle and changing the other configuration impacts my entire java project.
Let me know if you still need a screencast.
-Melody
No, a screencast is not necessary then.
You may safely remove groovy sdk because it's used implicitly from the configured gradle distribution.
Denis
Now I'm having this problem with other auto-imports in my gradle script. I can't find any groovy-related items to remove. This is quite annoying since it inserts an import every time I touch the file. This is getting added from a task of type jar:
import weblogic.application.io.Jar
Hello,
We're planning to provide the fix for v.12.1
Denis