Commit3eec27a723introduced a custom resource filter for projects imported into Eclipse IDE. However, commit85eb589c2eintroduced generated source files within the Gradle 'build' folder, and the filter prevents Eclipse from seeing the generated sources, resulting in build errors within the spring-oxm project in Eclipse. This commit therefore effectively reverts3eec27a723by removing the resource filter. See gh-25787
111 lines
3.7 KiB
Groovy
111 lines
3.7 KiB
Groovy
import org.gradle.plugins.ide.eclipse.model.ProjectDependency
|
|
import org.gradle.plugins.ide.eclipse.model.SourceFolder
|
|
|
|
apply plugin: "eclipse"
|
|
|
|
eclipse.jdt {
|
|
sourceCompatibility = 1.8
|
|
targetCompatibility = 1.8
|
|
}
|
|
|
|
// Replace classpath entries with project dependencies (GRADLE-1116)
|
|
// https://issues.gradle.org/browse/GRADLE-1116
|
|
eclipse.classpath.file.whenMerged { classpath ->
|
|
def regexp = /.*?\/([^\/]+)\/build\/([^\/]+\/)+(?:main|test)/ // only match those that end in main or test (avoids removing necessary entries like build/classes/jaxb)
|
|
def projectOutputDependencies = classpath.entries.findAll { entry -> entry.path =~ regexp }
|
|
projectOutputDependencies.each { entry ->
|
|
def matcher = (entry.path =~ regexp)
|
|
if (matcher) {
|
|
def projectName = matcher[0][1]
|
|
def path = "/${projectName}"
|
|
if(!classpath.entries.find { e -> e instanceof ProjectDependency && e.path == path }) {
|
|
def dependency = new ProjectDependency(path)
|
|
dependency.exported = true
|
|
classpath.entries.add(dependency)
|
|
}
|
|
classpath.entries.remove(entry)
|
|
}
|
|
}
|
|
classpath.entries.removeAll { entry -> (entry.path =~ /(?!.*?repack.*\.jar).*?\/([^\/]+)\/build\/libs\/[^\/]+\.jar/) }
|
|
}
|
|
|
|
// Use separate main/test outputs (prevents WTP from packaging test classes)
|
|
eclipse.classpath.defaultOutputDir = file(project.name+"/bin/eclipse")
|
|
eclipse.classpath.file.beforeMerged { classpath ->
|
|
classpath.entries.findAll{ it instanceof SourceFolder }.each {
|
|
if (it.output.startsWith("bin/")) {
|
|
it.output = null
|
|
}
|
|
}
|
|
}
|
|
eclipse.classpath.file.whenMerged { classpath ->
|
|
classpath.entries.findAll{ it instanceof SourceFolder }.each {
|
|
it.output = "bin/" + it.path.split("/")[1]
|
|
}
|
|
}
|
|
|
|
// Ensure project dependencies come after 3rd-party libs (SPR-11836)
|
|
// https://jira.spring.io/browse/SPR-11836
|
|
eclipse.classpath.file.whenMerged { classpath ->
|
|
classpath.entries.findAll { it instanceof ProjectDependency }.each {
|
|
// delete from original position
|
|
classpath.entries.remove(it)
|
|
// append to end of classpath
|
|
classpath.entries.add(it)
|
|
}
|
|
}
|
|
|
|
// Ensure that JMH sources and resources are treated as test classpath entries
|
|
// so that they can see test fixtures.
|
|
// https://github.com/melix/jmh-gradle-plugin/issues/157
|
|
eclipse.classpath.file.whenMerged {
|
|
entries.findAll { it.path =~ /src\/jmh\/(java|resources)/ }.each {
|
|
it.entryAttributes['test'] = 'true'
|
|
}
|
|
}
|
|
|
|
// Allow projects to be used as WTP modules
|
|
eclipse.project.natures "org.eclipse.wst.common.project.facet.core.nature"
|
|
|
|
// Include project specific settings
|
|
task eclipseSettings(type: Copy) {
|
|
from rootProject.files(
|
|
"src/eclipse/org.eclipse.jdt.ui.prefs",
|
|
"src/eclipse/org.eclipse.wst.common.project.facet.core.xml")
|
|
into project.file('.settings/')
|
|
outputs.upToDateWhen { false }
|
|
}
|
|
|
|
task eclipseWstComponent(type: Copy) {
|
|
from rootProject.files(
|
|
"src/eclipse/org.eclipse.wst.common.component")
|
|
into project.file('.settings/')
|
|
expand(deployname: project.name)
|
|
outputs.upToDateWhen { false }
|
|
}
|
|
|
|
task eclipseJdtPrepare(type: Copy) {
|
|
from rootProject.file("src/eclipse/org.eclipse.jdt.core.prefs")
|
|
into project.file(".settings/")
|
|
outputs.upToDateWhen { false }
|
|
}
|
|
|
|
task cleanEclipseJdtUi(type: Delete) {
|
|
delete project.file(".settings/org.eclipse.jdt.core.prefs")
|
|
delete project.file(".settings/org.eclipse.jdt.ui.prefs")
|
|
delete project.file(".settings/org.eclipse.wst.common.component")
|
|
delete project.file(".settings/org.eclipse.wst.common.project.facet.core.xml")
|
|
}
|
|
|
|
task eclipseBuildship(type: Copy) {
|
|
from rootProject.files(
|
|
"src/eclipse/org.eclipse.jdt.ui.prefs",
|
|
"src/eclipse/org.eclipse.jdt.core.prefs")
|
|
into project.file('.settings/')
|
|
outputs.upToDateWhen { false }
|
|
}
|
|
|
|
tasks["eclipseJdt"].dependsOn(eclipseJdtPrepare)
|
|
tasks["cleanEclipse"].dependsOn(cleanEclipseJdtUi)
|
|
tasks["eclipse"].dependsOn(eclipseSettings, eclipseWstComponent)
|