Skip to content

Conversation

@cstamas
Copy link
Member

@cstamas cstamas commented Nov 3, 2025

Instead to "smear" this feature across Maven and Resolver classes, for start let's keep it "confined" with single class: the TypeDeriver.

Later we can see where to go further with it.

This PR also includes bugfix, where Maven DefaultType implements ArtifactType, while in reality it does not (violates contract by returning null when no classifier present).

Supersedes #11373

Instead to "smear" this feature across Maven and Resolver classes,
for start let's keep it "confined" with single class: the
TypeDeriver.

Later we can see where to go further with it.

Supersedes apache#11373
@cstamas cstamas requested a review from gnodet November 3, 2025 14:59
@cstamas cstamas self-assigned this Nov 3, 2025
@cstamas cstamas mentioned this pull request Nov 3, 2025
@cstamas cstamas requested a review from desruisseaux November 3, 2025 15:41
*/
@Deprecated(since = "4.0.0")
public class DefaultType implements Type, ArtifactType {
public class DefaultType implements Type {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the benefit of this decoupling? It does not seem necessary.

@desruisseaux
Copy link
Contributor

Thanks. Just tried with the processor-type integration test in the compiler plugin. I still have the dependency on the classpath, but I can try to run in the debugger during the weekend.

@cstamas
Copy link
Member Author

cstamas commented Nov 4, 2025

@desruisseaux that is weird, as I have locally (master of m-compiler-p):

[INFO] --- invoker:3.9.1:integration-test (integration-test) @ maven-compiler-plugin ---
[INFO] Running 4 setup jobs:
[INFO] Building: setup_annotation-verify-plugin/pom.xml
[INFO]           setup_annotation-verify-plugin/pom.xml ........... SUCCESS (5.192 s)
[INFO] Building: setup_jar_automodule/pom.xml
[INFO]           setup_jar_automodule/pom.xml ..................... SUCCESS (1.464 s)
[INFO] Building: setup_jar_module/pom.xml
[INFO]           setup_jar_module/pom.xml ......................... SUCCESS (1.657 s)
[INFO] Building: setup_x/pom.xml
[INFO]           setup_x/pom.xml .................................. SUCCESS (1.813 s)
[INFO] Setup done.
[INFO] Building: processor-type/pom.xml
[INFO]           processor-type/pom.xml ........................... SUCCESS (1.481 s)

Invoked as:

[cstamas@angeleyes maven-compiler-plugin (master)]$ mvn -v
Apache Maven 4.1.0-SNAPSHOT (4ff85c235b1ecee29c6a71b16d9cf40dfb841c2d)
Maven home: /home/cstamas/.sdkman/candidates/maven/latest-master
Java version: 21.0.8, vendor: Eclipse Adoptium, runtime: /home/cstamas/.sdkman/candidates/java/21.0.8-tem
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "6.17.6-300.fc43.x86_64", arch: "amd64", family: "unix"
[cstamas@angeleyes maven-compiler-plugin (master)]$ mvn clean install -P run-its -Dinvoker.test=setup_*,processor-type

@cstamas
Copy link
Member Author

cstamas commented Nov 4, 2025

Aha, I think I see it now:

[cstamas@angeleyes processor-type (master)]$ cat annotation-user/target/javac.args 
--release 17
--module-version 1.0-SNAPSHOT
--processor-path "../annotation-processor/target/classes"
--class-path "../annotation-processor-dep/target/classes"
--source-path "src/main/java"
-d "target/classes"
"src/main/java/user/SimpleAnnotation.java"
"src/main/java/user/SimpleObject.java"
[cstamas@angeleyes processor-type (master)]$ 

@desruisseaux
Copy link
Contributor

Yes, the integration test passes because the line that cause a failure is commented out. If you open the following file:

target/it/processor-type/annotation-processor/src/main/java/processor/SimpleAnnotationProcessor.java

then uncomment the second line below:

        // TODO: pending https://github.com/apache/maven/pull/11373
        // dependency.AnnotationProcessorDependency.foo();

then, we get the test failure. You can also check that if the value on --class-path is moved to --processor-path, it works.

@cstamas
Copy link
Member Author

cstamas commented Nov 4, 2025

Blocked by apache/maven-resolver#1648

@cstamas
Copy link
Member Author

cstamas commented Nov 5, 2025

@desruisseaux if this build passes OK, you will have a Maven build (available as GH CI artifact here: https://github.com/apache/maven/actions/runs/19105278503?pr=11380) w/ resolver fix incorporated (will use 2.0.14-SNAPSHOT resolver)

@cstamas
Copy link
Member Author

cstamas commented Nov 5, 2025

Using that Maven along with latest Toolbox you can inspect the tree output from Maven and how types are derived.

@desruisseaux
Copy link
Contributor

Thanks! Will try this weekend. No worry for the github actions, I always build Maven core locally anyway.

@cstamas
Copy link
Member Author

cstamas commented Nov 5, 2025

Funnily, GH Actions revealed several "leaks" (UT and IT bubbled up to checkout root), so I am just using this as a good test to fix all those leaks 😄

Copy link
Contributor

@desruisseaux desruisseaux left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I cannot really evaluate this part of Maven code, but I tested with the Maven Compiler Plugin and confirm that it worked. I was able to re-enable a processor dependency test which was commented-out.

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.

3 participants