ziggy/script-plugins/eclipse.gradle

46 lines
1.8 KiB
Groovy

// Generates the Eclipse .classpath and .project files.
eclipse {
classpath {
defaultOutputDir = file("$buildDir/eclipse/default")
// outputBaseDir = file("$buildDir/eclipse")
downloadSources = false
downloadJavadoc = false
// Gradle 4.4 now specifies all of the output directories, but puts
// them in the Eclipse default of "bin". There is a feature request
// to add classpath.outputBaseDir that has the same syntax and effect
// as the now-useless defaultOutputDir. In the meantime, update the
// path manually.
file.whenMerged {
entries.each { entry ->
if (entry.kind == "src" && entry.hasProperty("output")) {
// The use of $buildDir does not return build.
entry.output = entry.output.replace("bin/", "build/eclipse/")
}
}
}
// Add native libraries for HDF5.
file.whenMerged { classpath ->
def hdf5 = classpath.entries.findResult { entry ->
if (entry.kind == 'lib' && entry.path.contains('jarhdf5')) {
return entry
}
}
// TODO Get the following pseudocode to work to avoid hardcoding path
//File jar = findFileInConfiguration(configurations.runtime, 'jarhdf5-1.12.2')
//hdf5.setNativeLibraryLocation(jar.getParent())
hdf5.setNativeLibraryLocation("$outsideDir/lib")
}
// Add the JPA metamodel directory compiled by Gradle to the Eclipse classpath.
file.withXml { xml ->
xml.asNode().appendNode("classpathentry", [ kind: "src", path: "build/generated/sources/annotationProcessor/java/main" ])
}
}
}
// Avoid duplicate classpath entries.
tasks.eclipse.dependsOn(cleanEclipse)