简体   繁体   中英

maven - To publish jar and ant zip file to the repository

I am using the following maven file. He the jar(artifact-1.0.jar) alone is getting published to repository. But I want to pblish the zip file(project1.zip) as well. Can anyone please help in fixing this?

http://maven.apache.org/xsd/maven-4.0.0.xsd">

<modelVersion>4.0.0</modelVersion>

<groupId>com.java</groupId>
<artifactId>artifact</artifactId>
<packaging>jar</packaging>
<version>1.0</version>

<name>project1</name>

<build>
<sourceDirectory>src/main/java</sourceDirectory>
<resources>
  <resource>
    <directory>src/main/resources</directory>
  </resource>
</resources>
<testSourceDirectory>src/test/java</testSourceDirectory>

<plugins>
  <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-antrun-plugin</artifactId>
            <version>1.7</version>
            <executions>
                <execution>
                    <id>create-archive-in-archive-ant</id>
                    <goals>
                        <goal>run</goal>
                    </goals>
                    <phase>package</phase>
                    <configuration>
                        <target name="bundle">
                            //
                            //ant task to create zip file
                            //
                            <zip zipfile="target/project1.zip" basedir="${target-content}" />
                        </target>
                    </configuration>
                </execution>
            </executions>
            <dependencies>
                <dependency>
                    <groupId>ant-contrib</groupId>
                    <artifactId>ant-contrib</artifactId>
                    <version>1.0b3</version>
                    <exclusions>
                        <exclusion>
                            <groupId>ant</groupId>
                            <artifactId>ant</artifactId>
                        </exclusion>
                    </exclusions>
                </dependency>
                <dependency>
                    <groupId>org.apache.ant</groupId>
                    <artifactId>ant-nodeps</artifactId>
                    <version>1.8.1</version>
                </dependency>
            </dependencies>
        </plugin>

</plugins>
</build>

Use the assembly plugin instead. While it doesn't give you all the options of building a ZIP archive manually, it does have a couple of neat tricks like it will figure out all important files automatically, so you can't accidentally miss anything.

It will also "attach the created assembly to the project so that it will be uploaded into the repository on the install and deploy goals."

This page explains how to use it .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM