matrei opened a new issue, #40:
URL: https://github.com/apache/grails-gradle-publish/issues/40

   ## Summary
   
   The plugin still accesses the root project from the project it is applied 
to, which Gradle reports as a violation when [Isolated 
Projects](https://docs.gradle.org/current/userguide/isolated_projects.html) is 
enabled. Isolated Projects is incubating and opt-in, so this doesn't affect 
current builds, but it blocks users who want to enable it.
   
   #39 removed the violations that were straightforward to fix: reading plugin 
properties from parent projects, and logging through 
`project.rootProject.logger`. Two remain, plus one in the Nexus publish plugin.
   
   ## Reproduce
   
   In a multi-project build that applies the plugin in a subproject, and 
doesn't use `allprojects`/`subprojects` itself, run with Gradle 9.8:
   
   ```
   ./gradlew :subproject:help -Dorg.gradle.isolated-projects=true
   ```
   
   A snapshot build (`GRAILS_PUBLISH_RELEASE=false`) reports violation 1, and a 
release build using `NEXUS_PUBLISH` (`GRAILS_PUBLISH_RELEASE=true`) reports 
violation 2.
   
   ## 1. Test repository hook (snapshot and release builds)
   
   `GrailsPublishGradlePlugin.groovy:486-490`: if the root project has a task 
named `publishAllPublicationsToTestCaseMavenRepoRepository`, the plugin makes 
it depend on the subproject's task of the same name.
   
   ```
   - Plugin 'org.apache.grails.gradle.grails-publish': Project ':subproject' 
cannot access 'Project.tasks' functionality on another project ':'
   ```
   
   Apart from Isolated Projects, this only works if the root task is registered 
before the subproject applies the plugin.
   
   **Users:** grails-core relies on it. Its `gradle/publish-root-config.gradle` 
registers an empty root task with the comment "subprojects will register 
dependencies via the publish plugin", and `grails-forge` runs that task in the 
`grails-core` and `grails-gradle` included builds. `grails-gradle` and this 
repository already collect the subproject tasks in their root build instead.
   
   **Possible fix:** remove the hook, and have root builds collect the tasks 
themselves, as this repository's `gradle/publish-root-config.gradle` does. That 
needs a coordinated change in grails-core first. Another option is for the 
plugin to register the aggregate task, but only when it is applied to the root 
project itself.
   
   ## 2. Nexus publish plugin setup (release builds using `NEXUS_PUBLISH`)
   
   `GrailsPublishGradlePlugin.groovy:313-345`: the Nexus publish plugin must be 
applied to the root project, so the plugin applies it there from the 
subproject, orders the root project's `InitializeNexusStagingRepository` tasks 
after the subproject's sign tasks, and configures the root project's 
`NexusPublishExtension`.
   
   ```
   - Plugin 'org.apache.grails.gradle.grails-publish': Project ':subproject' 
cannot access 'Project.pluginManager' functionality on another project ':'
   ```
   
   **Possible fixes:**
   - Require the plugin, or just the Nexus setup, to be applied to the root 
project as well. This is a breaking change for multi-project builds that apply 
it only in subprojects.
   - Configure Nexus publishing from a settings plugin.
   
   Either way, this only helps once the Nexus plugin itself supports Isolated 
Projects (see 3).
   
   ## 3. Upstream: the Nexus publish plugin
   
   `io.github.gradle-nexus.publish-plugin` 2.0.0 calls `Project.allprojects` 
and `getRootProject` from its root plugin, which Isolated Projects doesn't 
allow. This is tracked upstream in gradle-nexus/publish-plugin#81 and 
gradle-nexus/publish-plugin#343, both open. Until that's fixed, releases using 
`NEXUS_PUBLISH` can't work with Isolated Projects, whatever this plugin does.
   
   ## Suggested scope
   
   1. Fix the test repository hook (1) together with grails-core. It is 
independent of the Nexus plugin and makes snapshot builds and `MAVEN_PUBLISH` 
releases compatible.
   2. Revisit the Nexus setup (2) once the upstream issue (3) is resolved.
   3. Add a functional test that runs a multi-project snapshot build with 
`-Dorg.gradle.isolated-projects=true`, so new violations are caught.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to