How to make Buildship use a specific settings.gradle instead of the default one?

Buildship doesn’t work very well for composite builds (GHI #511, GHI #908), but at least some of the problems can be worked around when tweaking which projects actually use includeBuild in their settings.gradle. The problem is that settings.gradle becomes difficult to maintain that way, because only Buildship requires those workarounds, not Gradle itself e.g. when executing on the shell or in Jenkins.

That’s why I thought of using different settings.gradle with different names for different environments. I can think of various ways to do that: Eclipse manages its own config for executing Gradle and in that one can provide additional arguments, like –settings-file=somewhere/else/settings.gradle But each and every user would need to do that with each and every Eclipse-instance.

Is there some additional way using a plugin? I would like to have something like the following pseudocode. The applied plugin should detect Buildship and if so, apply settings from another settings.gradle and abort things afterwards, so that includeBuild is not executed anymore.

rootProject.name = 'de.am_soft.sm_mtg.api'
apply from: 'buildSrc/BuildshipHandler.gradle'

includeBuild('../de.am_soft.sm_mtg.parser.ks')
{
	[...]
}

Is that possible? If so, how do I detect Buildship and how do I make applying the current settings file stop? I know that “return” works in settings.gradle itself, but returning from a plugin is different.

Thanks!

1 Like

Sadly, using two different settings file doesn’t work easily, because Gradle doesn’t seem to honor a provided commandline argument for the included(!) builds. The custom settings file for Buildship is read once for the including(!) project and for all included(!) ones the default settings.gradle is read instead.

There is a way to manually make custom settings files used in included builds: Provide a JVM-property in the Eclipse-dialog above ("-D[…]=[…]") and put some code at the top of settings.gradlechecking that property and using a different file instead:

if (System.getProperty('useBuildshipWorkaround'))
{
	apply from: 'settings_buildship.gradle'
	return
}

It seems that this JVM-argument is available with and without using a daemon.

1 Like