'Artifact has not been packaged yet
I am letting Maven copy some dependency files into a specific location for a GWT project. The maven-dependency-plugin
does the job and so far it works. The only Problem is that I'm getting an error from Eclipse that says:
Artifact has not been packaged yet. When used on reactor artifact, copy should be executed after packaging: see MDEP-187.
I have tried to change the <phase>
but that did not work. How can I get rid of that error and why is it there because Maven builds as intended.
<plugins>
<plugin>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<phase>install</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>${project.basedir}/war/WEB-INF/lib</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
Solution 1:[1]
I got the same error and I solved this issue with a workaround. I have compiled and installed the project with Maven in a console outside Eclipse IDE. After I have refreshed the project inside Eclipse IDE and error has disappeared.
Solution 2:[2]
I solved by setting the plugin phase to prepare-package. I know it's still a workaround, but I think it's cleaner than compile externally.
<plugins>
[...]
<plugin>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<phase>prepare-package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
[YOUR_CONFIGURATION]
</configuration>
</execution>
</executions>
</plugin>
[...]
</plugins>
EDIT:
This is not fully solving: sometimes it works, other times not.
The final solution is to use the Lifecycle Mapping Maven Dummy Plugin through an eclipse-only maven profile:
<profile>
<id>only-eclipse</id>
<activation>
<property>
<name>m2e.version</name>
</property>
</activation>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.eclipse.m2e</groupId>
<artifactId>lifecycle-mapping</artifactId>
<version>1.0.0</version>
<configuration>
<lifecycleMappingMetadata>
<pluginExecutions>
<pluginExecution>
<pluginExecutionFilter>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<versionRange>${maven-dependency-plugin.version}</versionRange>
<goals>
<goal>copy-dependencies</goal>
</goals>
</pluginExecutionFilter>
<action>
<ignore />
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
</profile>
Solution 3:[3]
There is a solution similar to s1moner3d answer which doesn't require changes to pom.xml
file.
Go to Window > Preferences > Maven > Lifecycle Mappings and click on the Open workspace lifecycle mappings metadata button.
Than add pluginExecution
entry like in the code below. If the file is empty, copy the entire content below. You might need to change versionRange
.
<?xml version="1.0" encoding="UTF-8"?>
<lifecycleMappingMetadata>
<pluginExecutions>
<pluginExecution>
<pluginExecutionFilter>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<versionRange>2.10</versionRange>
<goals>
<goal>copy-dependencies</goal>
</goals>
</pluginExecutionFilter>
<action>
<ignore />
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
In order for this to take effect go back to Preferences and click Reload workspace lifecycle mappings metadata. Update Maven projects and / or rebuild. The error should be gone.
Useful if you cannot or don't want to modify pom.xml
for any reasons but want to stop your Eclipse m2e from executing particular goal of a particular plugin.
Solution 4:[4]
I had to wrap plugins tag under pluginManagement to make the error go away.
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>3.0.0</version>
<executions>
<execution>
<id>copy-dependencies</id>
<phase>package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>../../lib/</outputDirectory>
<overWriteReleases>false</overWriteReleases>
<overWriteSnapshots>false</overWriteSnapshots>
<overWriteIfNewer>true</overWriteIfNewer>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</pluginManagement>
Solution 5:[5]
I used this answer to fix the problem. That 2017 update to m2eclipse means you don't need to use the pluginManagment
xml as in s1moner3d's answer, and so that gets rid of the "POM not found" warning I got for the 'lifecycle-mapping' artifactId
tag when I included it.
To summarize:
You don't need a
pluginManagment
block for org.eclipse.m2eAdd a
<?m2e ignore?>
tag in your<execution>
tag(s) :<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-dependency-plugin</artifactId> <version>3.2.0</version> <executions> <execution> <?m2e ignore?> <phase>package</phase> <goals> <goal>copy-dependencies</goal> </goals> <configuration> ...{your configuration} ... </configuration> </execution> </executions> </plugin>
Solution 6:[6]
For those returning to this question, it may be useful to report seeing the same problem in Eclipse against maven-dependency-plugin
version 2.8. This was in the package
phase:
Artifact has not been packaged yet. When used on reactor artifact, copy should be executed after packaging: see MDEP-187. (org.apache.maven.plugins:maven-dependency-plugin:2.8:copy:copy-proguard:package)
In this case upgrading to 3.1.1 solved the problem:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>3.1.1</version>
<executions>
<execution>
<id>copy-proguard</id>
<phase>package</phase>
<goals>
<goal>copy</goal>
</goals>
...
Solution 7:[7]
This issue related to eclipse IDE:
Solution is to update M2E Connector for the maven-dependency-plugin
Steps :
Help ---> Eclipse Marketplace.. then update the plugin.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Lii |
Solution 2 | |
Solution 3 | Lii |
Solution 4 | |
Solution 5 | Mark59 |
Solution 6 | df778899 |
Solution 7 | Omar Zakaria |