Skip to content

Instantly share code, notes, and snippets.

@Kas-tle
Created April 6, 2024 18:46
Show Gist options
  • Save Kas-tle/62931a156e46ff3a8a00e34eb5051f61 to your computer and use it in GitHub Desktop.
Save Kas-tle/62931a156e46ff3a8a00e34eb5051f61 to your computer and use it in GitHub Desktop.
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()
}
}
}
}
}
}
}
@Kas-tle
Copy link
Author

Kas-tle commented Apr 6, 2024

Force eclipse to import gradle source repositories

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment