Skip to content

Commit

Permalink
Fixed #445 - itf-maven-plugin:0.13.0:install fails due to missing cla…
Browse files Browse the repository at this point in the history
…ss ArtifactIdUtils
  • Loading branch information
khmarbaise committed Dec 29, 2023
1 parent 3d4cdd6 commit b1672b7
Show file tree
Hide file tree
Showing 5 changed files with 89 additions and 67 deletions.
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
-->
| Release | Maven Central | Release Notes | Users Guide |
|-----------------| --------------------------------------------------- | ----------------------------------------------------------------: | -------------------------------------------------------------: |
| 0.13.0 | [![Maven Central][shield-central]][central-search] | [![PDF][stable-pdf-releasenotes]][releasenotes-pdf] | [![PDF][stable-pdf-usersguide]][usersguide-pdf] |
| 0.13.1 | [![Maven Central][shield-central]][central-search] | [![PDF][stable-pdf-releasenotes]][releasenotes-pdf] | [![PDF][stable-pdf-usersguide]][usersguide-pdf] |
| | | [![HTML][stable-html-release]][releasenotes-html] | [![HTML][stable-html-usersgude]][usersguide-html] |
| 0.14.0-SNAPSHOT | ![Maven Central][not-available-in-central] | [![PDF][unstable-pdf-releasenotes]][unstable-releasenotes-pdf] | [![PDF][unstable-pdf-usersguide]][unstable-usersguide-pdf] |
| | | [![HTML][unstable-html-releasenotes]][unstable-releasenotes-html] | [![HTML][unstable-html-usersguide]][unstable-usersguide-html] |
Expand Down Expand Up @@ -81,13 +81,13 @@ The first thing before you can run integration tests is to add the following dep
<dependency>
<groupId>com.soebes.itf.jupiter.extension</groupId>
<artifactId>itf-jupiter-extension</artifactId>
<version>0.13.0</version>
<version>0.13.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.soebes.itf.jupiter.extension</groupId>
<artifactId>itf-assertj</artifactId>
<version>0.13.0</version>
<version>0.13.1</version>
<scope>test</scope>
</dependency>
</dependencies>
Expand All @@ -113,7 +113,7 @@ which handles the first part which is involved:
<plugin>
<groupId>com.soebes.itf.jupiter.extension</groupId>
<artifactId>itf-maven-plugin</artifactId>
<version>0.13.0</version>
<version>0.13.1</version>
<executions>
<execution>
<id>installing</id>
Expand Down Expand Up @@ -344,10 +344,10 @@ mvn clean verify org.jacoco:jacoco-maven-plugin:report
[unstable-releasenotes-html]: https://khmarbaise.github.io/maven-it-extension/snapshot/itf-documentation/release-notes/release-notes.html
[unstable-releasenotes-pdf]: https://khmarbaise.github.io/maven-it-extension/snapshot/itf-documentation/release-notes/release-notes.pdf

[stable-html-release]: https://img.shields.io/badge/0.13.0-HTML--Releasenotes-green
[stable-html-usersgude]: https://img.shields.io/badge/0.13.0-HTML--Usersguide-green
[stable-pdf-releasenotes]: https://img.shields.io/badge/0.13.0-PDF--Releasenotes-green
[stable-pdf-usersguide]: https://img.shields.io/badge/0.13.0-PDF--Usersguide-green
[stable-html-release]: https://img.shields.io/badge/0.13.1-HTML--Releasenotes-green
[stable-html-usersgude]: https://img.shields.io/badge/0.13.1-HTML--Usersguide-green
[stable-pdf-releasenotes]: https://img.shields.io/badge/0.13.1-PDF--Releasenotes-green
[stable-pdf-usersguide]: https://img.shields.io/badge/0.13.1-PDF--Usersguide-green

[unstable-pdf-releasenotes]: https://img.shields.io/badge/0.14.0--SNAPSHOT-PDF--Releasenotes-orange
[unstable-html-releasenotes]: https://img.shields.io/badge/0.14.0--SNAPSHOT-HTML--Releasenotes-orange
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// 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.
//
[[release-notes-0.13.1]]
== Pre-release 0.13.1

:issue-445: https://github.com/khmarbaise/maven-it-extension/issues/445[Fixed #445]

:release_0_13_1: https://github.com/khmarbaise/maven-it-extension/milestone/16

*Date of Release:* December 29, 2023

*Breaking Changes*
* A change in 0.13.0 broke the compatibility with Maven before version 3.9.0.

* {issue-445} - itf-maven-plugin:0.13.0:install fails due to missing class ArtifactIdUtils
** Restored compatibility with Maven before 3.9.0

*Reporter of this release*

* https://github.com/acanda[Philip Graf]
** {issue-445} - itf-maven-plugin:0.13.0:install fails due to missing class ArtifactIdUtils

The full release notes can be found here {release_0_13_1}[Release 0.13.1].
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ overview and detailed instructions how to use the Integration Testing Framework.

include::{sourcedir}/_release-notes-0.14.0.adoc[]

include::{sourcedir}/_release-notes-0.13.1.adoc[]

include::{sourcedir}/_release-notes-0.13.0.adoc[]

include::{sourcedir}/_release-notes-0.12.0.adoc[]
Expand Down
59 changes: 24 additions & 35 deletions itf-maven-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@

<properties>
<mavenMinimumVersion>3.2.5</mavenMinimumVersion>
<!-- The same version as Maven Core 3.2.5 is using -->
<aetherVersion>1.0.0.v20140518</aetherVersion>
</properties>

<prerequisites>
Expand All @@ -42,26 +44,31 @@

<!-- FIXME: move versions into dependencyManagement -->
<dependencies>
<!--
! The following is required to get that running on Maven 3.8.X and below
-->
<dependency>
<groupId>com.soebes.itf.jupiter.extension</groupId>
<artifactId>itf-extension-maven</artifactId>
<version>${project.version}</version>
<groupId>org.eclipse.aether</groupId>
<artifactId>aether-api</artifactId>
<version>${aetherVersion}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-core</artifactId>
<version>${mavenMinimumVersion}</version>
<scope>provided</scope>
<groupId>org.eclipse.aether</groupId>
<artifactId>aether-util</artifactId>
<version>${aetherVersion}</version>
<!-- To work in Maven versions older than 3.9.0 -->
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-model</artifactId>
<artifactId>maven-core</artifactId>
<version>${mavenMinimumVersion}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-artifact</artifactId>
<artifactId>maven-model</artifactId>
<version>${mavenMinimumVersion}</version>
<scope>provided</scope>
</dependency>
Expand All @@ -71,40 +78,27 @@
<version>${mavenMinimumVersion}</version>
<scope>provided</scope>
</dependency>
<!-- Need to reconsider this -->
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-aether-provider</artifactId>
<version>${mavenMinimumVersion}</version>
<groupId>org.apache.maven.plugin-tools</groupId>
<artifactId>maven-plugin-annotations</artifactId>
<version>${maven-plugin-plugin.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-xml</artifactId>
<version>4.0.3</version>
<scope>provided</scope>
<groupId>com.soebes.itf.jupiter.extension</groupId>
<artifactId>itf-extension-maven</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-interpolation</artifactId>
<version>1.27</version>
<artifactId>plexus-utils</artifactId>
<version>3.5.1</version>
</dependency>
<dependency>
<groupId>org.apache.maven.shared</groupId>
<artifactId>maven-filtering</artifactId>
<version>3.3.1</version>
</dependency>
<dependency>
<groupId>org.apache.maven.shared</groupId>
<artifactId>maven-shared-utils</artifactId>
<version>3.4.2</version>
</dependency>
<dependency>
<groupId>org.apache.maven.plugin-tools</groupId>
<artifactId>maven-plugin-annotations</artifactId>
<version>${maven-plugin-plugin.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
Expand Down Expand Up @@ -157,11 +151,6 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-component-metadata</artifactId>
<version>2.1.1</version>
</plugin>
</plugins>
</build>
<profiles>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
*/

import org.apache.maven.RepositoryUtils;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.execution.MavenSession;
import org.apache.maven.model.DependencyManagement;
import org.apache.maven.model.Model;
Expand Down Expand Up @@ -103,19 +102,13 @@ public class InstallMojo extends AbstractMojo {
@Parameter(defaultValue = "${reactorProjects}", readonly = true)
private Collection<MavenProject> reactorProjects;

/**
*
*/
@Parameter(property = "localRepository", required = true, readonly = true)
private ArtifactRepository localRepository;

@Parameter(defaultValue = "runtime")
private String scope;

public void execute() throws MojoExecutionException, MojoFailureException {
createTestRepository();

Map<String, org.eclipse.aether.artifact.Artifact> resolvedArtifacts = new LinkedHashMap<>();
Map<String, Artifact> resolvedArtifacts = new LinkedHashMap<>();

try {

Expand All @@ -142,11 +135,11 @@ private void createTestRepository()
}
}

private void resolveProjectArtifacts(Map<String, org.eclipse.aether.artifact.Artifact> resolvedArtifacts) {
private void resolveProjectArtifacts(Map<String, Artifact> resolvedArtifacts) {

// pom packaging doesn't have a main artifact
if (project.getArtifact() != null && project.getArtifact().getFile() != null) {
org.eclipse.aether.artifact.Artifact artifact = RepositoryUtils.toArtifact(project.getArtifact());
Artifact artifact = RepositoryUtils.toArtifact(project.getArtifact());
resolvedArtifacts.put(ArtifactIdUtils.toId(artifact), artifact);
}

Expand All @@ -155,24 +148,24 @@ private void resolveProjectArtifacts(Map<String, org.eclipse.aether.artifact.Art
.forEach(a -> resolvedArtifacts.put(ArtifactIdUtils.toId(a), a));
}

private void resolveProjectPoms(MavenProject project, Map<String, org.eclipse.aether.artifact.Artifact> resolvedArtifacts)
private void resolveProjectPoms(MavenProject project, Map<String, Artifact> resolvedArtifacts)
throws ArtifactResolutionException {

if (project == null) {
return;
}

org.eclipse.aether.artifact.Artifact projectPom = RepositoryUtils.toArtifact(new ProjectArtifact(project));
Artifact projectPom = RepositoryUtils.toArtifact(new ProjectArtifact(project));
if (projectPom.getFile() != null) {
resolvedArtifacts.put(projectPom.toString(), projectPom);
} else {
org.eclipse.aether.artifact.Artifact artifact = resolveArtifact(projectPom, project.getRemoteProjectRepositories());
Artifact artifact = resolveArtifact(projectPom, project.getRemoteProjectRepositories());
resolvedArtifacts.put(ArtifactIdUtils.toId(artifact), artifact);
}
resolveProjectPoms(project.getParent(), resolvedArtifacts);
}

private void resolveProjectDependencies(Map<String, org.eclipse.aether.artifact.Artifact> resolvedArtifacts)
private void resolveProjectDependencies(Map<String, Artifact> resolvedArtifacts)
throws ArtifactResolutionException, MojoExecutionException, DependencyResolutionException {

DependencyFilter classpathFilter = DependencyFilterUtils.classpathFilter(scope);
Expand Down Expand Up @@ -203,7 +196,7 @@ private void resolveProjectDependencies(Map<String, org.eclipse.aether.artifact.
DependencyResult dependencyResult =
repositorySystem.resolveDependencies(session.getRepositorySession(), request);

List<org.eclipse.aether.artifact.Artifact> artifacts = dependencyResult.getArtifactResults().stream()
List<Artifact> artifacts = dependencyResult.getArtifactResults().stream()
.map(ArtifactResult::getArtifact)
.collect(Collectors.toList());

Expand All @@ -212,19 +205,19 @@ private void resolveProjectDependencies(Map<String, org.eclipse.aether.artifact.
}

private void resolvePomsForArtifacts(
List<org.eclipse.aether.artifact.Artifact> artifacts,
Map<String, org.eclipse.aether.artifact.Artifact> resolvedArtifacts,
List<Artifact> artifacts,
Map<String, Artifact> resolvedArtifacts,
List<RemoteRepository> remoteRepositories)
throws ArtifactResolutionException, MojoExecutionException {

for (org.eclipse.aether.artifact.Artifact a : artifacts) {
org.eclipse.aether.artifact.Artifact artifactResult = resolveArtifact(new SubArtifact(a, "", "pom"), remoteRepositories);
for (Artifact a : artifacts) {
Artifact artifactResult = resolveArtifact(new SubArtifact(a, "", "pom"), remoteRepositories);
resolvePomWithParents(artifactResult, resolvedArtifacts, remoteRepositories);
}
}

private void resolvePomWithParents(
org.eclipse.aether.artifact.Artifact artifact, Map<String, org.eclipse.aether.artifact.Artifact> resolvedArtifacts, List<RemoteRepository> remoteRepositories)
Artifact artifact, Map<String, Artifact> resolvedArtifacts, List<RemoteRepository> remoteRepositories)
throws MojoExecutionException, ArtifactResolutionException {

if (resolvedArtifacts.containsKey(ArtifactIdUtils.toId(artifact))) {
Expand All @@ -234,16 +227,16 @@ private void resolvePomWithParents(
Model model = PomUtils.loadPom(artifact.getFile());
Parent parent = model.getParent();
if (parent != null) {
org.eclipse.aether.artifact.DefaultArtifact pom =
DefaultArtifact pom =
new DefaultArtifact(parent.getGroupId(), parent.getArtifactId(), "", "pom", parent.getVersion());
org.eclipse.aether.artifact.Artifact resolvedPom = resolveArtifact(pom, remoteRepositories);
Artifact resolvedPom = resolveArtifact(pom, remoteRepositories);
resolvePomWithParents(resolvedPom, resolvedArtifacts, remoteRepositories);
}

resolvedArtifacts.put(ArtifactIdUtils.toId(artifact), artifact);
}

private org.eclipse.aether.artifact.Artifact resolveArtifact(Artifact artifact, List<RemoteRepository> remoteRepositories)
private Artifact resolveArtifact(Artifact artifact, List<RemoteRepository> remoteRepositories)
throws ArtifactResolutionException {

ArtifactRequest request = new ArtifactRequest();
Expand Down Expand Up @@ -317,7 +310,7 @@ private RepositorySystemSession createSystemSessionForLocalRepo() {

newSession.setLocalRepositoryManager(localRepositoryManager);
repositorySystemSession = newSession;
getLog().debug("localRepoPath: "
getLog().debug("itfRepositoryPath: "
+ localRepositoryManager.getRepository().getBasedir());
}

Expand Down

0 comments on commit b1672b7

Please sign in to comment.