Skip to content

Conversation

gnodet
Copy link
Contributor

@gnodet gnodet commented Aug 6, 2025

Summary

This PR adds a comprehensive integration test for the new dependency scopes introduced in Maven 4:

  • compile-only: Available during compilation, not at runtime
  • test-only: Available during test compilation, not at test runtime
  • test-runtime: Available during test runtime, not at test compilation

Test Coverage

The integration test (MavenITmng8750NewScopesTest) verifies:

Classpath Inclusion/Exclusion:

  • compile-only dependencies appear in compile classpath but NOT runtime classpath
  • test-only dependencies appear in test compile classpath but NOT test runtime classpath
  • test-runtime dependencies appear in test runtime classpath but NOT test compile classpath

Consumer POM Compatibility:

  • New scopes are excluded from consumer POMs for Maven 3 compatibility
  • Only Maven 3 compatible scopes appear in consumer POMs

Runtime Behavior:

  • Dependencies with new scopes cause appropriate NoClassDefFoundError when accessed incorrectly
  • All new scopes work correctly together in the same project

Test Structure

Main Test Class: MavenITmng8750NewScopesTest.java

  • 5 test methods covering individual scopes and comprehensive scenarios
  • Requires Maven 4.0.0+ (super("[4.0.0,)"))

Test Modules:

  1. compile-only-test - Tests compile-only scope behavior
  2. test-only-test - Tests test-only scope behavior
  3. test-runtime-test - Tests test-runtime scope behavior
  4. comprehensive-test - Tests all scopes working together
  5. validation-failure-test
  6. validation-success-test

Test Repository: Local repository with test dependency JARs and POMs

Files Added

  • Integration test class and test suite ordering update
  • 5 test module POMs with appropriate scope configurations
  • Java source files demonstrating scope behavior
  • Local test repository with dependency artifacts
  • Comprehensive README documentation

Verification

The test can be run with:

mvn test -Dits.test=MavenITmng8750NewScopesTest

This ensures that the new Maven 4 scopes work as designed while maintaining backward compatibility through proper consumer POM generation.


Pull Request opened by Augment Code with guidance from the PR author

@cstamas
Copy link
Member

cstamas commented Aug 6, 2025

Didn't we made new scopes available in model 4.1.0+ ONLY? As otherwise those can get deployed, no?

@gnodet
Copy link
Contributor Author

gnodet commented Aug 6, 2025

Didn't we made new scopes available in model 4.1.0+ ONLY? As otherwise those can get deployed, no?

New features are. In this case, those are new values for existing stuff, and it seems they are not. This could be added to model validation.

@cstamas
Copy link
Member

cstamas commented Aug 6, 2025

That's another thing, i remember adding them to model validation...

@cstamas
Copy link
Member

cstamas commented Aug 6, 2025

#2380

@gnodet gnodet force-pushed the mng-8750-new-scopes-integration-test branch 6 times, most recently from 3502cf0 to d3718df Compare September 25, 2025 21:14
This integration test verifies the correct behavior of the new dependency scopes introduced in Maven 4:

- compile-only: Available during compilation, not at runtime
- test-only: Available during test compilation, not at test runtime
- test-runtime: Available during test runtime, not at test compilation

The test also verifies that consumer POMs exclude these new scopes for Maven 3 compatibility.
@gnodet gnodet force-pushed the mng-8750-new-scopes-integration-test branch from d3718df to 71851dd Compare September 25, 2025 21:27
@gnodet gnodet requested a review from cstamas September 25, 2025 21:52
@gnodet gnodet added this to the 4.1.0 milestone Sep 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants