Configuring publishing extension when there is a semi-circular dependency

plugins

(Rob Spieldenner) #1

I have some teams that will have a multiproject with subprojects a and b. b depends on compile project('a:'). a dependsOn testCompile project(':b') when I apply a plugin that needs to resolve an unrelated configuration i get:

> A problem occurred configuring project ':a'.
> Cannot configure the 'publishing' extension after it has been accessed.

Here is an example to reproduce the issue: https://github.com/rspieldenner/configurationissue

If you go into a/build.gradle and uncomment the testCompile you will see the error.

Is this a bug or do I need to redesign these plugins to not do these steps in an afterEvaluate?

If a redesign how would you:
a) resolve a configuration to get a rule file without afterEvaluate and the rules will affect resolutionRules on the compile/testCompile configurations
b) configure some ivy/pom extra information without knowing what publications might be present


(Lance Java) #2

You might be able to use a configuration to break the circular dependency

project(':a') {
   configurations {
      rules
   } 
   configurations.compile.extendsFrom configurations.rules

   dependencies {
      compile project(':b') 
      rules file('path/to/rules.xml')
   } 
} 

project(':b') {
   dependencies {
      compile project(path: ':a', configuration: 'rules')
   } 
} 

(Rob Spieldenner) #3

Further context: https://github.com/nebula-plugins/gradle-extra-configurations-plugin and https://github.com/nebula-plugins/gradle-resolution-rules-plugin