[Git][java-team/maven-install-plugin][master] 8 commits: Standards-Version updated to 4.7.0
Emmanuel Bourg (@ebourg)
gitlab at salsa.debian.org
Fri Dec 20 12:27:02 GMT 2024
Emmanuel Bourg pushed to branch master at Debian Java Maintainers / maven-install-plugin
Commits:
c1b8e52f by Emmanuel Bourg at 2024-07-28T17:27:12+02:00
Standards-Version updated to 4.7.0
- - - - -
b6e818b3 by Emmanuel Bourg at 2024-07-28T17:27:46+02:00
New upstream version 3.1.2
- - - - -
dbc1ef9c by Emmanuel Bourg at 2024-10-22T20:46:59+02:00
New upstream version 3.1.3
- - - - -
2d180d36 by Emmanuel Bourg at 2024-10-22T20:47:00+02:00
Update upstream source from tag 'upstream/3.1.3'
Update to upstream version '3.1.3'
with Debian dir da1e8e4ba686732b1260a4efb51120f134227a22
- - - - -
a3714d5e by Emmanuel Bourg at 2024-10-22T20:47:25+02:00
New dependency on libplexus-xml-java
- - - - -
6efe15f5 by Emmanuel Bourg at 2024-12-20T13:24:37+01:00
Depend on libmaven-resolver-java (>= 1.9.18)
- - - - -
36a10104 by Emmanuel Bourg at 2024-12-20T13:25:32+01:00
Install a relocation pom for the version 3.1.2 expected by Maven 3.9.9
- - - - -
84d3608a by Emmanuel Bourg at 2024-12-20T13:26:30+01:00
Upload to unstable
- - - - -
28 changed files:
- .asf.yaml
- + .git-blame-ignore-revs
- .github/workflows/maven-verify.yml
- debian/changelog
- debian/control
- debian/libmaven-install-plugin-java.poms
- debian/maven.rules
- pom.xml
- src/it/gav-validation/invoker.properties
- src/it/install-file-minstall-121-bundle/test.properties
- src/it/install-file-minstall-121-bundle/verify.bsh
- src/it/install-file-minstall-121-java-source/verify.bsh
- src/it/install-file-minstall-121-maven-archetype/test.properties
- src/it/install-file-minstall-121-maven-archetype/verify.bsh
- src/it/install-file-minstall-121-targz/test.properties
- src/it/install-file-minstall-121-targz/verify.bsh
- src/it/no-main-artifact-1/verify.groovy
- src/it/no-main-artifact-2/verify.groovy
- src/it/non-changed-artifact/invoker.properties
- src/main/java/org/apache/maven/plugins/install/InstallFileMojo.java
- src/main/java/org/apache/maven/plugins/install/InstallMojo.java
- src/test/java/org/apache/maven/plugins/install/InstallFileMojoTest.java
- src/test/java/org/apache/maven/plugins/install/InstallMojoTest.java
- src/test/java/org/apache/maven/plugins/install/stubs/InstallArtifactStub.java
- + src/test/java/org/apache/maven/plugins/install/stubs/InstallBomArtifactStub.java
- + src/test/java/org/apache/maven/plugins/install/stubs/InstallPomArtifactStub.java
- + src/test/resources/unit/basic-install-test-packaging-bom/plugin-config.xml
- src/test/resources/unit/basic-install-test-packaging-pom/plugin-config.xml
Changes:
=====================================
.asf.yaml
=====================================
@@ -29,4 +29,9 @@ github:
merge: false
rebase: true
autolink_jira:
- - MINSTALL
\ No newline at end of file
+ - MINSTALL
+notifications:
+ commits: commits at maven.apache.org
+ issues: issues at maven.apache.org
+ pullrequests: issues at maven.apache.org
+ jira_options: link label comment
=====================================
.git-blame-ignore-revs
=====================================
@@ -0,0 +1,21 @@
+#
+# 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.
+#
+
+# Change maven code style (parent 39)
+ba4cdf27f42ac9c1fa8cba60ec2ee812934d9547
=====================================
.github/workflows/maven-verify.yml
=====================================
@@ -24,4 +24,7 @@ on:
jobs:
build:
name: Verify
- uses: apache/maven-gh-actions-shared/.github/workflows/maven-verify.yml at v3
+ uses: apache/maven-gh-actions-shared/.github/workflows/maven-verify.yml at v4
+ with:
+ maven4-enabled: true
+
=====================================
debian/changelog
=====================================
@@ -1,3 +1,14 @@
+maven-install-plugin (3.1.3-1) unstable; urgency=medium
+
+ * Team upload.
+ * New upstream release
+ - New dependency on libplexus-xml-java
+ - Depend on libmaven-resolver-java (>= 1.9.18)
+ - Install a relocation pom for the version 3.1.2 expected by Maven 3.9.9
+ * Standards-Version updated to 4.7.0
+
+ -- Emmanuel Bourg <ebourg at apache.org> Fri, 20 Dec 2024 13:26:21 +0100
+
maven-install-plugin (3.1.1-1) unstable; urgency=medium
* Team upload.
=====================================
debian/control
=====================================
@@ -14,12 +14,14 @@ Build-Depends:
libmaven-parent-java,
libmaven-plugin-testing-java,
libmaven-plugin-tools-java (>= 3.2),
+ libmaven-resolver-java (>= 1.9.18),
libmaven3-core-java,
libmockito-java,
libmodello-maven-plugin-java,
libplexus-utils-java,
+ libplexus-xml-java,
maven-debian-helper (>= 2.2)
-Standards-Version: 4.6.2
+Standards-Version: 4.7.0
Vcs-Git: https://salsa.debian.org/java-team/maven-install-plugin.git
Vcs-Browser: https://salsa.debian.org/java-team/maven-install-plugin
Homepage: http://maven.apache.org/plugins/maven-install-plugin/
=====================================
debian/libmaven-install-plugin-java.poms
=====================================
@@ -25,4 +25,4 @@
# --site-xml=<location>: Optional, the location for site.xml if it needs to be installed.
# Empty by default. [mh_install]
#
-pom.xml --has-package-version --relocate=org.apache.maven.plugins:maven-install-plugin:2.4
+pom.xml --has-package-version --relocate=org.apache.maven.plugins:maven-install-plugin:2.4,org.apache.maven.plugins:maven-install-plugin:3.1.2
=====================================
debian/maven.rules
=====================================
@@ -19,5 +19,3 @@
junit junit * s/.*/4.x/ * *
org.apache.maven maven-* * s/.*/3.x/ * *
org.apache.maven.plugins maven-plugins pom s/.*/debian/ * *
-
-s/org.eclipse.aether/org.apache.maven.resolver/ s/aether-(.*)/maven-resolver-$1/ * s/.*/debian/ * *
=====================================
pom.xml
=====================================
@@ -23,12 +23,12 @@
<parent>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-plugins</artifactId>
- <version>39</version>
+ <version>43</version>
<relativePath />
</parent>
<artifactId>maven-install-plugin</artifactId>
- <version>3.1.1</version>
+ <version>3.1.3</version>
<packaging>maven-plugin</packaging>
<name>Apache Maven Install Plugin</name>
@@ -46,13 +46,13 @@
</contributors>
<prerequisites>
- <maven>${mavenVersion}</maven>
+ <maven>3.6.3</maven>
</prerequisites>
<scm>
<connection>scm:git:https://gitbox.apache.org/repos/asf/maven-install-plugin.git</connection>
<developerConnection>scm:git:https://gitbox.apache.org/repos/asf/maven-install-plugin.git</developerConnection>
- <tag>maven-install-plugin-3.1.1</tag>
+ <tag>maven-install-plugin-3.1.3</tag>
<url>https://github.com/apache/maven-install-plugin/tree/${project.scm.tag}</url>
</scm>
<issueManagement>
@@ -72,23 +72,23 @@
<properties>
<javaVersion>8</javaVersion>
- <mavenVersion>3.2.5</mavenVersion>
+ <mavenVersion>3.9.6</mavenVersion>
<!-- Maven bound -->
- <aetherVersion>1.0.0.v20140518</aetherVersion>
+ <resolverVersion>1.9.18</resolverVersion>
<!-- Maven bound -->
- <slf4jVersion>1.7.5</slf4jVersion>
+ <slf4jVersion>1.7.36</slf4jVersion>
<!-- plugin versions used in IT tests -->
- <mavenAntrunPluginVersion>3.1.0</mavenAntrunPluginVersion>
- <mavenCompilerPluginVersion>3.10.1</mavenCompilerPluginVersion>
- <mavenEnforcerPluginVersion>3.1.0</mavenEnforcerPluginVersion>
- <mavenJarPluginVersion>3.3.0</mavenJarPluginVersion>
- <mavenPluginPluginVersion>3.7.0</mavenPluginPluginVersion>
- <mavenResourcesPluginVersion>3.3.0</mavenResourcesPluginVersion>
- <mavenSourcePluginVersion>3.2.1</mavenSourcePluginVersion>
- <mavenSurefirePluginVersion>3.0.0-M7</mavenSurefirePluginVersion>
-
- <project.build.outputTimestamp>2023-03-21T14:30:42Z</project.build.outputTimestamp>
+ <mavenAntrunPluginVersion>${version.maven-antrun-plugin}</mavenAntrunPluginVersion>
+ <mavenCompilerPluginVersion>${version.maven-compiler-plugin}</mavenCompilerPluginVersion>
+ <mavenEnforcerPluginVersion>${version.maven-enforcer-plugin}</mavenEnforcerPluginVersion>
+ <mavenJarPluginVersion>${version.maven-jar-plugin}</mavenJarPluginVersion>
+ <mavenPluginPluginVersion>${version.maven-plugin-tools}</mavenPluginPluginVersion>
+ <mavenResourcesPluginVersion>${version.maven-resources-plugin}</mavenResourcesPluginVersion>
+ <mavenSourcePluginVersion>${version.maven-source-plugin}</mavenSourcePluginVersion>
+ <mavenSurefirePluginVersion>${version.maven-surefire}</mavenSurefirePluginVersion>
+
+ <project.build.outputTimestamp>2024-08-15T19:40:47Z</project.build.outputTimestamp>
</properties>
<dependencies>
@@ -104,7 +104,6 @@
<version>${mavenVersion}</version>
<scope>provided</scope>
</dependency>
- <!-- This is here to override 3.0 coming with maven-artifact-transfer -->
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-core</artifactId>
@@ -118,22 +117,32 @@
<scope>provided</scope>
</dependency>
<dependency>
- <groupId>org.eclipse.aether</groupId>
- <artifactId>aether-api</artifactId>
- <version>${aetherVersion}</version>
+ <groupId>org.apache.maven.resolver</groupId>
+ <artifactId>maven-resolver-api</artifactId>
+ <version>${resolverVersion}</version>
<scope>provided</scope>
</dependency>
<dependency>
- <groupId>org.eclipse.aether</groupId>
- <artifactId>aether-util</artifactId>
- <version>${aetherVersion}</version>
+ <groupId>org.apache.maven.resolver</groupId>
+ <artifactId>maven-resolver-util</artifactId>
+ <version>${resolverVersion}</version>
<!-- To work in Maven versions older than 3.9.0 -->
<scope>compile</scope>
</dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ <version>${slf4jVersion}</version>
+ <scope>provided</scope>
+ </dependency>
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-utils</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-xml</artifactId>
+ </dependency>
<!-- dependencies to annotations -->
<dependency>
@@ -167,12 +176,6 @@
<version>4.8.1</version>
<scope>test</scope>
</dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-api</artifactId>
- <version>${slf4jVersion}</version>
- <scope>provided</scope>
- </dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-nop</artifactId>
@@ -180,9 +183,9 @@
<scope>test</scope>
</dependency>
<dependency>
- <groupId>org.eclipse.aether</groupId>
- <artifactId>aether-impl</artifactId>
- <version>${aetherVersion}</version>
+ <groupId>org.apache.maven.resolver</groupId>
+ <artifactId>maven-resolver-impl</artifactId>
+ <version>${resolverVersion}</version>
<scope>test</scope>
</dependency>
</dependencies>
=====================================
src/it/gav-validation/invoker.properties
=====================================
@@ -18,5 +18,5 @@
invoker.goals = org.apache.maven.plugins:maven-install-plugin:${project.version}:install-file
invoker.buildResult = failure
-invoker.systemPropertiesFile.1 = test-invalid.properties
-invoker.systemPropertiesFile.2 = test-missing.properties
+invoker.userPropertiesFile.1 = test-invalid.properties
+invoker.userPropertiesFile.2 = test-missing.properties
=====================================
src/it/install-file-minstall-121-bundle/test.properties
=====================================
@@ -18,3 +18,4 @@
file = test-0.1.jar
pomFile = test-0.1.pom
packaging = bundle
+extension = jar
=====================================
src/it/install-file-minstall-121-bundle/verify.bsh
=====================================
@@ -24,7 +24,7 @@ String[] paths =
{
"org/apache/maven/its/install/121/maven-bundle/maven-metadata-local.xml",
"org/apache/maven/its/install/121/maven-bundle/1.0/maven-bundle-1.0.pom",
- "org/apache/maven/its/install/121/maven-bundle/1.0/maven-bundle-1.0.jar",
+ "org/apache/maven/its/install/121/maven-bundle/1.0/maven-bundle-1.0.jar", // packaging bundle is NOT in core! (explicitly set with -Dextension=jar)
};
for ( String path : paths )
=====================================
src/it/install-file-minstall-121-java-source/verify.bsh
=====================================
@@ -24,7 +24,7 @@ String[] paths =
{
"org/apache/maven/its/install/121/test-java-source/maven-metadata-local.xml",
"org/apache/maven/its/install/121/test-java-source/1.0/test-java-source-1.0.pom",
- "org/apache/maven/its/install/121/test-java-source/1.0/test-java-source-1.0-sources.jar",
+ "org/apache/maven/its/install/121/test-java-source/1.0/test-java-source-1.0-sources.jar", // packaging java-source IS in core
};
for ( String path : paths )
=====================================
src/it/install-file-minstall-121-maven-archetype/test.properties
=====================================
@@ -18,3 +18,4 @@
file = test-0.1.jar
pomFile = test-0.1.pom
packaging = maven-archetype
+extension = jar
=====================================
src/it/install-file-minstall-121-maven-archetype/verify.bsh
=====================================
@@ -24,7 +24,7 @@ String[] paths =
{
"org/apache/maven/its/install/121/maven-archetype/maven-metadata-local.xml",
"org/apache/maven/its/install/121/maven-archetype/1.0/maven-archetype-1.0.pom",
- "org/apache/maven/its/install/121/maven-archetype/1.0/maven-archetype-1.0.jar",
+ "org/apache/maven/its/install/121/maven-archetype/1.0/maven-archetype-1.0.jar", // packaging maven-archetype is NOT in core! (explicitly set with -Dextension=jar)
};
for ( String path : paths )
=====================================
src/it/install-file-minstall-121-targz/test.properties
=====================================
@@ -18,3 +18,4 @@
file = test-0.1.tar.gz
pomFile = test-0.1.pom
packaging = war
+extension = tar.gz
=====================================
src/it/install-file-minstall-121-targz/verify.bsh
=====================================
@@ -24,7 +24,7 @@ String[] paths =
{
"org/apache/maven/its/install/121/test-targz/maven-metadata-local.xml",
"org/apache/maven/its/install/121/test-targz/1.0/test-targz-1.0.pom",
- "org/apache/maven/its/install/121/test-targz/1.0/test-targz-1.0.tar.gz",
+ "org/apache/maven/its/install/121/test-targz/1.0/test-targz-1.0.tar.gz", // this test is totally fluke: deploy POM.packaging=war and main artifact tar.gz
};
for ( String path : paths )
=====================================
src/it/no-main-artifact-1/verify.groovy
=====================================
@@ -19,5 +19,5 @@
def buildLog = new File ( basedir, "build.log")
-assert buildLog.text.contains( "The packaging plugin for this project did not assign "
+assert buildLog.text.contains( "The packaging plugin for project test did not assign "
+ "a main file to the project but it has attachments. Change packaging to 'pom'." )
\ No newline at end of file
=====================================
src/it/no-main-artifact-2/verify.groovy
=====================================
@@ -19,5 +19,5 @@
def buildLog = new File ( basedir, "build.log")
-assert buildLog.text.contains( "The packaging plugin for this project did not assign "
+assert buildLog.text.contains( "The packaging plugin for project test did not assign "
+ "a main file to the project but it has attachments. Change packaging to 'pom'." )
\ No newline at end of file
=====================================
src/it/non-changed-artifact/invoker.properties
=====================================
@@ -15,6 +15,9 @@
# specific language governing permissions and limitations
# under the License.
+# check was removed in MRESOLVER-392
+invoker.maven.version = !4+
+
# install called in two different Maven invocations, otherwise the build would fail with the Jar Plugin (MJAR-198)
invoker.goals.1 = install
invoker.goals.2 = install
=====================================
src/main/java/org/apache/maven/plugins/install/InstallFileMojo.java
=====================================
@@ -23,10 +23,11 @@ import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
-import java.io.Reader;
-import java.io.Writer;
import java.nio.file.Files;
-import java.util.Enumeration;
+import java.nio.file.Path;
+import java.nio.file.StandardCopyOption;
+import java.util.Objects;
+import java.util.function.Predicate;
import java.util.jar.JarEntry;
import java.util.jar.JarFile;
import java.util.regex.Pattern;
@@ -43,10 +44,7 @@ import org.apache.maven.plugins.annotations.Component;
import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.Parameter;
import org.codehaus.plexus.util.FileUtils;
-import org.codehaus.plexus.util.IOUtil;
import org.codehaus.plexus.util.StringUtils;
-import org.codehaus.plexus.util.xml.XmlStreamReader;
-import org.codehaus.plexus.util.xml.XmlStreamWriter;
import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
import org.eclipse.aether.DefaultRepositoryCache;
import org.eclipse.aether.DefaultRepositorySystemSession;
@@ -60,6 +58,10 @@ import org.eclipse.aether.installation.InstallationException;
import org.eclipse.aether.repository.LocalRepository;
import org.eclipse.aether.repository.LocalRepositoryManager;
import org.eclipse.aether.util.artifact.SubArtifact;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import static java.util.Objects.isNull;
/**
* Installs a file in the local repository.
@@ -68,7 +70,8 @@ import org.eclipse.aether.util.artifact.SubArtifact;
*/
@Mojo(name = "install-file", requiresProject = false, aggregator = true, threadSafe = true)
public class InstallFileMojo extends AbstractMojo {
- private static final String LS = System.getProperty("line.separator");
+ private static final String LS = System.lineSeparator();
+ private final Logger log = LoggerFactory.getLogger(getClass());
@Component
private RepositorySystem repositorySystem;
@@ -113,6 +116,15 @@ public class InstallFileMojo extends AbstractMojo {
@Parameter(property = "classifier")
private String classifier;
+ /**
+ * Extension of the artifact to be installed. If set, will override plugin own logic to detect extension. If not set,
+ * as Maven expected, packaging determines the artifact extension.
+ *
+ * @since 3.1.3
+ */
+ @Parameter(property = "extension")
+ private String extension;
+
/**
* The file to be installed in the local repository.
*/
@@ -162,11 +174,15 @@ public class InstallFileMojo extends AbstractMojo {
@Parameter(property = "localRepositoryPath")
private File localRepositoryPath;
+ private static final Predicate<String> IS_EMPTY = s -> isNull(s) || s.isEmpty();
+
+ private static final Predicate<String> IS_POM_PACKAGING = "pom"::equals;
+
@Override
public void execute() throws MojoExecutionException, MojoFailureException {
if (!file.exists()) {
String message = "The specified file '" + file.getPath() + "' does not exist";
- getLog().error(message);
+ log.error(message);
throw new MojoFailureException(message);
}
@@ -186,23 +202,23 @@ public class InstallFileMojo extends AbstractMojo {
newSession, new LocalRepository(localRepositoryPath, contentType));
newSession.setLocalRepositoryManager(localRepositoryManager);
repositorySystemSession = newSession;
- getLog().debug("localRepoPath: "
- + localRepositoryManager.getRepository().getBasedir());
+ log.debug(
+ "localRepoPath: {}", localRepositoryManager.getRepository().getBasedir());
}
File temporaryPom = null;
- if (pomFile != null) {
- processModel(readModel(pomFile));
- } else {
+ if (pomFile == null) {
temporaryPom = readingPomFromJarFile();
if (!Boolean.TRUE.equals(generatePom)) {
pomFile = temporaryPom;
- getLog().debug("Using JAR embedded POM as pomFile");
+ log.debug("Using JAR embedded POM as pomFile");
}
+ } else {
+ processModel(readModel(pomFile));
}
- if (groupId == null || artifactId == null || version == null || packaging == null) {
+ if (isNull(groupId) || isNull(artifactId) || isNull(version) || isNull(packaging)) {
throw new MojoExecutionException("The artifact information is incomplete: 'groupId', 'artifactId', "
+ "'version' and 'packaging' are required.");
}
@@ -213,18 +229,29 @@ public class InstallFileMojo extends AbstractMojo {
InstallRequest installRequest = new InstallRequest();
- boolean isFilePom = classifier == null && "pom".equals(packaging);
- if (!isFilePom) {
+ String mainArtifactExtension;
+ if (classifier == null && "pom".equals(packaging)) {
+ mainArtifactExtension = "pom";
+ } else {
ArtifactType artifactType =
- repositorySystemSession.getArtifactTypeRegistry().get(packaging);
- if (artifactType != null
- && StringUtils.isEmpty(classifier)
- && !StringUtils.isEmpty(artifactType.getClassifier())) {
- classifier = artifactType.getClassifier();
+ session.getRepositorySession().getArtifactTypeRegistry().get(packaging);
+ if (artifactType != null) {
+ if (StringUtils.isEmpty(classifier) && !StringUtils.isEmpty(artifactType.getClassifier())) {
+ classifier = artifactType.getClassifier();
+ }
+ mainArtifactExtension = artifactType.getExtension();
+ } else {
+ mainArtifactExtension = packaging;
}
}
+ if (extension != null && !Objects.equals(extension, mainArtifactExtension)) {
+ log.warn(
+ "Main artifact extension should be '{}' but was overridden to '{}'",
+ mainArtifactExtension,
+ extension);
+ }
Artifact mainArtifact = new DefaultArtifact(
- groupId, artifactId, classifier, isFilePom ? "pom" : getExtension(file), version)
+ groupId, artifactId, classifier, extension != null ? extension : mainArtifactExtension, version)
.setFile(file);
installRequest.addArtifact(mainArtifact);
@@ -236,17 +263,17 @@ public class InstallFileMojo extends AbstractMojo {
+ LS + LS + "File in question is: " + file + LS);
}
- if (!"pom".equals(packaging)) {
- if (pomFile != null) {
- installRequest.addArtifact(new SubArtifact(mainArtifact, "", "pom", pomFile));
- } else {
+ if (!IS_POM_PACKAGING.test(packaging)) {
+ if (isNull(pomFile)) {
if (Boolean.TRUE.equals(generatePom) || (generatePom == null && !pomLocalFile.exists())) {
temporaryPom = generatePomFile();
- getLog().debug("Installing generated POM");
+ log.debug("Installing generated POM");
installRequest.addArtifact(new SubArtifact(mainArtifact, "", "pom", temporaryPom));
} else if (generatePom == null) {
- getLog().debug("Skipping installation of generated POM, already present in local repository");
+ log.debug("Skipping installation of generated POM, already present in local repository");
}
+ } else {
+ installRequest.addArtifact(new SubArtifact(mainArtifact, "", "pom", pomFile));
}
}
@@ -270,70 +297,40 @@ public class InstallFileMojo extends AbstractMojo {
}
}
- private File readingPomFromJarFile() throws MojoExecutionException {
- File pomFile = null;
+ private static final Pattern POM_ENTRY_PATTERN = Pattern.compile("META-INF/maven/.*/pom\\.xml");
- JarFile jarFile = null;
- try {
- Pattern pomEntry = Pattern.compile("META-INF/maven/.*/pom\\.xml");
+ private static final Predicate<JarEntry> IS_POM_ENTRY =
+ entry -> POM_ENTRY_PATTERN.matcher(entry.getName()).matches();
- jarFile = new JarFile(file);
-
- Enumeration<JarEntry> jarEntries = jarFile.entries();
-
- while (jarEntries.hasMoreElements()) {
- JarEntry entry = jarEntries.nextElement();
-
- if (pomEntry.matcher(entry.getName()).matches()) {
- getLog().debug("Loading " + entry.getName());
-
- InputStream pomInputStream = null;
- OutputStream pomOutputStream = null;
-
- try {
- pomInputStream = jarFile.getInputStream(entry);
+ private File readingPomFromJarFile() throws MojoExecutionException {
- String base = file.getName();
- if (base.indexOf('.') > 0) {
- base = base.substring(0, base.lastIndexOf('.'));
- }
- pomFile = File.createTempFile(base, ".pom");
+ String base = file.getName();
+ if (base.contains(".")) {
+ base = base.substring(0, base.lastIndexOf('.'));
+ }
- pomOutputStream = Files.newOutputStream(pomFile.toPath());
+ try (JarFile jarFile = new JarFile(file)) {
- IOUtil.copy(pomInputStream, pomOutputStream);
+ JarEntry pomEntry = jarFile.stream().filter(IS_POM_ENTRY).findAny().orElse(null);
- pomOutputStream.close();
- pomOutputStream = null;
+ if (isNull(pomEntry)) {
+ // This means there is no entry which matches the "pom.xml"...(or in other words: not packaged by Maven)
+ log.info("pom.xml not found in {}", file.getName());
+ return null;
+ }
- pomInputStream.close();
- pomInputStream = null;
+ Path tempPomFile = Files.createTempFile(base, ".pom");
- processModel(readModel(pomFile));
+ Files.copy(jarFile.getInputStream(pomEntry), tempPomFile, StandardCopyOption.REPLACE_EXISTING);
- break;
- } finally {
- IOUtil.close(pomInputStream);
- IOUtil.close(pomOutputStream);
- }
- }
- }
+ log.debug("Loading {}", pomEntry.getName());
+ processModel(readModel(tempPomFile.toFile()));
+ return tempPomFile.toFile();
- if (pomFile == null) {
- getLog().info("pom.xml not found in " + file.getName());
- }
} catch (IOException e) {
// ignore, artifact not packaged by Maven
- } finally {
- if (jarFile != null) {
- try {
- jarFile.close();
- } catch (IOException e) {
- // we did our best
- }
- }
+ return null;
}
- return pomFile;
}
/**
@@ -344,21 +341,14 @@ public class InstallFileMojo extends AbstractMojo {
* @throws MojoExecutionException If the POM could not be parsed.
*/
private Model readModel(File pomFile) throws MojoExecutionException {
- Reader reader = null;
- try {
- reader = new XmlStreamReader(pomFile);
- final Model model = new MavenXpp3Reader().read(reader);
- reader.close();
- reader = null;
- return model;
+ try (InputStream reader = Files.newInputStream(pomFile.toPath())) {
+ return new MavenXpp3Reader().read(reader);
} catch (FileNotFoundException e) {
throw new MojoExecutionException("File not found " + pomFile, e);
} catch (IOException e) {
throw new MojoExecutionException("Error reading POM " + pomFile, e);
} catch (XmlPullParserException e) {
throw new MojoExecutionException("Error parsing POM " + pomFile, e);
- } finally {
- IOUtil.close(reader);
}
}
@@ -419,21 +409,15 @@ public class InstallFileMojo extends AbstractMojo {
*/
private File generatePomFile() throws MojoExecutionException {
Model model = generateModel();
-
- Writer writer = null;
try {
- File pomFile = File.createTempFile("mvninstall", ".pom");
-
- writer = new XmlStreamWriter(pomFile);
- new MavenXpp3Writer().write(writer, model);
- writer.close();
- writer = null;
+ Path tempPomFile = Files.createTempFile("mvninstall", ".pom");
- return pomFile;
+ try (OutputStream writer = Files.newOutputStream(tempPomFile)) {
+ new MavenXpp3Writer().write(writer, model);
+ return tempPomFile.toFile();
+ }
} catch (IOException e) {
throw new MojoExecutionException("Error writing temporary POM file: " + e.getMessage(), e);
- } finally {
- IOUtil.close(writer);
}
}
=====================================
src/main/java/org/apache/maven/plugins/install/InstallMojo.java
=====================================
@@ -19,9 +19,10 @@
package org.apache.maven.plugins.install;
import java.io.File;
-import java.util.ArrayList;
import java.util.List;
import java.util.Map;
+import java.util.function.Predicate;
+import java.util.stream.Collectors;
import org.apache.maven.RepositoryUtils;
import org.apache.maven.execution.MavenSession;
@@ -37,8 +38,10 @@ import org.apache.maven.plugins.annotations.Parameter;
import org.apache.maven.project.MavenProject;
import org.apache.maven.project.artifact.ProjectArtifact;
import org.eclipse.aether.RepositorySystem;
+import org.eclipse.aether.artifact.Artifact;
import org.eclipse.aether.installation.InstallRequest;
import org.eclipse.aether.installation.InstallationException;
+import org.eclipse.aether.util.artifact.ArtifactIdUtils;
/**
* Installs the project's main artifact, and any other artifacts attached by other plugins in the lifecycle, to the
@@ -57,9 +60,6 @@ public class InstallMojo extends AbstractMojo {
@Parameter(defaultValue = "${project}", readonly = true, required = true)
private MavenProject project;
- @Parameter(defaultValue = "${reactorProjects}", required = true, readonly = true)
- private List<MavenProject> reactorProjects;
-
@Parameter(defaultValue = "${plugin}", required = true, readonly = true)
private PluginDescriptor pluginDescriptor;
@@ -122,15 +122,15 @@ public class InstallMojo extends AbstractMojo {
getLog().info("Skipping artifact installation");
putState(State.SKIPPED);
} else {
- if (!installAtEnd) {
+ if (installAtEnd) {
+ getLog().info("Deferring install for " + project.getGroupId() + ":" + project.getArtifactId() + ":"
+ + project.getVersion() + " at end");
+ putState(State.TO_BE_INSTALLED);
+ } else {
InstallRequest request = new InstallRequest();
processProject(project, request);
installProject(request);
putState(State.INSTALLED);
- } else {
- getLog().info("Deferring install for " + project.getGroupId() + ":" + project.getArtifactId() + ":"
- + project.getVersion() + " at end");
- putState(State.TO_BE_INSTALLED);
}
}
@@ -149,35 +149,27 @@ public class InstallMojo extends AbstractMojo {
}
private boolean allProjectsMarked(List<MavenProject> allProjectsUsingPlugin) {
- for (MavenProject reactorProject : allProjectsUsingPlugin) {
- if (!hasState(reactorProject)) {
- return false;
- }
- }
- return true;
+ return allProjectsUsingPlugin.stream().allMatch(this::hasState);
}
+ private final Predicate<MavenProject> hasMavenInstallPluginExecution =
+ rp -> hasExecution(rp.getPlugin("org.apache.maven.plugins:maven-install-plugin"));
+
private List<MavenProject> getAllProjectsUsingPlugin() {
- ArrayList<MavenProject> result = new ArrayList<>();
- for (MavenProject reactorProject : reactorProjects) {
- if (hasExecution(reactorProject.getPlugin("org.apache.maven.plugins:maven-install-plugin"))) {
- result.add(reactorProject);
- }
- }
- return result;
+ return session.getProjects().stream()
+ .filter(hasMavenInstallPluginExecution)
+ .collect(Collectors.toList());
}
+ private final Predicate<PluginExecution> havingGoals = pe -> !pe.getGoals().isEmpty();
+ private final Predicate<PluginExecution> nonePhase = pe -> !"none".equalsIgnoreCase(pe.getPhase());
+
private boolean hasExecution(Plugin plugin) {
if (plugin == null) {
return false;
}
- for (PluginExecution execution : plugin.getExecutions()) {
- if (!execution.getGoals().isEmpty() && !"none".equalsIgnoreCase(execution.getPhase())) {
- return true;
- }
- }
- return false;
+ return plugin.getExecutions().stream().filter(havingGoals).anyMatch(nonePhase);
}
private void installProject(InstallRequest request) throws MojoExecutionException {
@@ -194,31 +186,52 @@ public class InstallMojo extends AbstractMojo {
* @throws MojoExecutionException if project is badly set up.
*/
private void processProject(MavenProject project, InstallRequest request) throws MojoExecutionException {
- if (isFile(project.getFile())) {
- request.addArtifact(RepositoryUtils.toArtifact(new ProjectArtifact(project)));
+ // always exists, as project exists
+ Artifact pomArtifact = RepositoryUtils.toArtifact(new ProjectArtifact(project));
+ // always exists, but at "init" is w/o file (packaging plugin assigns file to this when packaged)
+ Artifact projectArtifact = RepositoryUtils.toArtifact(project.getArtifact());
+
+ // pom project: pomArtifact and projectArtifact are SAME
+ // jar project: pomArtifact and projectArtifact are DIFFERENT
+ // incomplete project: is not pom project and projectArtifact has no file
+
+ // we must compare coordinates ONLY (as projectArtifact may not have file, and Artifact.equals factors it in)
+ // BUT if projectArtifact has file set, use that one
+ if (ArtifactIdUtils.equalsId(pomArtifact, projectArtifact)) {
+ if (isFile(projectArtifact.getFile())) {
+ pomArtifact = projectArtifact;
+ }
+ projectArtifact = null;
+ }
+
+ if (isFile(pomArtifact.getFile())) {
+ request.addArtifact(pomArtifact);
} else {
- throw new MojoExecutionException("The project POM could not be attached");
+ throw new MojoExecutionException(
+ "The POM for project " + project.getArtifactId() + " could not be attached");
}
- if (!"pom".equals(project.getPackaging())) {
- org.apache.maven.artifact.Artifact mavenMainArtifact = project.getArtifact();
- if (isFile(mavenMainArtifact.getFile())) {
- request.addArtifact(RepositoryUtils.toArtifact(mavenMainArtifact));
+ // is not packaged, is "incomplete"
+ boolean isIncomplete = projectArtifact != null && !isFile(projectArtifact.getFile());
+ if (projectArtifact != null) {
+ if (!isIncomplete) {
+ request.addArtifact(projectArtifact);
} else if (!project.getAttachedArtifacts().isEmpty()) {
if (allowIncompleteProjects) {
getLog().warn("");
- getLog().warn("The packaging plugin for this project did not assign");
+ getLog().warn("The packaging plugin for project " + project.getArtifactId() + " did not assign");
getLog().warn("a main file to the project but it has attachments. Change packaging to 'pom'.");
getLog().warn("");
getLog().warn("Incomplete projects like this will fail in future Maven versions!");
getLog().warn("");
} else {
- throw new MojoExecutionException("The packaging plugin for this project did not assign "
- + "a main file to the project but it has attachments. Change packaging to 'pom'.");
+ throw new MojoExecutionException("The packaging plugin for project " + project.getArtifactId()
+ + " did not assign a main file to the project but it has attachments. Change packaging"
+ + " to 'pom'.");
}
} else {
- throw new MojoExecutionException(
- "The packaging for this project did not assign a file to the build artifact");
+ throw new MojoExecutionException("The packaging plugin for project " + project.getArtifactId()
+ + " did not assign a file to the build artifact");
}
}
=====================================
src/test/java/org/apache/maven/plugins/install/InstallFileMojoTest.java
=====================================
@@ -30,6 +30,9 @@ import org.apache.maven.project.ProjectBuildingRequest;
import org.codehaus.plexus.util.FileUtils;
import org.codehaus.plexus.util.xml.XmlStreamReader;
import org.eclipse.aether.DefaultRepositorySystemSession;
+import org.eclipse.aether.internal.impl.DefaultLocalPathComposer;
+import org.eclipse.aether.internal.impl.DefaultLocalPathPrefixComposerFactory;
+import org.eclipse.aether.internal.impl.DefaultTrackingFileManager;
import org.eclipse.aether.internal.impl.EnhancedLocalRepositoryManagerFactory;
import org.eclipse.aether.repository.LocalRepository;
import org.eclipse.aether.repository.NoLocalRepositoryManagerException;
@@ -341,7 +344,10 @@ public class InstallFileMojoTest extends AbstractMojoTestCase {
private MavenSession createMavenSession(String localRepositoryBaseDir) throws NoLocalRepositoryManagerException {
MavenSession session = mock(MavenSession.class);
DefaultRepositorySystemSession repositorySession = new DefaultRepositorySystemSession();
- repositorySession.setLocalRepositoryManager(new EnhancedLocalRepositoryManagerFactory()
+ repositorySession.setLocalRepositoryManager(new EnhancedLocalRepositoryManagerFactory(
+ new DefaultLocalPathComposer(),
+ new DefaultTrackingFileManager(),
+ new DefaultLocalPathPrefixComposerFactory())
.newInstance(repositorySession, new LocalRepository(localRepositoryBaseDir)));
ProjectBuildingRequest buildingRequest = new DefaultProjectBuildingRequest();
buildingRequest.setRepositorySession(repositorySession);
=====================================
src/test/java/org/apache/maven/plugins/install/InstallMojoTest.java
=====================================
@@ -39,6 +39,9 @@ import org.apache.maven.project.ProjectBuildingRequest;
import org.codehaus.plexus.util.FileUtils;
import org.eclipse.aether.DefaultRepositorySystemSession;
import org.eclipse.aether.artifact.DefaultArtifact;
+import org.eclipse.aether.internal.impl.DefaultLocalPathComposer;
+import org.eclipse.aether.internal.impl.DefaultLocalPathPrefixComposerFactory;
+import org.eclipse.aether.internal.impl.DefaultTrackingFileManager;
import org.eclipse.aether.internal.impl.EnhancedLocalRepositoryManagerFactory;
import org.eclipse.aether.repository.LocalRepository;
import org.eclipse.aether.repository.NoLocalRepositoryManagerException;
@@ -84,10 +87,11 @@ public class InstallMojoTest extends AbstractMojoTestCase {
MavenProject project = (MavenProject) getVariableValueFromObject(mojo, "project");
updateMavenProject(project);
+ MavenSession session = createMavenSession();
+ session.setProjects(Collections.singletonList(project));
+ setVariableValueToObject(mojo, "session", session);
setVariableValueToObject(mojo, "pluginContext", new ConcurrentHashMap<>());
setVariableValueToObject(mojo, "pluginDescriptor", new PluginDescriptor());
- setVariableValueToObject(mojo, "reactorProjects", Collections.singletonList(project));
- setVariableValueToObject(mojo, "session", createMavenSession());
artifact = (InstallArtifactStub) project.getArtifact();
@@ -120,10 +124,11 @@ public class InstallMojoTest extends AbstractMojoTestCase {
MavenProject project = (MavenProject) getVariableValueFromObject(mojo, "project");
updateMavenProject(project);
+ MavenSession session = createMavenSession();
+ session.setProjects(Collections.singletonList(project));
+ setVariableValueToObject(mojo, "session", session);
setVariableValueToObject(mojo, "pluginContext", new ConcurrentHashMap<>());
setVariableValueToObject(mojo, "pluginDescriptor", new PluginDescriptor());
- setVariableValueToObject(mojo, "reactorProjects", Collections.singletonList(project));
- setVariableValueToObject(mojo, "session", createMavenSession());
List<Artifact> attachedArtifacts = project.getAttachedArtifacts();
@@ -150,6 +155,38 @@ public class InstallMojoTest extends AbstractMojoTestCase {
assertEquals(13, FileUtils.getFiles(new File(LOCAL_REPO), null, null).size());
}
+ public void testNonPomInstallWithAttachedArtifactsOnly() throws Exception {
+ File testPom = new File(
+ getBasedir(),
+ "target/test-classes/unit/basic-install-test-with-attached-artifacts/" + "plugin-config.xml");
+
+ AbstractMojo mojo = (AbstractMojo) lookupMojo("install", testPom);
+
+ assertNotNull(mojo);
+
+ MavenProject project = (MavenProject) getVariableValueFromObject(mojo, "project");
+ updateMavenProject(project);
+
+ setVariableValueToObject(mojo, "pluginContext", new ConcurrentHashMap<>());
+ setVariableValueToObject(mojo, "pluginDescriptor", new PluginDescriptor());
+ setVariableValueToObject(mojo, "session", createMavenSession());
+
+ artifact = (InstallArtifactStub) project.getArtifact();
+
+ artifact.setFile(null);
+
+ try {
+ mojo.execute();
+ fail("Did not throw mojo execution exception");
+ } catch (MojoExecutionException e) {
+ // expected, message should include artifactId
+ assertEquals(
+ "The packaging plugin for project maven-install-test did not assign a main file to the project "
+ + "but it has attachments. Change packaging to 'pom'.",
+ e.getMessage());
+ }
+ }
+
public void testUpdateReleaseParamSetToTrue() throws Exception {
File testPom = new File(getBasedir(), "target/test-classes/unit/configured-install-test/plugin-config.xml");
@@ -164,10 +201,11 @@ public class InstallMojoTest extends AbstractMojoTestCase {
MavenProject project = (MavenProject) getVariableValueFromObject(mojo, "project");
updateMavenProject(project);
+ MavenSession session = createMavenSession();
+ session.setProjects(Collections.singletonList(project));
+ setVariableValueToObject(mojo, "session", session);
setVariableValueToObject(mojo, "pluginContext", new ConcurrentHashMap<>());
setVariableValueToObject(mojo, "pluginDescriptor", new PluginDescriptor());
- setVariableValueToObject(mojo, "reactorProjects", Collections.singletonList(project));
- setVariableValueToObject(mojo, "session", createMavenSession());
artifact = (InstallArtifactStub) project.getArtifact();
@@ -190,10 +228,11 @@ public class InstallMojoTest extends AbstractMojoTestCase {
MavenProject project = (MavenProject) getVariableValueFromObject(mojo, "project");
updateMavenProject(project);
+ MavenSession session = createMavenSession();
+ session.setProjects(Collections.singletonList(project));
+ setVariableValueToObject(mojo, "session", session);
setVariableValueToObject(mojo, "pluginContext", new ConcurrentHashMap<>());
setVariableValueToObject(mojo, "pluginDescriptor", new PluginDescriptor());
- setVariableValueToObject(mojo, "reactorProjects", Collections.singletonList(project));
- setVariableValueToObject(mojo, "session", createMavenSession());
artifact = (InstallArtifactStub) project.getArtifact();
@@ -203,15 +242,44 @@ public class InstallMojoTest extends AbstractMojoTestCase {
try {
mojo.execute();
-
fail("Did not throw mojo execution exception");
} catch (MojoExecutionException e) {
- // expected
+ // expected, message should include artifactId
+ assertEquals(
+ "The packaging plugin for project maven-install-test did not assign a file to the build artifact",
+ e.getMessage());
}
assertFalse(new File(LOCAL_REPO).exists());
}
+ public void testInstallIfProjectFileIsNull() throws Exception {
+ File testPom = new File(getBasedir(), "target/test-classes/unit/basic-install-test/plugin-config.xml");
+
+ AbstractMojo mojo = (AbstractMojo) lookupMojo("install", testPom);
+
+ assertNotNull(mojo);
+
+ MavenProject project = (MavenProject) getVariableValueFromObject(mojo, "project");
+ updateMavenProject(project);
+
+ setVariableValueToObject(mojo, "pluginContext", new ConcurrentHashMap<>());
+ setVariableValueToObject(mojo, "pluginDescriptor", new PluginDescriptor());
+ setVariableValueToObject(mojo, "session", createMavenSession());
+
+ project.setFile(null);
+
+ assertNull(project.getFile());
+
+ try {
+ mojo.execute();
+ fail("Did not throw mojo execution exception");
+ } catch (MojoExecutionException e) {
+ // expected, message should include artifactId
+ assertEquals("The POM for project maven-install-test could not be attached", e.getMessage());
+ }
+ }
+
public void testInstallIfPackagingIsPom() throws Exception {
File testPom = new File(
getBasedir(), "target/test-classes/unit/basic-install-test-packaging-pom/" + "plugin-config.xml");
@@ -223,10 +291,11 @@ public class InstallMojoTest extends AbstractMojoTestCase {
MavenProject project = (MavenProject) getVariableValueFromObject(mojo, "project");
updateMavenProject(project);
+ MavenSession session = createMavenSession();
+ session.setProjects(Collections.singletonList(project));
+ setVariableValueToObject(mojo, "session", session);
setVariableValueToObject(mojo, "pluginContext", new ConcurrentHashMap<>());
setVariableValueToObject(mojo, "pluginDescriptor", new PluginDescriptor());
- setVariableValueToObject(mojo, "reactorProjects", Collections.singletonList(project));
- setVariableValueToObject(mojo, "session", createMavenSession());
String packaging = project.getPackaging();
@@ -248,6 +317,43 @@ public class InstallMojoTest extends AbstractMojoTestCase {
assertEquals(4, FileUtils.getFiles(new File(LOCAL_REPO), null, null).size());
}
+ public void testInstallIfPackagingIsBom() throws Exception {
+ File testPom = new File(
+ getBasedir(), "target/test-classes/unit/basic-install-test-packaging-bom/" + "plugin-config.xml");
+
+ AbstractMojo mojo = (AbstractMojo) lookupMojo("install", testPom);
+
+ assertNotNull(mojo);
+
+ MavenProject project = (MavenProject) getVariableValueFromObject(mojo, "project");
+ updateMavenProject(project);
+
+ MavenSession session = createMavenSession();
+ session.setProjects(Collections.singletonList(project));
+ setVariableValueToObject(mojo, "session", session);
+ setVariableValueToObject(mojo, "pluginContext", new ConcurrentHashMap<>());
+ setVariableValueToObject(mojo, "pluginDescriptor", new PluginDescriptor());
+
+ String packaging = project.getPackaging();
+
+ assertEquals("bom", packaging);
+
+ artifact = (InstallArtifactStub) project.getArtifact();
+
+ mojo.execute();
+
+ String groupId = dotToSlashReplacer(artifact.getGroupId());
+
+ File installedArtifact = new File(
+ getBasedir(),
+ LOCAL_REPO + groupId + "/" + artifact.getArtifactId() + "/" + artifact.getVersion() + "/"
+ + artifact.getArtifactId() + "-" + artifact.getVersion() + "." + "pom");
+
+ assertTrue(installedArtifact.exists());
+
+ assertEquals(4, FileUtils.getFiles(new File(LOCAL_REPO), null, null).size());
+ }
+
public void testBasicInstallAndCreate() throws Exception {
File testPom = new File(getBasedir(), "target/test-classes/unit/basic-install-checksum/plugin-config.xml");
@@ -261,10 +367,11 @@ public class InstallMojoTest extends AbstractMojoTestCase {
MavenSession mavenSession = createMavenSession();
updateMavenProject(project);
+ MavenSession session = createMavenSession();
+ session.setProjects(Collections.singletonList(project));
+ setVariableValueToObject(mojo, "session", session);
setVariableValueToObject(mojo, "pluginContext", new ConcurrentHashMap<>());
setVariableValueToObject(mojo, "pluginDescriptor", new PluginDescriptor());
- setVariableValueToObject(mojo, "reactorProjects", Collections.singletonList(project));
- setVariableValueToObject(mojo, "session", mavenSession);
artifact = (InstallArtifactStub) project.getArtifact();
@@ -308,10 +415,11 @@ public class InstallMojoTest extends AbstractMojoTestCase {
MavenProject project = (MavenProject) getVariableValueFromObject(mojo, "project");
updateMavenProject(project);
+ MavenSession session = createMavenSession();
+ session.setProjects(Collections.singletonList(project));
+ setVariableValueToObject(mojo, "session", session);
setVariableValueToObject(mojo, "pluginContext", new ConcurrentHashMap<>());
setVariableValueToObject(mojo, "pluginDescriptor", new PluginDescriptor());
- setVariableValueToObject(mojo, "reactorProjects", Collections.singletonList(project));
- setVariableValueToObject(mojo, "session", createMavenSession());
setVariableValueToObject(mojo, "skip", Boolean.TRUE);
artifact = (InstallArtifactStub) project.getArtifact();
@@ -341,7 +449,10 @@ public class InstallMojoTest extends AbstractMojoTestCase {
private MavenSession createMavenSession() throws NoLocalRepositoryManagerException {
MavenSession session = mock(MavenSession.class);
DefaultRepositorySystemSession repositorySession = new DefaultRepositorySystemSession();
- repositorySession.setLocalRepositoryManager(new EnhancedLocalRepositoryManagerFactory()
+ repositorySession.setLocalRepositoryManager(new EnhancedLocalRepositoryManagerFactory(
+ new DefaultLocalPathComposer(),
+ new DefaultTrackingFileManager(),
+ new DefaultLocalPathPrefixComposerFactory())
.newInstance(repositorySession, new LocalRepository(LOCAL_REPO)));
ProjectBuildingRequest buildingRequest = new DefaultProjectBuildingRequest();
buildingRequest.setRepositorySession(repositorySession);
=====================================
src/test/java/org/apache/maven/plugins/install/stubs/InstallArtifactStub.java
=====================================
@@ -74,7 +74,7 @@ public class InstallArtifactStub extends ArtifactStub {
public void addMetadata(ArtifactMetadata metadata) {
if (metadataMap == null) {
- metadataMap = new HashMap<Object, ArtifactMetadata>();
+ metadataMap = new HashMap<>();
}
ArtifactMetadata m = metadataMap.get(metadata.getKey());
@@ -85,8 +85,8 @@ public class InstallArtifactStub extends ArtifactStub {
}
}
- public Collection getMetadataList() {
- return metadataMap == null ? Collections.EMPTY_LIST : metadataMap.values();
+ public Collection<ArtifactMetadata> getMetadataList() {
+ return metadataMap == null ? Collections.emptyList() : metadataMap.values();
}
public boolean isRelease() {
=====================================
src/test/java/org/apache/maven/plugins/install/stubs/InstallBomArtifactStub.java
=====================================
@@ -0,0 +1,37 @@
+/*
+ * 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.
+ */
+package org.apache.maven.plugins.install.stubs;
+
+import org.apache.maven.artifact.handler.ArtifactHandler;
+import org.apache.maven.artifact.handler.DefaultArtifactHandler;
+
+public class InstallBomArtifactStub extends InstallArtifactStub {
+
+ public String getType() {
+ return "bom";
+ }
+
+ public ArtifactHandler getArtifactHandler() {
+ return new DefaultArtifactHandler() {
+ public String getExtension() {
+ return "pom";
+ }
+ };
+ }
+}
=====================================
src/test/java/org/apache/maven/plugins/install/stubs/InstallPomArtifactStub.java
=====================================
@@ -0,0 +1,37 @@
+/*
+ * 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.
+ */
+package org.apache.maven.plugins.install.stubs;
+
+import org.apache.maven.artifact.handler.ArtifactHandler;
+import org.apache.maven.artifact.handler.DefaultArtifactHandler;
+
+public class InstallPomArtifactStub extends InstallArtifactStub {
+
+ public String getType() {
+ return "pom";
+ }
+
+ public ArtifactHandler getArtifactHandler() {
+ return new DefaultArtifactHandler() {
+ public String getExtension() {
+ return "pom";
+ }
+ };
+ }
+}
=====================================
src/test/resources/unit/basic-install-test-packaging-bom/plugin-config.xml
=====================================
@@ -0,0 +1,35 @@
+<!--
+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.
+-->
+<project>
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-install-plugin</artifactId>
+ <configuration>
+ <project implementation="org.apache.maven.plugin.testing.stubs.MavenProjectStub">
+ <file>${basedir}/src/test/resources/unit/basic-install-test-packaging-bom/plugin-config.xml</file>
+ <packaging>bom</packaging>
+ <artifact implementation="org.apache.maven.plugins.install.stubs.InstallBomArtifactStub"/>
+ <attachedArtifacts/>
+ </project>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
=====================================
src/test/resources/unit/basic-install-test-packaging-pom/plugin-config.xml
=====================================
@@ -25,7 +25,7 @@ under the License.
<project implementation="org.apache.maven.plugin.testing.stubs.MavenProjectStub">
<file>${basedir}/src/test/resources/unit/basic-install-test-packaging-pom/plugin-config.xml</file>
<packaging>pom</packaging>
- <artifact implementation="org.apache.maven.plugins.install.stubs.InstallArtifactStub"/>
+ <artifact implementation="org.apache.maven.plugins.install.stubs.InstallPomArtifactStub"/>
<attachedArtifacts/>
</project>
</configuration>
View it on GitLab: https://salsa.debian.org/java-team/maven-install-plugin/-/compare/51704d7ddbe0b2bcc09e817f8e3366f81c27ec27...84d3608a7498c0389c0d9643f5a2a78ad04f8f2b
--
View it on GitLab: https://salsa.debian.org/java-team/maven-install-plugin/-/compare/51704d7ddbe0b2bcc09e817f8e3366f81c27ec27...84d3608a7498c0389c0d9643f5a2a78ad04f8f2b
You're receiving this email because of your account on salsa.debian.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/pkg-java-commits/attachments/20241220/ef2a9b17/attachment.htm>
More information about the pkg-java-commits
mailing list