Skip to content

Commit d6857d7

Browse files
committed
Merge DependencyCollector into DependencyResolver
1 parent 736dfec commit d6857d7

File tree

22 files changed

+673
-859
lines changed

22 files changed

+673
-859
lines changed

api/maven-api-core/src/main/java/org/apache/maven/api/Node.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
* Represents a dependency node within a Maven project's dependency collector.
3434
*
3535
* @since 4.0.0
36-
* @see org.apache.maven.api.services.DependencyCollectorResult#getRoot()
36+
* @see org.apache.maven.api.services.DependencyResolverResult#getRoot()
3737
*/
3838
@Experimental
3939
@Immutable

api/maven-api-core/src/main/java/org/apache/maven/api/Session.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -496,25 +496,25 @@ Artifact createArtifact(
496496
boolean isVersionSnapshot(@Nonnull String version);
497497

498498
/**
499-
* Shortcut for {@code getService(DependencyCollector.class).collect(...)}
499+
* Shortcut for {@code getService(DependencyResolver.class).collect(...)}
500500
*
501501
* @param artifact artifact for which to get the dependencies, including transitive ones
502502
* @return root node of the dependency graph for the given artifact
503503
*
504-
* @see org.apache.maven.api.services.DependencyCollector#collect(Session, Artifact)
505-
* @throws org.apache.maven.api.services.DependencyCollectorException if the dependency collection failed
504+
* @see org.apache.maven.api.services.DependencyResolver#collect(Session, Artifact)
505+
* @throws org.apache.maven.api.services.DependencyResolverException if the dependency collection failed
506506
*/
507507
@Nonnull
508508
Node collectDependencies(@Nonnull Artifact artifact);
509509

510510
/**
511-
* Shortcut for {@code getService(DependencyCollector.class).collect(...)}
511+
* Shortcut for {@code getService(DependencyResolver.class).collect(...)}
512512
*
513513
* @param project project for which to get the dependencies, including transitive ones
514514
* @return root node of the dependency graph for the given project
515515
*
516-
* @see org.apache.maven.api.services.DependencyCollector#collect(Session, Project)
517-
* @throws org.apache.maven.api.services.DependencyCollectorException if the dependency collection failed
516+
* @see org.apache.maven.api.services.DependencyResolver#collect(Session, Project)
517+
* @throws org.apache.maven.api.services.DependencyResolverException if the dependency collection failed
518518
*/
519519
@Nonnull
520520
Node collectDependencies(@Nonnull Project project);
@@ -524,13 +524,13 @@ Artifact createArtifact(
524524
* only concerned about determining the coordinates of the transitive dependencies and does not actually resolve the
525525
* artifact files.
526526
* <p>
527-
* Shortcut for {@code getService(DependencyCollector.class).resolve(...)}
527+
* Shortcut for {@code getService(DependencyResolver.class).resolve(...)}
528528
*
529529
* @param dependency dependency for which to get transitive dependencies
530530
* @return root node of the dependency graph for the given artifact
531531
*
532-
* @see org.apache.maven.api.services.DependencyCollector#collect(Session, DependencyCoordinate)
533-
* @throws org.apache.maven.api.services.DependencyCollectorException if the dependency collection failed
532+
* @see org.apache.maven.api.services.DependencyResolver#collect(Session, DependencyCoordinate)
533+
* @throws org.apache.maven.api.services.DependencyResolverException if the dependency collection failed
534534
*/
535535
@Nonnull
536536
Node collectDependencies(@Nonnull DependencyCoordinate dependency);

api/maven-api-core/src/main/java/org/apache/maven/api/plugin/annotations/Dependencies.java

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -30,21 +30,22 @@
3030
* Indicates that a given field will be injected with the result of
3131
* a dependency collection or resolution request. Whether a collection
3232
* or resolution request is performed is controlled by the {@link #pathScope()}
33-
* field.
33+
* field, the injected field type and the {@link #requestType()}.
3434
* <p>
35-
* If a collection request is to be done, the type of the field annotated with
36-
* this annotation can be either <ul>
37-
* <li>a {@link org.apache.maven.api.services.DependencyCollectorResult DependencyCollectorResult},</li>
38-
* <li>or a {@link org.apache.maven.api.Node Node} object.</li>
39-
* </ul>
40-
* <p>
41-
* If a resolution request is to be done, the type of the annotated field can be either <ul>
42-
* <li>a {@link org.apache.maven.api.services.DependencyResolverResult DependencyResolverResult},</li>
43-
* <li>a {@code List<}{@link org.apache.maven.api.Node Node}{@code >},</li>
44-
* <li>a {@code List<}{@link java.nio.file.Path Path}{@code >},</li>
45-
* <li>a {@code Map<}{@link org.apache.maven.api.PathType PathType}{@code , List<}{@link java.nio.file.Path Path}{@code >>},</li>
46-
* <li>or a {@code Map<}{@link org.apache.maven.api.Dependency Dependency}{@code , }{@link java.nio.file.Path Path}{@code >}.</li>
47-
* </ul>
35+
* If the {@code requestType} is not set explicitly, it will be inferred
36+
* from the {@code pathScope} and the injected field type. If the type
37+
* is {@link org.apache.maven.api.Node Node} and {@code pathScope == ""},
38+
* then the dependencies will be <i>collected</i>.
39+
* If the type is {@link org.apache.maven.api.Node Node} or
40+
* {@code List<}{@link org.apache.maven.api.Node Node}{@code >},
41+
* and {@code pathScope != ""}, the dependencies will be <i>flattened</i>.
42+
* Else the dependencies will be <i>resolved</i> and {@code pathScope} must be non empty,
43+
* and the field type can be {@link org.apache.maven.api.Node Node},
44+
* {@code List<}{@link org.apache.maven.api.Node Node}{@code >},
45+
* {@link org.apache.maven.api.services.DependencyResolverResult DependencyResolverResult},
46+
* {@code List<}{@link java.nio.file.Path Path}{@code >},
47+
* {@code Map<}{@link org.apache.maven.api.PathType PathType}{@code , List<}{@link java.nio.file.Path Path}{@code >>},
48+
* or {@code Map<}{@link org.apache.maven.api.Dependency Dependency}{@code , }{@link java.nio.file.Path Path}{@code >}.
4849
*
4950
* @since 4.0.0
5051
*/
@@ -62,4 +63,12 @@
6263
* @return the id of the path scope
6364
*/
6465
String pathScope() default "";
66+
67+
/**
68+
* The request type, in case the default one is not correct.
69+
* Valid values are {@code collect}, {@code flatten}, or {@code resolve}.
70+
*
71+
* @return the request type
72+
*/
73+
String requestType() default "";
6574
}

api/maven-api-core/src/main/java/org/apache/maven/api/plugin/annotations/Mojo.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,4 +94,22 @@
9494
*/
9595
@Nonnull
9696
String configurator() default "";
97+
98+
/**
99+
* Indicates whether dependency collection will be
100+
* required when executing the Mojo.
101+
* If not set, it will be inferred from the fields
102+
* annotated with the {@link Dependencies} annotation.
103+
*/
104+
@Nonnull
105+
boolean dependencyCollection() default false;
106+
107+
/**
108+
* Comma separated list of path scopes that will be
109+
* required for dependency resolution.
110+
* If not set, it will be inferred from the fields
111+
* annotated with the {@link Dependencies} annotation.
112+
*/
113+
@Nonnull
114+
String dependencyResolutionPathScopes() default "";
97115
}

api/maven-api-core/src/main/java/org/apache/maven/api/services/DependencyCollector.java

Lines changed: 0 additions & 107 deletions
This file was deleted.

api/maven-api-core/src/main/java/org/apache/maven/api/services/DependencyCollectorException.java

Lines changed: 0 additions & 43 deletions
This file was deleted.

0 commit comments

Comments
 (0)