Reading project.properties triggers configuration of any DeferredConfigurable extensions


(detelinyordanov) #1

We are using the new incubating PublishingExtension and registering an IvyPublication in its publication container. Since we need to manually populate the ‘IvyPublication’ with all artifacts from all configurations, we are relying on the deferred configuration support for this extension, and thus expect that the extension will be configured at the last possible moment so that all artifacts are already available.

Unfortunately it turns out that reading the project properties using project.properties is triggering the configuration of the publishing extension and thus reading all configuration artifacts too early.

Shall we instruct all users not to do that? If this is “by design”, then I guess it deserves to be documented as a known limitation - IMHO it is not that obvious that reading all project properties implies configuring all DeferredConfigurable extensions. Do you have any suggestion how to make sure the build fails early, if a deferred configurable is configured before project is evaluated (which is undesirable in our case)?

P.S. We are using Gradle 1.5

Regards,

Detelin


(Luke Daley) #2

I wouldn’t say this is by design specifically. The deferred configurable is very much a (controlled) trial of a solution to a very tricky problem and there are cases like this that we haven’t fully factored in. So I’m grateful that you’re trying it out and letting us know of your experience :slight_smile: I can’t think of a way around this problem with 1.5. I’m going to have to raise this as a discussion on the dev list and explore how to solve this.


(detelinyordanov) #3

Thanks Luke,

In the meantime we are instructing teams to use project.hasProperty and project.property instead. Also, we added a check in the configuration block of the publishing extension so that it fails if project is not yet evaluated:

publishing {
  publications {
    ivy(IvyPublication) {
       assert project.getState().getExecuted() : "Accessing the ivy publication before project '$project.path' is evaluated is not allowed."
      ...
    }
  }
}

Hopefully this would catch any other methods that could cause early configuration of deffered configurable extensions.

Regards,

Detelin


(Luke Daley) #4

Dev list discussion can be found here: http://gradle.1045684.n5.nabble.com/Calling-project-properties-triggers-configuration-of-deferred-configurables-tp5711226.html


(Luke Daley) #5

Raised as GRADLE-2754.