Le lun. 22 juil. 2024 à 18:41, Martin Desruisseaux
<martin.desruisse...@geomatys.com> a écrit :
>
> Hello all
>
> The work on a new maven-compiler-plugin [1] for Maven 4 has reached the
> following state:
>
>   * All existing JUnit tests pass
>   * Integration tests do not yet pass (I'm working on that)
>   * Plexus compiler dependency completely removed (replaced by javax.tools)

Awesome work !  Does ECJ implement javax.tools API too ?

>
> My current issue is that dependencies of type "test-jar" are lost. I'm
> not sure if I'm doing something wrong or if this is an issue with Maven
> core. The code looks like that:
>
>     DependencyResolver resolver = 
> session.getService(DependencyResolver.class);
>     DependencyResolverResult dependencies
>              .session(session)
>              .project(project)
>              .pathScope(PathScope.TEST_COMPILE)
>              .build());
>
> In a step-by-step debugging, I see that
> org.apache.maven.internal.impl.AbstractSession.toDependency(…) is
> invoked for transforming a dependency from Maven model to Aether model
> as below (line 274):
>
>     new org.eclipse.aether.artifact.DefaultArtifact(
>              dependency.getGroupId(),
>              dependency.getArtifactId(),
>              dependency.getClassifier(),
>              dependency.getType().getExtension(),
>              dependency.getVersion().toString(),
>              null)
>
> I did not saw the "test-jar" anywhere in the copied object, or did I
> missed something? Or is this code supposed to generate automatically a
> "tests" classifier when the type is "type-jar"?
>
> Generally speaking, having coexisting models such as Maven and Eclipse
> Aether with conversions between those models makes more difficult to
> follow what is happening inside Maven core, and is a risk of data lost.
> Don't we have an overlap between the following interfaces, and if yes,
> should we try to reduce the overlap?
>
>   * org.eclipse.aether.graph.Dependency
>   * org.apache.maven.api.Dependency
>   * org.apache.maven.api.DependencyCoordinate

The org.eclipse.aether.graph.Dependency objects should not be used and
will not even be exposed once/if [1] is merged. One of the goals of
the Maven 4 API was to hide the resolver completely, so I'm not sure
how to not wrap those.  But if you have some suggestions...

For this particular point, there are really only two implementations
of org.apache.maven.api.DependencyCoordinate which are
org.apache.maven.internal.impl.DefaultDependencyCoordinate and the
anonymous class defined in
org.apache.maven.internal.impl.DefaultProject, which wraps a
org.apache.maven.api.model.Dependency.  Both should have the getType()
return a correct value, so passing null to the
org.eclipse.aether.artifact.DefaultArtifact constructor [2] definitely
looks like a bug.

[1] https://github.com/apache/maven/pull/1336
[2] 
https://github.com/apache/maven/blob/d35864e348e84e2246fafe242fa732b58980a4cf/maven-api-impl/src/main/java/org/apache/maven/internal/impl/AbstractSession.java#L305

>
> Thanks,
>
>      Martin
>
> [1]https://github.com/Geomatys/maven-compiler-plugin



-- 
------------------------
Guillaume Nodet

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@maven.apache.org
For additional commands, e-mail: dev-h...@maven.apache.org

Reply via email to