Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
798 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 Answer

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...