eclipse Artifact 尚未打包

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/30642630/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 05:32:52  来源:igfitidea点击:

Artifact has not been packaged yet

eclipsemaven

提问by displayname

I am letting Maven copy some dependency files into a specific location for a GWT project. The maven-dependency-plugindoes 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.

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.

我试图改变,<phase>但没有奏效。我怎样才能摆脱那个错误,为什么会出现这个错误,因为 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>

采纳答案by jkings

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 中的项目并且错误消失后。

回答by s1moner3d

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 Pluginthrough an eclipse-onlymaven profile:

最后的解决方案是通过eclipse-onlymaven profile使用Lifecycle Mapping Maven Dummy Plugin

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

回答by indusBull

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>

回答by ixi

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 screenshot

转到 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 执行特定插件的特定目标,则很有用。

回答by df778899

For those returning to this question, it may be useful to report seeing the same problem in Eclipse against maven-dependency-pluginversion 2.8. This was in the packagephase:

对于那些回到这个问题的人来说,报告在 Eclipse 中针对maven-dependency-plugin2.8 版看到相同的问题可能会很有用。这是在package阶段:

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)

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:

在这种情况下升级到 3.1.1 解决了问题:

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