Reputation: 23
my project is a very simple example because I removed all your code to try to find the problem by running the command "mvn dependency: copy -Dcopy.version = 0.0.1-SNAPSHOT".
The point is, I need to package projects to publish .jar on Google Cloud.
Here is the description of the POM´s:
Project: app-java/pom.xml
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.7.RELEASE</version>
<relativePath />
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>br.com.example</groupId>
<artifactId>ticket</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>pom</packaging>
<name>xxxx</name>
<url>xxxxxr</url>
<description>xxxxxx</description>
<properties>
</properties>
<modules>
<module>app</module>
</modules>
<profiles>
<profile>
<id>dev</id>
<modules>
<module>api</module>
</modules>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<profile.id>dev</profile.id>
<downloadSources>true</downloadSources>
<downloadJavadocs>true</downloadJavadocs>
</properties>
</profile>
<profile>
<id>test</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<profile.id>test</profile.id>
<downloadSources>true</downloadSources>
<downloadJavadocs>true</downloadJavadocs>
</properties>
</profile>
<profile>
<id>all</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<profile.id>all</profile.id>
<downloadSources>true</downloadSources>
<downloadJavadocs>true</downloadJavadocs>
</properties>
</profile>
</profiles>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.0</version>
</plugin>
</plugins>
</pluginManagement>
</build>
Project: app/pom.xml
<parent>
<groupId>br.com.example</groupId>
<artifactId>ticket</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>app</artifactId>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>3.1.1</version>
<executions>
<execution>
<id>copy-dependencies</id>
<phase>package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>br.com.example</groupId>
<artifactId>app</artifactId>
<type>jar</type>
<overWrite>true</overWrite>
<outputDirectory>target/deploy</outputDirectory>
<destFileName>app.jar</destFileName>
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
Commands executed:
mvn -B versions:set -f app-java/pom.xml -DallowSnapshots=true -DnewVersion=0.0.1-SNAPSHOT -Pall
mvn clean -f app-java/pom.xml install -Pall -Dmaven.application.buildNumber=12
mvn dependency:copy -Dcopy.version=0.0.1-SNAPSHOT
Response:
app-java\app>mvn dependency:copy -Dcopy.version=0.0.1-SNAPSHOT
[INFO] Scanning for projects...
[INFO]
[INFO] -------------------------< br.com.example:app >--------------------------
[INFO] Building app 0.0.1-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-dependency-plugin:3.1.1:copy (default-cli) @ app ---
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.632 s
[INFO] Finished at: 2019-08-19T22:16:17-03:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-dependency-plugin:3.1.1:copy (default-cli) on project app: **Either artifact or artifactItems is required** -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
mvn dependency:copy -Dcopy.version=0.0.1-SNAPSHOT
Upvotes: 2
Views: 7462
Reputation: 1736
depending what you are doing, if you run mvn install
the execution part will be automatically executed and you do not have to run 'mvn dependency:copy'
if you want to run mvn dependency:copy
separately, i.e. after running mvn package
, then remove execution part. Now it will not be picked up automatically, you have to add mvn dependency: copy
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>3.1.1</version>
<configuration>
<artifactItems>
<artifactItem>
<groupId>br.com.example</groupId>
<artifactId>app</artifactId>
<type>jar</type>
<overWrite>true</overWrite>
<outputDirectory>target/deploy</outputDirectory>
<destFileName>app.jar</destFileName>
</artifactItem>
</artifactItems>
</configuration>
</plugin>
</plugins>
Upvotes: 0
Reputation: 35843
You configured the execution of dependency:copy-dependencies
, but you also call dependency:copy
on command line. This does not have a configuration in the POM and therefore misses the artifactItems entries.
Upvotes: 2