Created
April 6, 2024 18:46
-
-
Save Kas-tle/62931a156e46ff3a8a00e34eb5051f61 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
plugins { | |
id("eclipse") | |
} | |
eclipse { | |
classpath { | |
file { | |
withXml { | |
val classpath = asNode() | |
val compositeBuildModuleNames = mutableSetOf<String>() | |
configurations["runtimeClasspath"].resolvedConfiguration.resolvedArtifacts.forEach { artifact -> | |
val id = artifact.id.componentIdentifier | |
if (id is ProjectComponentIdentifier && !id.build.isCurrentBuild) { | |
val classpathEntry = classpath.appendNode("classpathentry") | |
classpathEntry.attributes().put("kind", "lib") | |
classpathEntry.attributes().put("path", artifact.file.absolutePath) | |
compositeBuildModuleNames.add(artifact.moduleVersion.id.name) | |
} | |
} | |
classpath.children().listIterator().apply { | |
while (hasNext()) { | |
val entry = next() as Node | |
val kind = entry.attribute("kind") as? String | |
val path = entry.attribute("path") as? String | |
if (kind == "src" && path != null && compositeBuildModuleNames.any { path.endsWith(it) }) { | |
remove() | |
} | |
} | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Force eclipse to import gradle source repositories