I have a build that was working fine. Then I added the idea
plugin and the build started failing with Duplicate root element common
. My project does have more than one subproject named “common” (e.g. utils/common, server/common, android/common, etc.) but, as I understand it, the idea plugin should be OK with that. Here’s the build scan:
Thanks for the build scan @oliverdain, this helps tremendously. I’ll investigate what might be happening here.
Also, is there a specific reason you wish to use the ‘idea’ plugin vs just the plain Gradle import capability provided by IntelliJ/Android Studio?
I’ve been able to create a simple reproduction case for this.
I think the problem has something to do with no having the ‘idea’ plugin applied to the conflicting project’s parent. That is for projects :foo:common
and :bar:common
applying the ‘idea’ plugin to :foo
and :bar
seems to not result in the error. Perhaps this is a feasible workaround for you for now.
I’ve opened a GitHub issue for this.
@mark_vieira thanks for the response. The reason I’m using the idea plugin is that some of my projects have provided dependencies (e.g. dependencies that I need during compile but not at runtime as they’re already on the CLASSPATH). I can set that up and everything builds but IntelliJ doesn’t understand it and I get lots of unresolved dependency
issues. Using the plugin I can add the provides stuff to intellij and everything works.
@mark_vieira thanks for filing the bug. An ETA on a fix? Wondering if I should come up with a workaround or just wait for the bug fix.
The workaround for now would be to apply the ‘idea’ plugin to all projects.
@mark_vieira I’m not sure I can do that, though it may just be gradle ignorance. The issue is that the “parent project” doesn’t exist at all. For example, we have a utils
directory that has several sub-directories (like common
, httputils
, etc.). Each of those subdirectories contains code and a build.gradle
but utils
itself contains no files and no build.gradle. It’s just subdirectories. I suppose I could put a build.gradle
in each such directory, add it to settings.gradle
and then put nothing but the idea plugin into those directories.
The other alternative would be to rename the common
directories to common_utils
, common_server
, or similar.
Those projects exist, they are just “empty”. You could just add the following to the root build.gradle and call it a day.
subprojects {
apply plugin: 'idea'
}
Perfect! I didn’t know you could do that. Thanks @mark_vieira!