Remove classpath entries for non-existent libraries added by mrjar plugin

The me.champeau.mrjar Gradle plugin causes non-existent libraries to be
added to the Eclipse classpath, such as:

<classpathentry kind="lib" path="/workspaces/spring-framework/spring-core/build/classes/kotlin/java21">
  <attributes>
    <attribute name="gradle_used_by_scope" value="java21"/>
    <attribute name="test" value="true"/>
  </attributes>
</classpathentry>

This results in build errors in Eclipse IDE like the following.

Project 'spring-core' is missing required library:
  '/workspaces/spring-framework/spring-core/build/classes/kotlin/java21'

This commit filters those and removes them.
This commit is contained in:
Sam Brannen 2023-10-29 11:55:36 +01:00
parent fc77172d67
commit 8770544769
1 changed files with 9 additions and 0 deletions

View File

@ -1,3 +1,4 @@
import org.gradle.plugins.ide.eclipse.model.Library
import org.gradle.plugins.ide.eclipse.model.ProjectDependency
import org.gradle.plugins.ide.eclipse.model.SourceFolder
@ -67,6 +68,14 @@ eclipse.classpath.file.whenMerged {
}
}
// Remove classpath entries for non-existent libraries added by the me.champeau.mrjar
// plugin, such as "spring-core/build/classes/kotlin/java21".
eclipse.classpath.file.whenMerged {
entries.findAll { it instanceof Library && !file(it.path).exists() }.each {
entries.remove(it)
}
}
// Include project specific settings
task eclipseSettings(type: Copy) {
from rootProject.files(