This plugin is also available on the Gradle Plugin Repository.
This project uses the Eclipse Plugin to configure a multi-project Gradle build as a single-project view in the Eclipse IDE, without the use of the Eclipse Gradle Plugin.
The Gradle Plugin for Eclipse loads each subproject as a separate project within the IDE. With this Gradle plugin, a multiple-project view within Eclipse will look like the screen below (similar to IDEA's Gradle Plugin). In addition, you can keep your IDE lightweight and not have to install the Gradle Plugin.
- The master Gradle build file should have the follow snippet:
buildscript {
repositories {
maven {
url 'https://github.com/kkdt/mavenrepo/raw/master'
}
}
dependencies {
classpath "kkdt.gradle.eclipseone:eclipseone:0.5"
}
}
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'kkdt.gradle.eclipseone'
- Execute the Eclipse plugin as normal:
gradle cleanEclipse eclipse
This plugin looks for Java subprojects and will configure their sources and library configurations into the root project's Eclipse Model. Because of this, the convention is as follows:
- The root project needs the Java plugin:
apply plugin: 'java'
- The root project needs the Eclipse plugin:
apply plugin: 'eclipse'
- Subprojects that include the Eclipse plugin will not include Eclipse artifacts (removed by this plugin)
- You will need to run
gradle cleanEclipse eclipse
again if configurations change (i.e. add a newcompile
configuration to a subproject)
EclipseOneModel
is a project extension and is defined as follows:
eclipseone {
jreContainerPath = null // i.e. 'org.eclipse.jdt.launching.JRE_CONTAINER'
excludedJavaProjects = [] // Java projects to exclude from classpath
ignoreExcludedJavaProjectsArtifacts = false // set to true to also ignore any jar artifacts from excluded java projects
}
Suppose the baseline has a subproject that performs a wsimport
or xjc
that is taken care of by the build. The eclipseone
model can be configured to exclude the source for that subproject in the IDE if its jar is referenced by another project.
Access restriction can occur when the baseline uses JRE sources when loading the baseline in Eclipse (see this StackOverflow thread). Override the jreContainerPath
in the plugin model to use org.eclipse.jdt.launching.JRE_CONTAINER
fixes this issue - the one generated by the Eclipe Plugin is something like
org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8/
vs. (the overriden)
org.eclipse.jdt.launching.JRE_CONTAINER
Publish to a Maven-style file repository.
gradle publish
Publish to local Maven (classpath dependencies would just be classpath "gradle.plugin.kkdt.gradle.eclipseone:eclipseone:0.5"
).
gradle publishToMavenLocal