Looking for Gradle 2.2 Model configuration usage docs

The release notes say the dependencies are no longer defined before ‘afterEvaluate’. I can’t find any reference to the new ‘model’ configuration in the docs. How can I port this code to the 2.2 configuration?

Can you please provide some info on what you are trying to do.

The original code cleared the dependencies out of the publish task. This does not work in 2.2

afterEvaluate { publish.dependsOn.clear() }

This will now be:

‘’’ model {

tasks.publish { dependsOn.clear() } } ‘’’

Here is a test case. It looks like there was a regression at some point:

apply plugin:'java'
apply plugin:'maven-publish'
  publishing {
   repositories.maven { url "localhost" }
   publications {
      java(MavenPublication) { from components.java }
task testModel {
   doLast { assert publish.dependsOn == [] as HashSet }
model { tasks.publish { dependsOn.clear() } }
$ gradle --version | grep Gradle; gradle testModel
Gradle 2.1
Configuration on demand is an incubating feature.
  Total time: 1.121 secs
$ gradle --version | grep Gradle; gradle testModel
Gradle 2.2
Configuration on demand is an incubating feature.
:testModel FAILED
  FAILURE: Build failed with an exception.
  * Where:
Build file '/home/pcm/dir/build.gradle' line: 11
  * What went wrong:
Execution failed for task ':testModel'.
> assert publish.dependsOn == [] as HashSet
     [task ':publishJavaPublicationToMavenRepository']
         task ':publish'
  * Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
  Total time: 1.258 secs

Hmm, that’s a nasty one. The “new” publishing stuff is in an interim state while we build out more of the configuration infrastructure. The fundamental problem is that the maven publishing is mutating the ‘publish’ task when it shouldn’t be, so we aren’t ordering the configuration correctly.

The only solution I can think of is to use for the time being is ‘gradle.projectsEvaluated { tasks.publish.dependsOn.clear() }’.

I added ‘gradle.projectsEvaluated { tasks.publish.dependsOn.clear() }’ and the test cases pass. However, when I execute the build the ‘:publishJavaPublicationToMavenRepository’ task is still running. I thought clearing the task dependencies would prevent this.

$ gradle publish -m
Configuration on demand is an incubating feature.
:generatePomFileForJavaPublication SKIPPED
:compileJava SKIPPED
:processResources SKIPPED
:classes SKIPPED
:publishJavaPublicationToMavenRepository SKIPPED
:publish SKIPPED
  Total time: 1.359 secs

So clearing dependsOn worked in 2.1?

tasks.publish { dependsOn.clear() }

works in 2.1

gradle.projectsEvaluated { tasks.publish.dependsOn.clear() }

does not work in either 2.1 or 2.2

I did get a workaround for 2.2 that does what I want:

gradle.taskGraph.whenReady { taskGraph ->
  if (taskGraph.hasTask(publish)) {
    publishJavaPublicationToMavenRepository.enabled = false