44

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>
Melebius
  • 6,183
  • 4
  • 39
  • 52
Stefan Falk
  • 23,898
  • 50
  • 191
  • 378
  • 2
    https://issues.apache.org/jira/browse/MDEP-187 still seems active. Maybe you can ask for a workaround there? – Wim Deblauwe Jun 04 '15 at 12:40
  • 1
    @WimDeblauwe Created 12/Nov/08; Priority: Major ... well that's sad.. but thanks for the hint! – Stefan Falk Jun 04 '15 at 14:43
  • Possible duplicate of [Artifact has not been packaged yet - maven-dependency-plugin](http://stackoverflow.com/questions/26101135/artifact-has-not-been-packaged-yet-maven-dependency-plugin) – BuZZ-dEE Apr 26 '17 at 11:26
  • 1
    worked for me , but wondering is it the best solution – abhi Sep 06 '17 at 11:23
  • I know this problem has been years. but I recently had this issues as well, and it is not specific for eclipse. Eventually, changing the `phase` from `generate-resources` to `prepare-package` solved it (I know your case id different but it worth to try different phases to see if it will unblock you). – Zzz... Jul 28 '23 at 14:48

7 Answers7

37

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.

Lii
  • 11,553
  • 8
  • 64
  • 88
jkings
  • 394
  • 4
  • 4
  • This question is kind of old so I cannot try this out anymore. Since you have some up-votes I assume your solution works which is why I am going to accept this answer. – Stefan Falk Jul 19 '17 at 11:42
  • The problem seems to be still alive with "Maven Integration for Eclipse JDT APT" 1.5.3 and/or maven-resources-plugin 3.1.0. a "Run As Maven clean" seems to be a workaround for me. – ngong Jan 06 '20 at 14:17
  • This issues is related with IDE. as my case, i use IntelliJ IDEA. i resolve this issues by unchecked Resolve Workspace artifacts button – zhao yufei Feb 18 '20 at 00:20
14

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. screenshot

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.

Lii
  • 11,553
  • 8
  • 64
  • 88
ixi
  • 441
  • 5
  • 10
  • It works for me. But there is a missing tag in the given XML. You can add `` after `` – Q Q Jul 03 '18 at 12:48
12

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>
s1moner3d
  • 1,141
  • 2
  • 16
  • 35
11

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>
indusBull
  • 1,834
  • 5
  • 27
  • 39
  • I thinked it worked, but it just prevents the inclusion of this plugin :-/ – Laloi Oct 22 '18 at 14:48
  • The copy-dependencies never executes when wrapped in . It gets rid of the error but have to remove to get the dependencies to copy using the mvn CLI. – Ens Jan 29 '19 at 17:40
  • This does work but what he is missing is that you have to re-add the plugin outside of so add org.apache.maven.plugins maven-dependency-plugin after and before – steve lane Jan 09 '20 at 14:11
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:

  1. You don't need a pluginManagment block for org.eclipse.m2e

  2. Add 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>
    

https://www.eclipse.org/m2e/documentation/release-notes-17.html#new-syntax-for-specifying-lifecycle-mapping-metadata

MarkUs
  • 101
  • 1
  • 3
1

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>
            ...
df778899
  • 10,703
  • 1
  • 24
  • 36
  • I came here looking for a solution to the same problem. My plugin was already set to 3.1.1; wasn't working. – trash80 Feb 24 '21 at 20:31
0

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.

Omar Zakaria
  • 51
  • 1
  • 4