Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
744 views
in Technique[技术] by (71.8m points)

java - How to create zip target instead of jar in maven?

Can someone please help me in creating a zip target instead of jar in maven. I tried several ways but couldn't progress. Given descriptor file in the assembly path is as follows:

<assembly>
<formats>
    <format>zip</format>
</formats>
<fileSets>
    <fileSet>
        <directory>src/main</directory>
    </fileSet>
</fileSets>
</assembly>

The assembly plugin section in my pom file is as follows:

<build>
    <plugins>
        <plugin>
            <artifactId>maven-assembly-plugin</artifactId>
            <configuration>
                <descriptors>
                    <descriptor>src/assembly/descriptor.xml</descriptor>
                </descriptors>
            </configuration>
        </plugin>
    </plugins>
</build>

Final Output:

[INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ sql1 ---
[INFO] Building jar: C:Divakarmvn_projectsql1argetsql1-0.1.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

You need to bind the plugin to a particular build lifecycle phase via execution like this:

<executions> 
  <execution>
    <id>make-zip</id>
    <phase>package</phase>
    <goals>
      <goal>single</goal>
    </goals>
  </execution>
</executions>

Afterwards you can do it via mvn clean package.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

56.8k users

...