Skip to content

Commit

Permalink
Merge DependencyCollector into DependencyResolver
Browse files Browse the repository at this point in the history
  • Loading branch information
gnodet committed Jun 6, 2024
1 parent 6c22461 commit 5377f97
Show file tree
Hide file tree
Showing 22 changed files with 673 additions and 859 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
* Represents a dependency node within a Maven project's dependency collector.
*
* @since 4.0.0
* @see org.apache.maven.api.services.DependencyCollectorResult#getRoot()
* @see org.apache.maven.api.services.DependencyResolverResult#getRoot()
*/
@Experimental
@Immutable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -496,25 +496,25 @@ Artifact createArtifact(
boolean isVersionSnapshot(@Nonnull String version);

/**
* Shortcut for {@code getService(DependencyCollector.class).collect(...)}
* Shortcut for {@code getService(DependencyResolver.class).collect(...)}
*
* @param artifact artifact for which to get the dependencies, including transitive ones
* @return root node of the dependency graph for the given artifact
*
* @see org.apache.maven.api.services.DependencyCollector#collect(Session, Artifact)
* @throws org.apache.maven.api.services.DependencyCollectorException if the dependency collection failed
* @see org.apache.maven.api.services.DependencyResolver#collect(Session, Artifact)
* @throws org.apache.maven.api.services.DependencyResolverException if the dependency collection failed
*/
@Nonnull
Node collectDependencies(@Nonnull Artifact artifact);

/**
* Shortcut for {@code getService(DependencyCollector.class).collect(...)}
* Shortcut for {@code getService(DependencyResolver.class).collect(...)}
*
* @param project project for which to get the dependencies, including transitive ones
* @return root node of the dependency graph for the given project
*
* @see org.apache.maven.api.services.DependencyCollector#collect(Session, Project)
* @throws org.apache.maven.api.services.DependencyCollectorException if the dependency collection failed
* @see org.apache.maven.api.services.DependencyResolver#collect(Session, Project)
* @throws org.apache.maven.api.services.DependencyResolverException if the dependency collection failed
*/
@Nonnull
Node collectDependencies(@Nonnull Project project);
Expand All @@ -524,13 +524,13 @@ Artifact createArtifact(
* only concerned about determining the coordinates of the transitive dependencies and does not actually resolve the
* artifact files.
* <p>
* Shortcut for {@code getService(DependencyCollector.class).resolve(...)}
* Shortcut for {@code getService(DependencyResolver.class).resolve(...)}
*
* @param dependency dependency for which to get transitive dependencies
* @return root node of the dependency graph for the given artifact
*
* @see org.apache.maven.api.services.DependencyCollector#collect(Session, DependencyCoordinate)
* @throws org.apache.maven.api.services.DependencyCollectorException if the dependency collection failed
* @see org.apache.maven.api.services.DependencyResolver#collect(Session, DependencyCoordinate)
* @throws org.apache.maven.api.services.DependencyResolverException if the dependency collection failed
*/
@Nonnull
Node collectDependencies(@Nonnull DependencyCoordinate dependency);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,21 +30,22 @@
* Indicates that a given field will be injected with the result of
* a dependency collection or resolution request. Whether a collection
* or resolution request is performed is controlled by the {@link #pathScope()}
* field.
* field, the injected field type and the {@link #requestType()}.
* <p>
* If a collection request is to be done, the type of the field annotated with
* this annotation can be either <ul>
* <li>a {@link org.apache.maven.api.services.DependencyCollectorResult DependencyCollectorResult},</li>
* <li>or a {@link org.apache.maven.api.Node Node} object.</li>
* </ul>
* <p>
* If a resolution request is to be done, the type of the annotated field can be either <ul>
* <li>a {@link org.apache.maven.api.services.DependencyResolverResult DependencyResolverResult},</li>
* <li>a {@code List<}{@link org.apache.maven.api.Node Node}{@code >},</li>
* <li>a {@code List<}{@link java.nio.file.Path Path}{@code >},</li>
* <li>a {@code Map<}{@link org.apache.maven.api.PathType PathType}{@code , List<}{@link java.nio.file.Path Path}{@code >>},</li>
* <li>or a {@code Map<}{@link org.apache.maven.api.Dependency Dependency}{@code , }{@link java.nio.file.Path Path}{@code >}.</li>
* </ul>
* If the {@code requestType} is not set explicitly, it will be inferred
* from the {@code pathScope} and the injected field type. If the type
* is {@link org.apache.maven.api.Node Node} and {@code pathScope == ""},
* then the dependencies will be <i>collected</i>.
* If the type is {@link org.apache.maven.api.Node Node} or
* {@code List<}{@link org.apache.maven.api.Node Node}{@code >},
* and {@code pathScope != ""}, the dependencies will be <i>flattened</i>.
* Else the dependencies will be <i>resolved</i> and {@code pathScope} must be non empty,
* and the field type can be {@link org.apache.maven.api.Node Node},
* {@code List<}{@link org.apache.maven.api.Node Node}{@code >},
* {@link org.apache.maven.api.services.DependencyResolverResult DependencyResolverResult},
* {@code List<}{@link java.nio.file.Path Path}{@code >},
* {@code Map<}{@link org.apache.maven.api.PathType PathType}{@code , List<}{@link java.nio.file.Path Path}{@code >>},
* or {@code Map<}{@link org.apache.maven.api.Dependency Dependency}{@code , }{@link java.nio.file.Path Path}{@code >}.
*
* @since 4.0.0
*/
Expand All @@ -62,4 +63,12 @@
* @return the id of the path scope
*/
String pathScope() default "";

/**
* The request type, in case the default one is not correct.
* Valid values are {@code collect}, {@code flatten}, or {@code resolve}.
*
* @return the request type
*/
String requestType() default "";
}
Original file line number Diff line number Diff line change
Expand Up @@ -94,4 +94,22 @@
*/
@Nonnull
String configurator() default "";

/**
* Indicates whether dependency collection will be
* required when executing the Mojo.
* If not set, it will be inferred from the fields
* annotated with the {@link Dependencies} annotation.
*/
@Nonnull
boolean dependencyCollection() default false;

/**
* Comma separated list of path scopes that will be
* required for dependency resolution.
* If not set, it will be inferred from the fields
* annotated with the {@link Dependencies} annotation.
*/
@Nonnull
String dependencyResolutionPathScopes() default "";
}

This file was deleted.

This file was deleted.

Loading

0 comments on commit 5377f97

Please sign in to comment.