Maven: The packaging for this project did not assign a file to the build artifact

前端 未结 8 1565
误落风尘
误落风尘 2020-11-30 18:25

I\'m using Maven 3.0.3 on Mac 10.6.6. I have a JAR project and when I run the command \"mvn clean install:install\", I\'m getting the error,

[ERROR] Failed         


        
相关标签:
8条回答
  • 2020-11-30 18:45

    This error shows up when using the maven-install-plugin version 3.0.0-M1 (or similar)

    As already mentioned above and also here the following plug-in version works:

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-install-plugin</artifactId>
            <version>2.5.2</version>
        </plugin>
    
    0 讨论(0)
  • 2020-11-30 18:45

    While @A_Di-Matteo answer does work for non multimodule I have a solution for multimodules.

    The solution is to override every plugin configuration so that it binds to the phase of none with the exception of the jar/war/ear plugin and of course the deploy plugin. Even if you do have a single module my rudimentary tests show this to be a little faster (for reasons I don't know) performance wise.

    Thus the trick is to make a profile that does the above that is activated when you only want to deploy.

    Below is an example from one of my projects which uses the shade plugin and thus I had to re-override the jar plugin not to overwrite:

        <profile>
          <id>deploy</id>
          <activation>
            <property>
              <name>buildStep</name>
              <value>deploy</value>
            </property>
          </activation>
          <build>
            <plugins>
              <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <executions>
                  <execution>
                    <id>default-compile</id>
                    <phase>none</phase>
                  </execution>
                  <execution>
                    <id>default-testCompile</id>
                    <phase>none</phase>
                  </execution>
                  <execution>
                    <id>test-compile</id>
                    <phase>none</phase>
                  </execution>
                </executions>
              </plugin>
              <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <executions>
                  <execution>
                    <id>default-test</id>
                    <phase>none</phase>
                  </execution>
                </executions>
              </plugin>
              <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-install-plugin</artifactId>
                <executions>
                  <execution>
                    <id>default-install</id>
                    <phase>none</phase>
                  </execution>
                </executions>
              </plugin>
              <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-resources-plugin</artifactId>
                <executions>
                  <execution>
                    <id>default-resources</id>
                    <phase>none</phase>
                  </execution>
                  <execution>
                    <id>default-testResources</id>
                    <phase>none</phase>
                  </execution>
                </executions>
              </plugin>
              <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-shade-plugin</artifactId>
                <executions>
                  <execution>
                    <id>default</id>
                    <phase>none</phase>
                  </execution>
                </executions>
              </plugin>
              <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <executions>
                  <execution>
                    <id>default-jar</id>
                    <configuration>
                      <forceCreation>false</forceCreation>
                    </configuration>
                  </execution>
                </executions>
              </plugin>
            </plugins>
          </build>
        </profile>
    

    Now if I run mvn deploy -Pdeploy it will only run the jar and deploy plugins.

    How you can figure out which plugins you need to override is to run deploy and look at the log to see which plugins are running. Make sure to keep track of the id of the plugin configuration which is parens after the name of the plugin.

    0 讨论(0)
  • 2020-11-30 18:46

    This reply is on a very old question to help others facing this issue.

    I face this failed error while I were working on my Java project using IntelliJ IDEA IDE.

    Failed to execute goal org.apache.maven.plugins:maven-install-plugin:2.4:install (default-cli) on project getpassword: The packaging for this project did not assign a file to the build artifact
    

    this failed happens, when I choose install:install under Plugins - install, as pointed with red arrow in below image.

    Once I run the selected install under Lifecycle as illustrated above, the issue gone, and my maven install compile build successfully.

    0 讨论(0)
  • 2020-11-30 18:46

    I had the same issue but I executed mvn install initially (not install:install as it was mentioned earlier).

    The solution is to include:

     <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-install-plugin</artifactId>
            <version>2.5.2</version>
     </plugin>
    

    Into plugin management section.

    0 讨论(0)
  • 2020-11-30 18:48

    I have same issue. Error message for me is not complete. But in my case, I've added generation jar with sources. By placing this code in pom.xml:

    <build> 
        <pluginManagement>
            <plugins>
                <plugin>
                    <artifactId>maven-source-plugin</artifactId>
                    <version>2.1.2</version>
                    <executions>
                        <execution>
                            <phase>deploy</phase>
                            <goals>
                                <goal>jar</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>
            </plugins>
        </pluginManagement>
    </build>
    

    So in deploy phase I execute source:jar goal which produces jar with sources. And deploy ends with BUILD SUCCESS

    0 讨论(0)
  • 2020-11-30 19:00

    I don't know if this is the answer or not but it might lead you in the right direction...

    The command install:install is actually a goal on the maven-install-plugin. This is different than the install maven lifecycle phase.

    Maven lifecycle phases are steps in a build which certain plugins can bind themselves to. Many different goals from different plugins may execute when you invoke a single lifecycle phase.

    What this boils down to is the command...

    mvn clean install
    

    is different from...

    mvn clean install:install
    

    The former will run all goals in every cycle leading up to and including the install (like compile, package, test, etc.). The latter will not even compile or package your code, it will just run that one goal. This kinda makes sense, looking at the exception; it talks about:

    StarTeamCollisionUtil: The packaging for this project did not assign a file to the build artifact

    Try the former and your error might just go away!

    0 讨论(0)
提交回复
热议问题