Maven Install Plugin fails: Could not resolve dependencies

1.1k views Asked by At

I'm trying to install company internal local dependencies into the .m2 repo; with the maven install plugin, before building the ear.

For this example I use org.apache dependencies, so that everyone can rebuild it for testing independently from the internal company libs

When I run mvn clean install the plugin goal install-file is not executed correct. It produces the error message, that it could not resolve dependencies, which is normal, because they are not installed to local repo before.

However when I run:

  1. mvn clean
  2. mvn install

separately it works like expected and installs the dependencies before package, etc.

[INFO] Installing C:\Windows\TEMP\mvninstall6283951176974866121.pom to C:\Users\XYZ\.m2\repository\org\apache\example\httpcore\5.1.3\httpcore-5.1.3.pom
[INFO] 
[INFO] --- maven-install-plugin:2.5.1:install-file (install-jar-2) @ install_multiple_local_dependencies ---
[INFO] Installing C:\_work\_workspaces\ReportserviceEAR\install_multiple_local_dependencies\libs\httpclient5-5.1.3.jar to C:\Users\XYZ\.m2\repository\org\apache\example\httpclient\5.1.3\httpclient-5.1.3.jar
[INFO] Installing C:\Windows\TEMP\mvninstall15901936683612080025.pom to C:\Users\XYZ\.m2\repository\org\apache\example\httpclient\5.1.3\httpclient-5.1.3.pom
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 4.757 s
[INFO] Finished at: 2022-04-12T12:06:15+02:00
[INFO] Final Memory: 9M/40M
[INFO] ------------------------------------------------------------------------

I want to archive this with only one command: mvn clean install is this possible or do I need to run the clean phase explicitly?

Thanks in advance for any help.

Setup

  • Maven 3.8.4
  • Java 1.8
  • Maven install plugin 2.5.1

Example POM:

<project xmlns="http://maven.apache.org/POM/4.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven- 
4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.example</groupId>
    <artifactId>install_multiple_local_dependencies</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>Example Project</name>
    <description>Install multiple dependencies</description>
    <properties>
        <maven.compiler.target>1.8</maven.compiler.target>
        <maven.compiler.source>1.8</maven.compiler.source>
    </properties>
    <dependencies>
        <dependency>
            <groupId>org.apache.example</groupId>
            <artifactId>httpcore</artifactId>
            <version>5.1.3</version>
        </dependency>
        <dependency>
            <groupId>org.apache.example</groupId>
            <artifactId>httpclient</artifactId>
            <version>5.1.3</version>
        </dependency>
    </dependencies>
    <build>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-install-plugin</artifactId>
                    <version>2.5.1</version>
                    <executions>
                        <execution>
                            <id>install-jar-1</id>
                            <goals>
                                <goal>install-file</goal>
                            </goals>
                            <phase>clean</phase>
                            <configuration>
                                <groupId>org.apache.example</groupId>
                                <artifactId>httpcore</artifactId>
                                <version>5.1.3</version>
                                <packaging>jar</packaging>
                                <file>${basedir}/libs/httpcore5-5.1.3.jar</file>
                                <generatePom>true</generatePom>
                            </configuration>
                        </execution>
                        <execution>
                            <id>install-jar-2</id>
                            <goals>
                                <goal>install-file</goal>
                            </goals>
                            <phase>clean</phase>
                            <configuration>
                                <groupId>org.apache.example</groupId>
                                <artifactId>httpclient</artifactId>
                                <version>5.1.3</version>
                                <packaging>jar</packaging>
                                <file>${basedir}/libs/httpclient5-5.1.3.jar</file>
                                <generatePom>true</generatePom>
                            </configuration>
                        </execution>
                    </executions>
                </plugin>
            </plugins>
        </pluginManagement>
    </build>
</project>

Error Message:

$ mvn clean install
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Example Project 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-clean- 
plugin/2.5/maven-clean-plugin-2.5.pom
Downloaded: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-clean- 
plugin/2.5/maven-clean-plugin-2.5.pom (4 KB at 6.9 KB/sec)
Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven- 
plugins/22/maven-plugins-22.pom
Downloaded: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven- 
plugins/22/maven-plugins-22.pom (13 KB at 181.9 KB/sec)
Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/maven-parent/21/maven- 
parent-21.pom
Downloaded: https://repo.maven.apache.org/maven2/org/apache/maven/maven-parent/21/maven- 
parent-21.pom (26 KB at 352.6 KB/sec)
Downloading: https://repo.maven.apache.org/maven2/org/apache/apache/10/apache-10.pom
Downloaded: https://repo.maven.apache.org/maven2/org/apache/apache/10/apache-10.pom (15 KB 
at 
206.5 KB/sec)
Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-clean- 
plugin/2.5/maven-clean-plugin-2.5.jar
Downloaded: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-clean- 
plugin/2.5/maven-clean-plugin-2.5.jar (25 KB at 338.8 KB/sec)
Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-install- 
plugin/2.5.1/maven-install-plugin-2.5.1.pom
Downloaded: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-install- 
plugin/2.5.1/maven-install-plugin-2.5.1.pom (8 KB at 106.2 KB/sec)
Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven- 
plugins/24/maven-plugins-24.pom
Downloaded: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven- 
plugins/24/maven-plugins-24.pom (11 KB at 162.3 KB/sec)
Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/maven-parent/23/maven- 
parent-23.pom
Downloaded: https://repo.maven.apache.org/maven2/org/apache/maven/maven-parent/23/maven- 
parent-23.pom (32 KB at 402.8 KB/sec)
Downloading: https://repo.maven.apache.org/maven2/org/apache/apache/13/apache-13.pom
Downloaded: https://repo.maven.apache.org/maven2/org/apache/apache/13/apache-13.pom (14 KB 
at 
206.8 KB/sec)
Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-install- 
plugin/2.5.1/maven-install-plugin-2.5.1.jar
Downloaded: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-install- 
plugin/2.5.1/maven-install-plugin-2.5.1.jar (33 KB at 382.3 KB/sec)
Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven- 
resources- 
plugin/2.6/maven-resources-plugin-2.6.pom
Downloaded: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-resources- 
plugin/2.6/maven-resources-plugin-2.6.pom (8 KB at 120.1 KB/sec)
Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven- 
plugins/23/maven-plugins-23.pom
Downloaded: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven- 
plugins/23/maven-plugins-23.pom (9 KB at 123.0 KB/sec)
Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/maven-parent/22/maven- 
parent-22.pom
Downloaded: https://repo.maven.apache.org/maven2/org/apache/maven/maven-parent/22/maven- 
parent-22.pom (30 KB at 363.1 KB/sec)
Downloading: https://repo.maven.apache.org/maven2/org/apache/apache/11/apache-11.pom
Downloaded: https://repo.maven.apache.org/maven2/org/apache/apache/11/apache-11.pom (15 KB 
at 
222.5 KB/sec)
Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven- 
resources- 
plugin/2.6/maven-resources-plugin-2.6.jar
Downloaded: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-resources- 
plugin/2.6/maven-resources-plugin-2.6.jar (29 KB at 343.2 KB/sec)
Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-compiler- 
plugin/3.1/maven-compiler-plugin-3.1.pom
Downloaded: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-compiler- 
plugin/3.1/maven-compiler-plugin-3.1.pom (10 KB at 155.8 KB/sec)
Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-compiler- 
plugin/3.1/maven-compiler-plugin-3.1.jar
Downloaded: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-compiler- 
plugin/3.1/maven-compiler-plugin-3.1.jar (42 KB at 499.3 KB/sec)
Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-surefire- 
plugin/2.12.4/maven-surefire-plugin-2.12.4.pom
Downloaded: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-surefire- 
plugin/2.12.4/maven-surefire-plugin-2.12.4.pom (11 KB at 155.0 KB/sec)
Downloading: 
https://repo.maven.apache.org/maven2/org/apache/maven/surefire/surefire/2.12.4/surefire- 
2.12.4.pom
Downloaded: 
https://repo.maven.apache.org/maven2/org/apache/maven/surefire/surefire/2.12.4/surefire- 
2.12.4.pom (14 KB at 204.0 KB/sec)
Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-surefire- 
plugin/2.12.4/maven-surefire-plugin-2.12.4.jar
Downloaded: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-surefire- 
plugin/2.12.4/maven-surefire-plugin-2.12.4.jar (30 KB at 431.1 KB/sec)
Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-jar- 
plugin/2.4/maven-jar-plugin-2.4.pom
Downloaded: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-jar- 
plugin/2.4/maven-jar-plugin-2.4.pom (6 KB at 71.2 KB/sec)
Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-jar- 
plugin/2.4/maven-jar-plugin-2.4.jar
Downloaded: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-jar- 
plugin/2.4/maven-jar-plugin-2.4.jar (34 KB at 420.6 KB/sec)
Downloading: 
https://repo.maven.apache.org/maven2/org/apache/example/httpcore/5.1.3/httpcore- 
5.1.3.pom
[WARNING] The POM for org.apache.example:httpcore:jar:5.1.3 is missing, no dependency 
information available
Downloading: 
https://repo.maven.apache.org/maven2/org/apache/example/httpckient/5.1.3/httpckient- 
5.1.3.pom
[WARNING] The POM for org.apache.example:httpckient:jar:5.1.3 is missing, no dependency 
information available
Downloading: 
https://repo.maven.apache.org/maven2/org/apache/example/httpcore/5.1.3/httpcore- 
5.1.3.jar
Downloading: 
https://repo.maven.apache.org/maven2/org/apache/example/httpckient/5.1.3/httpckient- 
5.1.3.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3.323 s
[INFO] Finished at: 2022-04-12T11:31:07+02:00
[INFO] Final Memory: 9M/40M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project install_multiple_local_dependencies: Could not 
resolve dependencies for project 
com.example:install_multiple_local_dependencies:jar:0.0.1- 
SNAPSHOT: The following artifacts could not be resolved: 
org.apache.example:httpcore:jar:5.1.3, org.apache.example:httpckient:jar:5.1.3: Could not 
find 
artifact org.apache.example:httpcore:jar:5.1.3 in central 
(https://repo.maven.apache.org/maven2) -> [Help 1]
0

There are 0 answers