diff --git a/api/maven-api-core/src/main/java/org/apache/maven/api/Artifact.java b/api/maven-api-core/src/main/java/org/apache/maven/api/Artifact.java index bdc18b958c45..77a45251ec50 100644 --- a/api/maven-api-core/src/main/java/org/apache/maven/api/Artifact.java +++ b/api/maven-api-core/src/main/java/org/apache/maven/api/Artifact.java @@ -23,76 +23,88 @@ import org.apache.maven.api.annotations.Nonnull; /** - * An artifact points to a resource such as a jar file or war application. + * Pointer to a resolved resource such as a JAR file or WAE application. + * Each {@code Artifact} instance is basically a pointer to a file in the Maven repository. + * {@code Artifact} instances are created when resolving {@link ArtifactCoordinate} instances. + * Resolving is the process that selects a {@linkplain #getVersion() particular version} + * and downloads the artifact in the local repository. + * The download may be deferred to the first time that the file is needed. * * @since 4.0.0 */ @Experimental @Immutable public interface Artifact { - /** - * Returns a unique identifier for this artifact. + * {@return a unique identifier for this artifact}. * The identifier is composed of groupId, artifactId, extension, classifier, and version. * - * @return the unique identifier + * @see ArtifactCoordinate#getId() */ @Nonnull default String key() { + String c = getClassifier(); return getGroupId() + ':' + getArtifactId() + ':' + getExtension() - + (getClassifier().isEmpty() ? "" : ":" + getClassifier()) + + (c.isEmpty() ? "" : ":" + c) + ':' + getVersion(); } /** - * The groupId of the artifact. + * {@return the group identifier of the artifact}. * - * @return the groupId + * @see ArtifactCoordinate#getGroupId() */ @Nonnull String getGroupId(); /** - * The artifactId of the artifact. + * {@return the identifier of the artifact}. * - * @return the artifactId + * @see ArtifactCoordinate#getArtifactId() */ @Nonnull String getArtifactId(); /** - * The version of the artifact. + * {@return the version of the artifact}. Contrarily to {@link ArtifactCoordinate}, + * each {@code Artifact} is associated to a specific version instead of a range of versions. + * If the {@linkplain #getBaseVersion() base version} contains a meta-version such as {@code SNAPSHOT}, + * those keywords are replaced by, for example, the actual timestamp. * - * @return the version + * @see ArtifactCoordinate#getVersionConstraint() */ @Nonnull Version getVersion(); /** - * The base version of the artifact. - * - * @return the version + * {@return the version or meta-version of the artifact}. + * A meta-version is a version suffixed with the {@code SNAPSHOT} keyword. + * Meta-versions are represented in a base version by their symbols (e.g., {@code SNAPSHOT}), + * while they are replaced by, for example, the actual timestamp in the {@linkplain #getVersion() version}. */ @Nonnull Version getBaseVersion(); /** - * The classifier of the artifact. + * Returns the classifier of the artifact. * * @return the classifier or an empty string if none, never {@code null} + * @see ArtifactCoordinate#getClassifier() */ @Nonnull String getClassifier(); /** - * The file extension of the artifact. + * Returns the file extension of the artifact. + * The dot separator is not included in the returned string. * - * @return the extension + * @return the file extension or an empty string if none, never {@code null} + * @see ArtifactCoordinate#getExtension() */ @Nonnull String getExtension(); @@ -106,9 +118,9 @@ default String key() { boolean isSnapshot(); /** - * Shortcut for {@code session.createArtifactCoordinate(artifact)} + * {@return coordinate with the same identifiers as this artifact}. + * This is a shortcut for {@code session.createArtifactCoordinate(artifact)}. * - * @return an {@link ArtifactCoordinate} * @see org.apache.maven.api.Session#createArtifactCoordinate(Artifact) */ @Nonnull diff --git a/api/maven-api-core/src/main/java/org/apache/maven/api/ArtifactCoordinate.java b/api/maven-api-core/src/main/java/org/apache/maven/api/ArtifactCoordinate.java index 7eb96410b75f..196971b900e1 100644 --- a/api/maven-api-core/src/main/java/org/apache/maven/api/ArtifactCoordinate.java +++ b/api/maven-api-core/src/main/java/org/apache/maven/api/ArtifactCoordinate.java @@ -23,33 +23,29 @@ import org.apache.maven.api.annotations.Nonnull; /** - * The {@code Coordinate} object is used to point to an {@link Artifact} - * but the version may be specified as a range instead of an exact version. + * Identification of an ensemble of {@code Artifact}s in a range of versions. + * Each {@code ArtifactCoordinate} instance is basically a pointer to a file in the Maven repository, + * except that the version may not be defined precisely. * * @since 4.0.0 */ @Experimental @Immutable public interface ArtifactCoordinate { - /** - * The groupId of the artifact. - * - * @return the groupId + * {@return the group identifier of the artifact}. */ @Nonnull String getGroupId(); /** - * The artifactId of the artifact. - * - * @return the artifactId + * {@return the identifier of the artifact}. */ @Nonnull String getArtifactId(); /** - * The classifier of the artifact. + * Returns the classifier of the artifact. * * @return the classifier or an empty string if none, never {@code null} */ @@ -57,30 +53,39 @@ public interface ArtifactCoordinate { String getClassifier(); /** - * The version of the artifact. - * - * @return the version + * {@return the specific version, range of versions or meta-version of the artifact}. + * A meta-version is a version suffixed with the {@code SNAPSHOT} keyword. */ @Nonnull - VersionConstraint getVersion(); + VersionConstraint getVersionConstraint(); /** - * The extension of the artifact. + * Returns the file extension of the artifact. + * The dot separator is not included in the returned string. * - * @return the extension or an empty string if none, never {@code null} + * @return the file extension or an empty string if none, never {@code null} */ @Nonnull String getExtension(); /** - * Unique id identifying this artifact + * {@return a unique string representation identifying this artifact}. + * The default implementation returns a colon-separated list of group + * identifier, artifact identifier, extension, classifier and version. + * + * @see Artifact#key() */ @Nonnull default String getId() { + String c = getClassifier(); return getGroupId() - + ":" + getArtifactId() - + ":" + getExtension() - + (getClassifier().isEmpty() ? "" : ":" + getClassifier()) - + ":" + getVersion(); + + ':' + + getArtifactId() + + ':' + + getExtension() + + ':' + + c + + (c.isEmpty() ? "" : ":") + + getVersionConstraint(); } } diff --git a/api/maven-api-core/src/main/java/org/apache/maven/api/Dependency.java b/api/maven-api-core/src/main/java/org/apache/maven/api/Dependency.java index 8af8b69fb916..77e9ddaca443 100644 --- a/api/maven-api-core/src/main/java/org/apache/maven/api/Dependency.java +++ b/api/maven-api-core/src/main/java/org/apache/maven/api/Dependency.java @@ -23,30 +23,49 @@ import org.apache.maven.api.annotations.Nonnull; /** + * A result of collecting, flattening and resolving {@code DependencyCoordinate}s. + * Dependency is the output of the collection process, which builds the graph of dependencies, + * followed by flattening and resolution. + * The version selection is done for each dependency during the collection phase. + * The flatten phase will keep only a single version per ({@code groupId}, {@code artifactId}) pair. + * The resolution will actually download the dependencies (or artifacts) that have been computed. * * @since 4.0.0 */ @Experimental @Immutable public interface Dependency extends Artifact { - /** - * The dependency type. + * {@return the type of the dependency}. A dependency can be a JAR file, + * a modular-JAR if it is intended to be placed on the module-path, + * a JAR containing test classes, etc. * - * @return the dependency type, never {@code null} + * @see DependencyCoordinate#getType() */ @Nonnull Type getType(); + /** + * {@return the time at which the dependency will be used}. + * If may be, for example, at compile time only, at run time or at test time. + * + * @see DependencyCoordinate#getScope() + */ @Nonnull DependencyScope getScope(); + /** + * Returns whether the dependency is optional or mandatory. + * Contrarily to {@link DependencyCoordinate}, the obligation of a {@code Dependency} is always present. + * The value is computed during the dependencies collection phase. + * + * @return {@code true} if the dependency is optional, or {@code false} if mandatory + * @see DependencyCoordinate#getOptional() + */ boolean isOptional(); /** - * Creates a {@code DependencyCoordinate} based on this {@code Dependency}. - * - * @return a {@link DependencyCoordinate} + * {@return coordinate with the same identifiers as this dependency}. */ @Nonnull @Override diff --git a/api/maven-api-core/src/main/java/org/apache/maven/api/DependencyCoordinate.java b/api/maven-api-core/src/main/java/org/apache/maven/api/DependencyCoordinate.java index c0295bfaa0e4..74d3a41932a6 100644 --- a/api/maven-api-core/src/main/java/org/apache/maven/api/DependencyCoordinate.java +++ b/api/maven-api-core/src/main/java/org/apache/maven/api/DependencyCoordinate.java @@ -26,6 +26,11 @@ import org.apache.maven.api.annotations.Nullable; /** + * {@code ArtifactCoordinate} completed with information about how the artifact will be used. + * Those information include the dependency type (main classes, test classes, etc.), + * a scope (compile-time, run-time etc.), and an obligation (whether the dependency + * is optional or mandatory). The {@linkplain #getVersionConstraint() version} + * and the {@linkplain #getOptional() obligation} may not be defined precisely. * * @since 4.0.0 */ @@ -33,19 +38,31 @@ @Immutable public interface DependencyCoordinate extends ArtifactCoordinate { /** - * The type of the artifact. - * - * @return the type + * {@return the type of the dependency}. A dependency can be a JAR file, + * a modular-JAR if it is intended to be placed on the module-path, + * a JAR containing test classes, etc. */ @Nonnull Type getType(); + /** + * {@return the time at which the dependency will be used}. + * If may be, for example, at compile time only, at run time or at test time. + */ @Nonnull DependencyScope getScope(); + /** + * Returns whether the dependency is optional, mandatory or of unspecified obligation. + * + * @return the obligation, or {@code null} if unspecified + */ @Nullable Boolean getOptional(); + /** + * {@return transitive dependencies to exclude}. + */ @Nonnull Collection getExclusions(); } diff --git a/api/maven-api-core/src/main/java/org/apache/maven/api/DependencyScope.java b/api/maven-api-core/src/main/java/org/apache/maven/api/DependencyScope.java index bf384c559575..6002baccf913 100644 --- a/api/maven-api-core/src/main/java/org/apache/maven/api/DependencyScope.java +++ b/api/maven-api-core/src/main/java/org/apache/maven/api/DependencyScope.java @@ -28,9 +28,9 @@ import org.apache.maven.api.annotations.Nonnull; /** - * Dependency scope. - * This represents at which time the dependency will be used, for example, at compile time only, - * at run time or at test time. For a given dependency, the scope is directly derived from the + * Indicates when the dependency will be used. + * For example, it may be at compile time only, at runtime, or at test time. + * For a given dependency, the scope is directly derived from the * {@link org.apache.maven.api.model.Dependency#getScope()} and will be used when using {@link PathScope} * and the {@link org.apache.maven.api.services.DependencyResolver}. * diff --git a/api/maven-api-core/src/main/java/org/apache/maven/api/Session.java b/api/maven-api-core/src/main/java/org/apache/maven/api/Session.java index 720bb85e475d..a719ede4fc64 100644 --- a/api/maven-api-core/src/main/java/org/apache/maven/api/Session.java +++ b/api/maven-api-core/src/main/java/org/apache/maven/api/Session.java @@ -613,8 +613,8 @@ Map> resolveDependencies( @Nonnull Project project, @Nonnull PathScope scope, @Nonnull Collection desiredTypes); /** - * Resolves an artifact's meta version (if any) to a concrete version. For example, resolves "1.0-SNAPSHOT" - * to "1.0-20090208.132618-23" or "RELEASE"/"LATEST" to "2.0". + * Resolves an artifact's meta version (if any) to a concrete version. + * For example, resolves "1.0-SNAPSHOT" to "1.0-20090208.132618-23". *

* Shortcut for {@code getService(VersionResolver.class).resolve(...)} * diff --git a/api/maven-api-core/src/main/java/org/apache/maven/api/Version.java b/api/maven-api-core/src/main/java/org/apache/maven/api/Version.java index ee29cc2b7e68..02f33f44c7ca 100644 --- a/api/maven-api-core/src/main/java/org/apache/maven/api/Version.java +++ b/api/maven-api-core/src/main/java/org/apache/maven/api/Version.java @@ -22,7 +22,9 @@ import org.apache.maven.api.annotations.Nonnull; /** - * A version usually parsed using the {@link org.apache.maven.api.services.VersionParser} service. + * A version or meta-version of an artifact or a dependency. + * A meta-version is a version suffixed with the {@code SNAPSHOT} keyword. + * Version is usually parsed using the {@link org.apache.maven.api.services.VersionParser} service. * * @since 4.0.0 * @see org.apache.maven.api.services.VersionParser#parseVersion(String) diff --git a/api/maven-api-core/src/main/java/org/apache/maven/api/package-info.java b/api/maven-api-core/src/main/java/org/apache/maven/api/package-info.java new file mode 100644 index 000000000000..e2bbc4984517 --- /dev/null +++ b/api/maven-api-core/src/main/java/org/apache/maven/api/package-info.java @@ -0,0 +1,55 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +/** + * Core API for Maven plugins. + * + *

Definitions of terms

+ *

Artifact resolution is the process of {@linkplain org.apache.maven.api.services.VersionResolver + * resolving the version} and then downloading the file.

+ * + *

Dependency resolution is the process of collecting dependencies, flattening the graph, + * and then downloading the file. The flattening phase removes branches of the graph so that one artifact + * per ({@code groupId}, {@code artifactId}) pair is present.

+ * + *

Dependency management

+ *

{@link org.apache.maven.api.ArtifactCoordinate} instances are used to locate artifacts in a repository. + * Each instance is basically a pointer to a file in the Maven repository, except that the version may not be + * defined precisely.

+ * + *

{@link org.apache.maven.api.Artifact} instances are the pointed artifacts in the repository. + * They are created when resolving an {@code ArtifactCoordinate}. Resolving is the process + * that selects a particular version and downloads the artifact in the local repository. + * The download may be deferred to the first time that the file is needed.

+ * + *

{@link org.apache.maven.api.DependencyCoordinate} instances are used to express a dependency. + * They are an {@code ArtifactCoordinate} completed with information about how the artifact will be used: + * type, scope and obligation (whether the dependency is optional or mandatory). + * The version and the obligation may not be defined precisely.

+ * + *

{@link org.apache.maven.api.Dependency} instances are the pointed dependencies in the repository. + * They are created when resolving a {@code DependencyCoordinate}. + * Resolving is the process that clarifies the obligation (optional or mandatory status), + * selects a particular version and downloads the artifact in the local repository.

+ * + *

{@link org.apache.maven.api.Node} is the main output of the dependency collection process. + * it's the graph of dependencies. The above-cited {@code Dependency} instances are the outputs of the + * collection process, part of the graph computed from one or more {@code DependencyCoordinate}s.

+ */ +package org.apache.maven.api; diff --git a/api/maven-api-core/src/main/java/org/apache/maven/api/services/ArtifactCoordinateFactoryRequest.java b/api/maven-api-core/src/main/java/org/apache/maven/api/services/ArtifactCoordinateFactoryRequest.java index 3b8a6a459df0..c2fd1424cc05 100644 --- a/api/maven-api-core/src/main/java/org/apache/maven/api/services/ArtifactCoordinateFactoryRequest.java +++ b/api/maven-api-core/src/main/java/org/apache/maven/api/services/ArtifactCoordinateFactoryRequest.java @@ -100,7 +100,7 @@ static ArtifactCoordinateFactoryRequest build(@Nonnull Session session, @Nonnull .groupId(nonNull(coordinate, "coordinate").getGroupId()) .artifactId(coordinate.getArtifactId()) .classifier(coordinate.getClassifier()) - .version(coordinate.getVersion().asString()) + .version(coordinate.getVersionConstraint().asString()) .extension(coordinate.getExtension()) .build(); } diff --git a/api/maven-api-core/src/main/java/org/apache/maven/api/services/DependencyCoordinateFactoryRequest.java b/api/maven-api-core/src/main/java/org/apache/maven/api/services/DependencyCoordinateFactoryRequest.java index 34483be0de67..5a9249b09f52 100644 --- a/api/maven-api-core/src/main/java/org/apache/maven/api/services/DependencyCoordinateFactoryRequest.java +++ b/api/maven-api-core/src/main/java/org/apache/maven/api/services/DependencyCoordinateFactoryRequest.java @@ -74,7 +74,7 @@ static DependencyCoordinateFactoryRequest build(@Nonnull Session session, @Nonnu .session(nonNull(session, "session cannot be null")) .groupId(nonNull(coordinate, "coordinate cannot be null").getGroupId()) .artifactId(coordinate.getArtifactId()) - .version(coordinate.getVersion().asString()) + .version(coordinate.getVersionConstraint().asString()) .classifier(coordinate.getClassifier()) .extension(coordinate.getExtension()) .build(); diff --git a/api/maven-api-core/src/main/java/org/apache/maven/api/services/VersionResolver.java b/api/maven-api-core/src/main/java/org/apache/maven/api/services/VersionResolver.java index 0a27f97d7c49..a470452f7e78 100644 --- a/api/maven-api-core/src/main/java/org/apache/maven/api/services/VersionResolver.java +++ b/api/maven-api-core/src/main/java/org/apache/maven/api/services/VersionResolver.java @@ -35,8 +35,8 @@ public interface VersionResolver extends Service { /** - * Resolves an artifact's meta version (if any) to a concrete version. For example, resolves "1.0-SNAPSHOT" - * to "1.0-20090208.132618-23" or "RELEASE"/"LATEST" to "2.0". + * Resolves an artifact's meta version (if any) to a concrete version. + * For example, resolves "1.0-SNAPSHOT" to "1.0-20090208.132618-23". * * @param session The repository session, must not be {@code null}. * @param artifactCoordinate The artifact coordinate for which the version needs to be resolved, must not be {@code null} @@ -50,8 +50,8 @@ default VersionResolverResult resolve(@Nonnull Session session, @Nonnull Artifac } /** - * Resolves an artifact's meta version (if any) to a concrete version. For example, resolves "1.0-SNAPSHOT" - * to "1.0-20090208.132618-23" or "RELEASE"/"LATEST" to "2.0". + * Resolves an artifact's meta version (if any) to a concrete version. + * For example, resolves "1.0-SNAPSHOT" to "1.0-20090208.132618-23". * * @param request The version request, must not be {@code null}. * @return The version result, never {@code null}. diff --git a/maven-api-impl/src/main/java/org/apache/maven/internal/impl/AbstractSession.java b/maven-api-impl/src/main/java/org/apache/maven/internal/impl/AbstractSession.java index 1d37687b9226..e6e76ae70abe 100644 --- a/maven-api-impl/src/main/java/org/apache/maven/internal/impl/AbstractSession.java +++ b/maven-api-impl/src/main/java/org/apache/maven/internal/impl/AbstractSession.java @@ -306,7 +306,7 @@ public org.eclipse.aether.graph.Dependency toDependency(DependencyCoordinate dep dependency.getArtifactId(), dependency.getClassifier(), type.getExtension(), - dependency.getVersion().toString(), + dependency.getVersionConstraint().toString(), Map.of("type", type.id()), (ArtifactType) null), dependency.getScope().id(), @@ -357,7 +357,7 @@ public org.eclipse.aether.artifact.Artifact toArtifact(ArtifactCoordinate coord) coord.getArtifactId(), coord.getClassifier(), coord.getExtension(), - coord.getVersion().toString(), + coord.getVersionConstraint().toString(), null, (File) null); } diff --git a/maven-api-impl/src/main/java/org/apache/maven/internal/impl/DefaultArtifactCoordinate.java b/maven-api-impl/src/main/java/org/apache/maven/internal/impl/DefaultArtifactCoordinate.java index 04b4c73e286d..98dd3c04ca6f 100644 --- a/maven-api-impl/src/main/java/org/apache/maven/internal/impl/DefaultArtifactCoordinate.java +++ b/maven-api-impl/src/main/java/org/apache/maven/internal/impl/DefaultArtifactCoordinate.java @@ -57,7 +57,7 @@ public String getArtifactId() { @Nonnull @Override - public VersionConstraint getVersion() { + public VersionConstraint getVersionConstraint() { return session.parseVersionConstraint(coordinate.getVersion()); } @@ -83,13 +83,13 @@ public boolean equals(Object o) { DefaultArtifactCoordinate that = (DefaultArtifactCoordinate) o; return Objects.equals(this.getGroupId(), that.getGroupId()) && Objects.equals(this.getArtifactId(), that.getArtifactId()) - && Objects.equals(this.getVersion(), that.getVersion()) + && Objects.equals(this.getVersionConstraint(), that.getVersionConstraint()) && Objects.equals(this.getClassifier(), that.getClassifier()); } @Override public int hashCode() { - return Objects.hash(getGroupId(), getArtifactId(), getVersion(), getClassifier()); + return Objects.hash(getGroupId(), getArtifactId(), getVersionConstraint(), getClassifier()); } @Override diff --git a/maven-api-impl/src/main/java/org/apache/maven/internal/impl/DefaultDependencyCoordinate.java b/maven-api-impl/src/main/java/org/apache/maven/internal/impl/DefaultDependencyCoordinate.java index dd88da7a3340..fed15cc41c26 100644 --- a/maven-api-impl/src/main/java/org/apache/maven/internal/impl/DefaultDependencyCoordinate.java +++ b/maven-api-impl/src/main/java/org/apache/maven/internal/impl/DefaultDependencyCoordinate.java @@ -33,7 +33,7 @@ public DefaultDependencyCoordinate( } @Override - public VersionConstraint getVersion() { + public VersionConstraint getVersionConstraint() { return session.parseVersionConstraint(dependency.getArtifact().getVersion()); } diff --git a/maven-api-impl/src/main/java/org/apache/maven/internal/impl/resolver/DefaultModelResolver.java b/maven-api-impl/src/main/java/org/apache/maven/internal/impl/resolver/DefaultModelResolver.java index a3e251294e20..9473c8c36412 100644 --- a/maven-api-impl/src/main/java/org/apache/maven/internal/impl/resolver/DefaultModelResolver.java +++ b/maven-api-impl/src/main/java/org/apache/maven/internal/impl/resolver/DefaultModelResolver.java @@ -50,8 +50,8 @@ public ModelSource resolveModel( throws ModelResolverException { try { ArtifactCoordinate coord = session.createArtifactCoordinate(groupId, artifactId, version, "pom"); - if (coord.getVersion().getVersionRange() != null - && coord.getVersion().getVersionRange().getUpperBoundary() == null) { + if (coord.getVersionConstraint().getVersionRange() != null + && coord.getVersionConstraint().getVersionRange().getUpperBoundary() == null) { // Message below is checked for in the MNG-2199 core IT. throw new ModelResolverException( String.format("The requested version range '%s' does not specify an upper bound", version), diff --git a/maven-artifact/src/main/java/org/apache/maven/artifact/Artifact.java b/maven-artifact/src/main/java/org/apache/maven/artifact/Artifact.java index df98a1aa2259..bbbdc14d8278 100644 --- a/maven-artifact/src/main/java/org/apache/maven/artifact/Artifact.java +++ b/maven-artifact/src/main/java/org/apache/maven/artifact/Artifact.java @@ -37,8 +37,10 @@ */ public interface Artifact extends Comparable { + @Deprecated(since = "4.0.0") String RELEASE_VERSION = "RELEASE"; + @Deprecated(since = "4.0.0") String LATEST_VERSION = "LATEST"; String SNAPSHOT_VERSION = "SNAPSHOT"; diff --git a/maven-compat/src/main/java/org/apache/maven/repository/legacy/DefaultUpdateCheckManager.java b/maven-compat/src/main/java/org/apache/maven/repository/legacy/DefaultUpdateCheckManager.java index 4c4156a07172..ea2ca33a8cbd 100644 --- a/maven-compat/src/main/java/org/apache/maven/repository/legacy/DefaultUpdateCheckManager.java +++ b/maven-compat/src/main/java/org/apache/maven/repository/legacy/DefaultUpdateCheckManager.java @@ -60,6 +60,7 @@ public DefaultUpdateCheckManager(Logger logger) { private static final String TOUCHFILE_NAME = "resolver-status.properties"; + @Override public boolean isUpdateRequired(Artifact artifact, ArtifactRepository repository) { File file = artifact.getFile(); @@ -98,6 +99,7 @@ public boolean isUpdateRequired(Artifact artifact, ArtifactRepository repository return (lastCheckDate == null) || policy.checkOutOfDate(lastCheckDate); } + @Override public boolean isUpdateRequired(RepositoryMetadata metadata, ArtifactRepository repository, File file) { // Here, we need to determine which policy to use. Release updateInterval will be used when // the metadata refers to a release artifact or meta-version, and snapshot updateInterval will be used when @@ -141,11 +143,13 @@ private Date readLastUpdated(RepositoryMetadata metadata, ArtifactRepository rep return readLastUpdated(touchfile, key); } + @Override public String getError(Artifact artifact, ArtifactRepository repository) { File touchFile = getTouchfile(artifact); return getError(touchFile, getRepositoryKey(repository)); } + @Override public void touch(Artifact artifact, ArtifactRepository repository, String error) { File file = artifact.getFile(); @@ -158,6 +162,7 @@ public void touch(Artifact artifact, ArtifactRepository repository, String error } } + @Override public void touch(RepositoryMetadata metadata, ArtifactRepository repository, File file) { File touchfile = getTouchfile(metadata, file); diff --git a/maven-compat/src/main/java/org/apache/maven/repository/legacy/resolver/transform/ReleaseArtifactTransformation.java b/maven-compat/src/main/java/org/apache/maven/repository/legacy/resolver/transform/ReleaseArtifactTransformation.java index abc20e2cd2c9..8eb749f8125f 100644 --- a/maven-compat/src/main/java/org/apache/maven/repository/legacy/resolver/transform/ReleaseArtifactTransformation.java +++ b/maven-compat/src/main/java/org/apache/maven/repository/legacy/resolver/transform/ReleaseArtifactTransformation.java @@ -40,6 +40,7 @@ @Deprecated public class ReleaseArtifactTransformation extends AbstractVersionTransformation { + @Override public void transformForResolve(Artifact artifact, RepositoryRequest request) throws ArtifactResolutionException, ArtifactNotFoundException { if (Artifact.RELEASE_VERSION.equals(artifact.getVersion())) { @@ -58,12 +59,14 @@ public void transformForResolve(Artifact artifact, RepositoryRequest request) } } + @Override public void transformForInstall(Artifact artifact, ArtifactRepository localRepository) { ArtifactMetadata metadata = createMetadata(artifact); artifact.addMetadata(metadata); } + @Override public void transformForDeployment( Artifact artifact, ArtifactRepository remoteRepository, ArtifactRepository localRepository) { ArtifactMetadata metadata = createMetadata(artifact); @@ -84,6 +87,7 @@ private ArtifactMetadata createMetadata(Artifact artifact) { return new ArtifactRepositoryMetadata(artifact, versioning); } + @Override protected String constructVersion(Versioning versioning, String baseVersion) { return versioning.getRelease(); } diff --git a/maven-compat/src/test/java/org/apache/maven/repository/TestRepositorySystem.java b/maven-compat/src/test/java/org/apache/maven/repository/TestRepositorySystem.java index 3921e20704e7..5b436de54379 100644 --- a/maven-compat/src/test/java/org/apache/maven/repository/TestRepositorySystem.java +++ b/maven-compat/src/test/java/org/apache/maven/repository/TestRepositorySystem.java @@ -78,6 +78,7 @@ public TestRepositorySystem(ModelReader modelReader, ArtifactFactory artifactFac this.artifactFactory = artifactFactory; } + @Override public ArtifactRepository buildArtifactRepository(Repository repository) throws InvalidRepositoryException { return new MavenArtifactRepository( repository.getId(), @@ -87,14 +88,17 @@ public ArtifactRepository buildArtifactRepository(Repository repository) throws new ArtifactRepositoryPolicy()); } + @Override public Artifact createArtifact(String groupId, String artifactId, String version, String packaging) { return createArtifact(groupId, artifactId, version, null, packaging); } + @Override public Artifact createArtifact(String groupId, String artifactId, String version, String scope, String type) { return new DefaultArtifact(groupId, artifactId, version, scope, type, null, new TestArtifactHandler(type)); } + @Override public ArtifactRepository createArtifactRepository( String id, String url, @@ -104,16 +108,19 @@ public ArtifactRepository createArtifactRepository( return new MavenArtifactRepository(id, url, repositoryLayout, snapshots, releases); } + @Override public Artifact createArtifactWithClassifier( String groupId, String artifactId, String version, String type, String classifier) { return new DefaultArtifact(groupId, artifactId, version, null, type, classifier, new TestArtifactHandler(type)); } + @Override public ArtifactRepository createDefaultLocalRepository() throws InvalidRepositoryException { return createLocalRepository( new File(System.getProperty("basedir", "."), "target/local-repo").getAbsoluteFile()); } + @Override public ArtifactRepository createDefaultRemoteRepository() throws InvalidRepositoryException { return new MavenArtifactRepository( DEFAULT_REMOTE_REPO_ID, @@ -127,6 +134,7 @@ public ArtifactRepository createDefaultRemoteRepository() throws InvalidReposito new ArtifactRepositoryPolicy()); } + @Override public Artifact createDependencyArtifact(Dependency dependency) { Artifact artifact = new DefaultArtifact( dependency.getGroupId(), @@ -145,6 +153,7 @@ public Artifact createDependencyArtifact(Dependency dependency) { return artifact; } + @Override public ArtifactRepository createLocalRepository(File localRepository) throws InvalidRepositoryException { return new MavenArtifactRepository( MavenRepositorySystem.DEFAULT_LOCAL_REPO_ID, @@ -154,6 +163,7 @@ public ArtifactRepository createLocalRepository(File localRepository) throws Inv new ArtifactRepositoryPolicy()); } + @Override public Artifact createPluginArtifact(Plugin plugin) { VersionRange versionRange; try { @@ -169,24 +179,31 @@ public Artifact createPluginArtifact(Plugin plugin) { return artifactFactory.createPluginArtifact(plugin.getGroupId(), plugin.getArtifactId(), versionRange); } + @Override public Artifact createProjectArtifact(String groupId, String artifactId, String version) { return createArtifact(groupId, artifactId, version, "pom"); } + @Override public List getEffectiveRepositories(List repositories) { return repositories; } + @Override public Mirror getMirror(ArtifactRepository repository, List mirrors) { return null; } + @Override public void injectAuthentication(List repositories, List servers) {} + @Override public void injectMirror(List repositories, List mirrors) {} + @Override public void injectProxy(List repositories, List proxies) {} + @Override public void publish( ArtifactRepository repository, File source, String remotePath, ArtifactTransferListener transferListener) throws ArtifactTransferFailedException { @@ -194,6 +211,7 @@ public void publish( } + @Override public ArtifactResolutionResult resolve(ArtifactResolutionRequest request) { ArtifactResolutionResult result = new ArtifactResolutionResult(); @@ -283,6 +301,7 @@ private void resolve(Artifact artifact, ArtifactResolutionRequest request) throw artifact.setResolved(true); } + @Override public void retrieve( ArtifactRepository repository, File destination, @@ -293,9 +312,12 @@ public void retrieve( } + @Override public void injectMirror(RepositorySystemSession session, List repositories) {} + @Override public void injectProxy(RepositorySystemSession session, List repositories) {} + @Override public void injectAuthentication(RepositorySystemSession session, List repositories) {} } diff --git a/maven-core/src/main/java/org/apache/maven/internal/impl/DefaultProject.java b/maven-core/src/main/java/org/apache/maven/internal/impl/DefaultProject.java index 012514926e2e..8508c5a29774 100644 --- a/maven-core/src/main/java/org/apache/maven/internal/impl/DefaultProject.java +++ b/maven-core/src/main/java/org/apache/maven/internal/impl/DefaultProject.java @@ -188,7 +188,7 @@ public String getClassifier() { } @Override - public VersionConstraint getVersion() { + public VersionConstraint getVersionConstraint() { return session.parseVersionConstraint(dependency.getVersion()); }