disable the execution: default-jar

非 Y 不嫁゛ 提交于 2019-12-17 09:50:58

问题


i am using maven assembly plugin to pack a jar file. But when i run mvn package, maven always trigger the [jar:jar {execution: default-jar}] to create a default jar file. So i will have 2 jar files (one created by assembly plugin and one created by maven jar which i dont want to be created). How can i turn off the execution: default-jar.

in my pom.xml, i am using : <packaging>jar</packaging>. i dont want to change it to <packaging>pom</packaging>.


回答1:


(...) So i will have 2 jar files (one created by assembly plugin and one created by maven jar which i dont want to be created).

Looks like you're doing pretty complicated things. Maybe Maven is not the right tool in your case.

How can I turn off the execution: default-jar.

You can set the <phase> of the corresponding execution to something unknown, like none:

  <plugin>
    <artifactId>maven-jar-plugin</artifactId>
    <version>2.3.1</version>
    <executions>
      <execution>
        <id>default-jar</id>
        <phase>none</phase>
      </execution>
    </executions>
  </plugin>
  <plugin>
    <artifactId>maven-assembly-plugin</artifactId>
    <version>2.2</version>
    <configuration>
      <descriptorRefs>
        <descriptorRef>jar-with-dependencies</descriptorRef>
      </descriptorRefs>
    </configuration>
    <executions>
      <execution>
        <id>make-assembly</id>
        <!-- this is used for inheritance merges -->
        <phase>package</phase>
        <!-- append to the packaging phase. -->
        <goals>
          <goal>single</goal>
          <!-- goals == mojos -->
        </goals>
      </execution>
    </executions>
  </plugin>

This seems to work as long as you're providing something else to be installed, like an assembly (I only tested install). But of course, this is a hack.




回答2:


While not a direct answer to the question, you could exclude the jar created by maven jar using <useProjectArtifact>false</useProjectArtifact>



来源:https://stackoverflow.com/questions/4101750/disable-the-execution-default-jar

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!