So you want to automate your IDE configuration. The first thing to do is look at a few examples.
- Gradle and Eclipse RCP talk (multi-project Eclipse RCP project)
- lsp4j (xtend IDE example)
- Spotless (single-project Gradle plugin)
- (your example here)
The next thing is to look at the javadoc for OomphIdePlugin
, which inclues a pretty in-depth look at how it works.
First off, search the issues on GitHub to see if somebody already tried to automate your thing. If they didn't make a new one to document what you find and maybe somebody can help you too!
Eclipse gets its behavior from three places:
- project files (
.project
,.classpath
, etc.) which live in the individual project folders - plugin and feature jars (installed by p2)
- workspace settings files (
workspace/.metadata/.plugins/org.eclipse.core.runtime/.settings/something.prefs
)
Depending on what you're trying to automate, you might need to touch all three.
Manipulating project files is a core part of gradle, so we won't cover that here.
Manipulating plugin and feature jars has lots of coverage in the examples above. The entire oomphIdeBlock
extends P2Declarative.
So if you want to add any features, you just add the required p2 repositories, and then specify the features or installable units that you need.
Manipulating the workspace is where it gets tricky. We'll dig in below:
The general formula for setting a particular setting is this:
- Create and open a clean IDE
gradlew ideClean ide
- Close the IDE (which will save the workspace metadata)
- Find the workspace directory (it will be inside
~/.goomph/ide-workspaces
) - Copy the workspace directory
- Open the IDE
gradlew ide
and set the settings you'd like to set - Close the IDE (which will save the workspace metadata)
- Diff the workspace directory before and after
This will let you know which property file you need to set, and what you need to set it to. Once you know what you need to do, this is how you can actually do it:
Most eclipse settings are set in property files. You can set them manually like this:
oomphIde {
...
workspaceProp '.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.e4.ui.css.swt.theme.prefs', {
it.put('themeid', 'org.eclipse.e4.ui.css.theme.e4_classic')
}
}
You can also set xml files. In order to set an xml file, you must first provide a template, and then you can modify the xml using XmlProvider
.
oomphIde {
...
workspaceFile('destination', 'source')
workspaceXml('destination', { xmlProvider -> ...}) // modify your xml here
}
You can also use Eclipse's internal APIs to programatically set properties. This is pretty advanced. You'll want to look at Goomph's code, and examine the subclasses of SetupAction
.
If you have an Eclipse plugin that you'd like to add to to Goomph, we'd love to have it! Take a look at ConventionThirdParty, and add a block for your plugin there. If you look at all subclasses of OomphConvention
, you can see how you can make a configuration DSL for your users, if you'd like. But even just a simple "add the repo, add the feature" is helpful.
If you find out how to set a useful setting, please consider contributing it back! Key places where it might make sense to contribute:
- ConventionStyle is the
style{}
block inoomphIde
. - ConventionJdt is the
jdt{}
block inoomphIde
. - ConventionPde is the
pde{}
block inoomphIde
. - or a new subclass of OomphConvention to create a new way of grouping settings.