Vladimir Sitnikov created CALCITE-7972:
------------------------------------------

             Summary: Aggregate Javadoc tasks resolve subproject configurations 
from the root project, which Gradle 9 rejects
                 Key: CALCITE-7972
                 URL: https://issues.apache.org/jira/browse/CALCITE-7972
             Project: Calcite
          Issue Type: Improvement
          Components: build
            Reporter: Vladimir Sitnikov


{{javadocAggregate}} and {{javadocAggregateIncludingTests}} in the root 
{{build.gradle.kts}} cannot run on Gradle 9 as written. Both tasks look up each 
subproject's {{SourceSetContainer}} and put the {{compileClasspath}} of its 
source sets on the Javadoc classpath, so the root project resolves 
configurations that belong to the subprojects. Gradle 8.14.4 reports this as 
deprecated (b3f0923dac):

{noformat}
$ ./gradlew javadocAggregate --warning-mode=all
Resolution of the configuration :ubenchmark:compileClasspath was attempted from 
a context different than the project context. Have a look at the documentation 
to understand why this is a problem and how it can be resolved. This behavior 
has been deprecated. This will fail with an error in Gradle 9.0. For more 
information, please refer to 
https://docs.gradle.org/8.14.4/userguide/viewing_debugging_dependencies.html#sub:resolving-unsafe-configuration-resolution-errors
 in the Gradle documentation.
{noformat}

Reading another project's model from the root project is also what [Isolated 
Projects|https://docs.gradle.org/current/userguide/isolated_projects.html] 
forbids.

The change is done when {{./gradlew javadocAggregate 
javadocAggregateIncludingTests --warning-mode=all}} prints no "Resolution of 
the configuration ... from a context different than the project context" 
warning, the root build script no longer reads subproject source sets, and both 
tasks document the same packages as before.

h3. One possible shape (untested)

The {{java}} plugin already publishes the source directories of the main source 
set as the consumable variant {{mainSourceElements}} (output trimmed):

{noformat}
$ ./gradlew :core:outgoingVariants --variant mainSourceElements
Attributes
    - org.gradle.category            = verification
    - org.gradle.dependency.bundling = external
    - org.gradle.verificationtype    = main-sources
Artifacts
    - build/generated/sources/version (artifactType = directory)
    - build/javacc/javaCCMain (artifactType = directory)
    - src/main/java (artifactType = directory)
    - src/main/kotlin (artifactType = directory)
    - src/main/resources (artifactType = directory)
{noformat}

The root project could declare the subprojects as dependencies of a 
dependency-scope configuration and resolve two configurations from it: one that 
selects {{mainSourceElements}} for the sources, filtered to {{*.java}} because 
the variant also lists resource and Kotlin directories, and one with 
{{Usage=java-api}} and {{LibraryElements=classes}} for the classpath. Test 
sources have no such variant, so {{javadocAggregateIncludingTests}} needs a 
consumable configuration of its own in each subproject.

CALCITE-7971 (open) changes the classpath of the same two tasks; this issue 
does not depend on it.




--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to