Skip to content

Commit

Permalink
Use Maven Core artifacts in provided scope
Browse files Browse the repository at this point in the history
  • Loading branch information
slawekjaranowski committed Aug 7, 2022
1 parent f3b9697 commit 7e16ce3
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 28 deletions.
45 changes: 28 additions & 17 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -144,35 +144,50 @@
</properties>

<dependencies>
<!-- plugin tools -->
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-model</artifactId>
<version>${mavenVersion}</version>
<groupId>org.apache.maven.plugin-tools</groupId>
<artifactId>maven-plugin-annotations</artifactId>
<scope>provided</scope>
</dependency>

<!-- Maven Core -->
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-model-builder</artifactId>
<artifactId>maven-artifact</artifactId>
<version>${mavenVersion}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.maven.shared</groupId>
<artifactId>maven-dependency-tree</artifactId>
<version>2.2</version>
<groupId>org.apache.maven</groupId>
<artifactId>maven-core</artifactId>
<version>${mavenVersion}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-artifact</artifactId>
<artifactId>maven-model</artifactId>
<version>${mavenVersion}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-core</artifactId>
<artifactId>maven-plugin-api</artifactId>
<version>${mavenVersion}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-plugin-api</artifactId>
<artifactId>maven-model-builder</artifactId>
<version>${mavenVersion}</version>
<scope>provided</scope>
</dependency>

<!-- other -->
<dependency>
<groupId>org.apache.maven.shared</groupId>
<artifactId>maven-dependency-tree</artifactId>
<version>2.2</version>
</dependency>
<dependency>
<groupId>org.codehaus.plexus</groupId>
Expand All @@ -184,6 +199,8 @@
<artifactId>maven-artifact-transfer</artifactId>
<version>0.13.1</version>
</dependency>

<!-- testing -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
Expand All @@ -198,21 +215,15 @@
<dependency>
<groupId>org.apache.maven.plugin-testing</groupId>
<artifactId>maven-plugin-testing-harness</artifactId>
<scope>test</scope>
<version>3.3.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-compat</artifactId>
<version>${mavenVersion}</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.apache.maven.plugin-tools</groupId>
<artifactId>maven-plugin-annotations</artifactId>
<scope>provided</scope>
</dependency>
</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
package org.codehaus.mojo.flatten.model.resolution;

/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
Expand All @@ -16,15 +18,14 @@
* specific language governing permissions and limitations
* under the License.
*/
package org.codehaus.mojo.flatten.model.resolution;

import com.google.common.base.Objects;
import org.apache.maven.project.MavenProject;

import java.io.File;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;

/**
* Holds a list of models and allows to retrieve them by their coordinates.
Expand Down Expand Up @@ -52,7 +53,7 @@ public void addProjects( List<MavenProject> projects )
public void addProject( MavenProject project )
{
Coordinates coordinates = new Coordinates( project.getGroupId(), project.getArtifactId(),
project.getVersion() );
project.getVersion() );
models.put( coordinates, project.getFile() );
}

Expand All @@ -62,28 +63,33 @@ private static final class Coordinates
final String artifactId;
final String version;

Coordinates( String groupId, String artifactId, String version ) {
Coordinates( String groupId, String artifactId, String version )
{
this.groupId = groupId;
this.artifactId = artifactId;
this.version = version;
}

@Override
public boolean equals(Object obj) {
if (obj == this) {
public boolean equals( Object obj )
{
if ( obj == this )
{
return true;
}
if (obj instanceof Coordinates) {
if ( obj instanceof Coordinates )
{
Coordinates other = (Coordinates) obj;
return artifactId.equals(other.artifactId) && groupId.equals(other.groupId)
&& version.equals(other.version);
return artifactId.equals( other.artifactId ) && groupId.equals( other.groupId )
&& version.equals( other.version );
}
return false;
}

@Override
public int hashCode() {
return Objects.hashCode(artifactId, groupId, version);
public int hashCode()
{
return Objects.hash( artifactId, groupId, version );
}

}
Expand Down

0 comments on commit 7e16ce3

Please sign in to comment.