Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MINVOKER-319] Workaround to allow use with Maven 4.0.0-alpha-4 #173

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions src/main/java/org/apache/maven/plugins/invoker/InstallMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -218,15 +218,12 @@ private void createTestRepository() throws MojoExecutionException {
* originate from the current (reactor) build. Artifacts that have been grabbed from the user's local repository
* should be installed to the test repository via {@link #copyArtifact(File, Artifact)}.
*
* @param file The file associated with the artifact, must not be <code>null</code>. This is in most cases the value
* of <code>artifact.getFile()</code> with the exception of the main artifact from a project with
* packaging "pom". Projects with packaging "pom" have no main artifact file. They have however artifact
* metadata (e.g. site descriptors) which needs to be installed.
* @param artifact The artifact to install, must not be <code>null</code>.
* @throws MojoExecutionException If the artifact could not be installed (e.g. has no associated file).
*/
private void installArtifact(File file, Artifact artifact) throws MojoExecutionException {
private void installArtifact(Artifact artifact) throws MojoExecutionException {
try {
File file = artifact.getFile();
if (file == null) {
throw new IllegalStateException("Artifact has no associated file: " + artifact.getId());
}
Expand All @@ -235,7 +232,9 @@ private void installArtifact(File file, Artifact artifact) throws MojoExecutionE
}

if (installedArtifacts.add(artifact.getId())) {
artifact.setFile(file);
if (!file.equals(artifact.getFile())) {
artifact.setFile(file);
}
installer.install(projectBuildingRequest, localRepositoryPath, Collections.singletonList(artifact));
} else {
getLog().debug("Not re-installing " + artifact + ", " + file);
Expand All @@ -247,7 +246,7 @@ private void installArtifact(File file, Artifact artifact) throws MojoExecutionE

/**
* Installs the specified artifact to the local repository. This method serves basically the same purpose as
* {@link #installArtifact(File, Artifact)} but is meant for artifacts that have been resolved
* {@link #installArtifact(Artifact)} but is meant for artifacts that have been resolved
* from the user's local repository (and not the current build outputs). The subtle difference here is that
* artifacts from the repository have already undergone transformations and these manipulations should not be redone
* by the artifact installer. For this reason, this method performs plain copy operations to install the artifacts.
Expand Down Expand Up @@ -304,13 +303,13 @@ private void installProjectArtifacts(MavenProject mvnProject) throws MojoExecuti
// Install the main project artifact (if the project has one, e.g. has no "pom" packaging)
Artifact mainArtifact = mvnProject.getArtifact();
if (mainArtifact.getFile() != null) {
installArtifact(mainArtifact.getFile(), mainArtifact);
installArtifact(mainArtifact);
}

// Install any attached project artifacts
Collection<Artifact> attachedArtifacts = mvnProject.getAttachedArtifacts();
for (Artifact attachedArtifact : attachedArtifacts) {
installArtifact(attachedArtifact.getFile(), attachedArtifact);
installArtifact(attachedArtifact);
}
} catch (Exception e) {
throw new MojoExecutionException("Failed to install project artifacts: " + mvnProject, e);
Expand Down Expand Up @@ -354,7 +353,8 @@ private void installProjectPom(MavenProject mvnProject) throws MojoExecutionExce
pomArtifact = artifactFactory.createProjectArtifact(
mvnProject.getGroupId(), mvnProject.getArtifactId(), mvnProject.getVersion());
}
installArtifact(mvnProject.getFile(), pomArtifact);
pomArtifact.setFile(mvnProject.getFile());
installArtifact(pomArtifact);
} catch (Exception e) {
throw new MojoExecutionException("Failed to install POM: " + mvnProject, e);
}
Expand Down