I think I solved this. As far as I can tell the problem was that I attempted to have ProfileDefinition also be a Binding. I was playing with how to expose this to the “Gradle fragment” I apply and just tried playing with that for no real good reason
Anyway, I removed that and it seems to work pretty consistently now.
Relatedly, any pointers to resources that discuss how to expose beans / dsl-extensions to gradle fragments? Something like project.getExtensions().create(...)
but that I can later remove?
The basic idea is that the plugin finds a number of “database profiles” used for testing. Each profile is defined using a gradle fragment. At them moment I apply each fragment ((GradleProfileFragment == ProfileDefinition) as:
final GradleProfileFragment profileFragment = new GradleProfileFragment( defaultProfileName );
project.getConvention().getPlugins().put( PROFILE_KEY, profileFragment );
try {
project.apply( Collections.singletonMap( "from", profileFile ) );
}
finally {
project.getConvention().getPlugins().remove( PROFILE_KEY );
}
So that profile descriptor should only be in effect while processing that single file.
What I do not understand is that PROFILE_KEY
is "profile"
, but I cannot specify profile {}
in the fragment. I have to use the unqualified attribute names. E.g., this works:
beforeEachTest {
...
}
However, this does not:
profile {
beforeEachTest {
...
}
}
How would I make that work? Can I add it to that Map passed to Project#apply
? Another way?
Thanks again James