lhotari opened a new pull request, #25441:
URL: https://github.com/apache/pulsar/pull/25441

   ### Motivation
   
   When running Gradle with `--configure-on-demand` (or 
`org.gradle.configureondemand=true`), the build fails with:
   
   ```
   Could not determine the dependencies of task ':pulsar-broker:test'.
   > A problem occurred configuring project 
':pulsar-io:pulsar-io-batch-data-generator'.
      > org.gradle.api.internal.initialization.DefaultClassLoaderScope@... must 
be locked before it can be used to compute a classpath!
   ```
   
   The root cause is that `pulsar-broker`'s test tasks declare cross-project 
task dependencies via `dependsOn` strings (e.g., 
`":pulsar-io:pulsar-io-batch-data-generator:nar"`). With configure-on-demand, 
when Gradle resolves these task references, it needs to configure the target 
child project. However, the Kotlin DSL compiler requires the parent project's 
(`pulsar-io`, `pulsar-functions`) `ClassLoaderScope` to be locked (i.e., fully 
configured) first. Since configure-on-demand skips configuring projects that 
aren't explicitly needed, the parent scopes were never locked, causing the 
failure.
   
   ### Modifications
   
   - Added `evaluationDependsOn(":pulsar-io")` and 
`evaluationDependsOn(":pulsar-functions")` in `pulsar-broker/build.gradle.kts` 
to ensure these parent projects are configured before their children are 
referenced via cross-project task dependencies.
   - Enabled configure-on-demand by default in `gradle.properties` 
(`org.gradle.configureondemand=true`).
   - Removed the `buildscript` block from root `build.gradle.kts` as it is 
incompatible with the build-logic composite build pattern and 
configure-on-demand.
   
   ### Verifying this change
   
   This change is already covered by existing tests. The fix can be verified by 
running:
   ```
   ./gradlew --configure-on-demand :pulsar-broker:test --dry-run
   ```
   which previously failed with the ClassLoaderScope error and now succeeds.
   
   ### Does this pull request potentially affect one of the following parts:
   
   - [ ] Dependencies (add or upgrade a dependency)
   - [ ] The public API
   - [ ] The schema
   - [ ] The default values of configurations
   - [ ] The threading model
   - [ ] The binary protocol
   - [ ] The REST endpoints
   - [ ] The admin CLI options
   - [ ] The metrics
   - [ ] Anything that affects deployment
   
   ### Documentation
   
   - [x] `doc-not-needed`


-- 
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