神器尚未打包

时间:2022-04-22 23:59:47

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:

我让Maven将一些依赖文件复制到GWT项目的特定位置。 maven-dependency-plugin完成了这项工作,到目前为止它的工作原理。唯一的问题是我从Eclipse那里得到一个错误:

Artifact has not been packaged yet. When used on reactor artifact, copy should be executed after packaging: see MDEP-187.

神器尚未打包。当用于反应器工件时,应在包装后执行复制:参见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.

我试图改变 <阶段> ,但这不起作用。我怎样才能摆脱那个错误,为什么它会出现,因为Maven按照预期构建。

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

4 个解决方案

#1


14  

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 eclise ide and error has disappeared.

我得到了同样的错误,我解决了这个问题的解决方法。我已经在eclipse ide之外的控制台中使用maven编译和安装了项目。我刷新了eclise ide中的项目并且错误消失了。

#2


7  

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.

我通过将插件阶段设置为prepare-package来解决。我知道它仍然是一种解决方法,但我认为它比外部编译更清晰。

<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:

最终的解决方案是通过仅限eclipse的maven配置文件使用Lifecycle Mapping Maven Dummy插件:

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

#3


3  

There is a solution similar to @s1moner3d answer which doesn't require changes to pom.xml file.

有一个类似于@ s1moner3d的解决方案,它不需要更改pom.xml文件。

Go to Window -> Preferences -> Maven -> Lifecycle Mappings and click on the Open workspace lifecycle mappings metadata 神器尚未打包

转到Window - > Preferences - > Maven - > Lifecycle Mappings,然后单击Open workspace lifecycle mappings metadata

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

比添加“pluginExecution”条目,如下面的代码。如果文件为空,请复制下面的整个内容。您可能需要更改“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.

要使其生效,请返回“首选项”并单击“重新加载工作空间生命周期映射”元数据。更新maven项目和/或重建。错误应该消失了。

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.

如果您因为任何原因不能或不想修改pom.xml但想要阻止您的eclipse m2e执行特定插件的特定目标,则非常有用。

#4


2  

I had to wrap plugins tag under pluginManagement to make the error go away.

我不得不在pluginManagement下包装plugins标签以使错误消失。

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

#1


14  

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 eclise ide and error has disappeared.

我得到了同样的错误,我解决了这个问题的解决方法。我已经在eclipse ide之外的控制台中使用maven编译和安装了项目。我刷新了eclise ide中的项目并且错误消失了。

#2


7  

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.

我通过将插件阶段设置为prepare-package来解决。我知道它仍然是一种解决方法,但我认为它比外部编译更清晰。

<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:

最终的解决方案是通过仅限eclipse的maven配置文件使用Lifecycle Mapping Maven Dummy插件:

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

#3


3  

There is a solution similar to @s1moner3d answer which doesn't require changes to pom.xml file.

有一个类似于@ s1moner3d的解决方案,它不需要更改pom.xml文件。

Go to Window -> Preferences -> Maven -> Lifecycle Mappings and click on the Open workspace lifecycle mappings metadata 神器尚未打包

转到Window - > Preferences - > Maven - > Lifecycle Mappings,然后单击Open workspace lifecycle mappings metadata

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

比添加“pluginExecution”条目,如下面的代码。如果文件为空,请复制下面的整个内容。您可能需要更改“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.

要使其生效,请返回“首选项”并单击“重新加载工作空间生命周期映射”元数据。更新maven项目和/或重建。错误应该消失了。

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.

如果您因为任何原因不能或不想修改pom.xml但想要阻止您的eclipse m2e执行特定插件的特定目标,则非常有用。

#4


2  

I had to wrap plugins tag under pluginManagement to make the error go away.

我不得不在pluginManagement下包装plugins标签以使错误消失。

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