如何将一个pom生成的多个jar上传到nexus存储库中

时间:2017-04-10 07:40:10

标签: maven pom.xml nexus

我有一个pom文件,我根据包生成了两个罐子,但我想在nexus repo中上传两个罐子。我只能看到一个罐子正在复制到nexus仓库,而不是另一个。

的pom.xml

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.my</groupId>
<artifactId>Shared</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<url>http://maven.apache.org</url>

<properties>
    <project.build.directory>.</project.build.directory>
    <localRepo>C:/Users/myuser/.m2/repository1</localRepo>
</properties>



<build>
    <!--source directory pick the resources to be build. -->
    <sourceDirectory>source</sourceDirectory>

    <plugins>
        <!--maven compiler plugin -->
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>2.3.2</version>
            <configuration>
                <source>1.6</source>
                <target>1.6</target>
            </configuration>
        </plugin>

        <!--this plugin is to generate the manifest file -->
        <!-- <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-jar-plugin</artifactId> 
            <version>2.4</version> <configuration> <archive> <manifest> 
            <addClasspath>true</addClasspath> </manifest> <manifestEntries> <Built-By>my-org</Built-By> 
            </manifestEntries> </archive> </configuration> </plugin> -->
        <!-- this plugin to create the multiple jars with inclusion or exclusion 
            of the files -->
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-jar-plugin</artifactId>
            <version>2.4</version>
            <executions>
                <execution>
                    <id>default-jar</id>
                    <phase>none</phase>
                </execution>
                <execution>
                    <id>build-Castor-jar</id>
                    <goals>
                        <goal>jar</goal>
                    </goals>
                    <phase>prepare-package</phase>
                    <configuration>
                        <archive>
                            <manifest>

                                <addClasspath>true</addClasspath>
                            </manifest>
                            <manifestEntries>
                                <Built-By>my-org</Built-By>
                            </manifestEntries>
                        </archive>
                        <includes>
                            <include>com/my/domain/BigDecimalHandler.class</include>
                            <include>com/my/domain/CalendarFieldHandler.class</include>

                            <include>com/my/domain/TimeZoneFieldHandler.class</include>

                        </includes>
                        <finalName>Castor-${version}</finalName>
                        <!-- <outputDirectory>${localRepo}/com/my/Castor/${version}/</outputDirectory> -->
                    </configuration>
                </execution>
                <execution>
                    <id>build-Shared-jar</id>
                    <phase>prepare-package</phase>
                    <goals>
                        <goal>jar</goal>
                    </goals>
                    <configuration>
                        <archive>
                            <manifest>

                                <addClasspath>true</addClasspath>
                            </manifest>
                            <manifestEntries>
                                <Built-By>my-org</Built-By>
                            </manifestEntries>
                        </archive>
                        <excludes>
                            <exclude>com/my/domain/BigDecimalHandler.class</exclude>
                            <exclude>com/my/domain/CalendarFieldHandler.class</exclude>

                            <exclude>com/my/domain/TimeZoneFieldHandler.class</exclude>

                        </excludes>
                        <finalName>Shared-${version}</finalName>

                    </configuration>
                </execution>
            </executions>
        </plugin>



    </plugins>
</build>
    <repositories>
        <repository>
            <id>central</id>
            <name>Maven Plugin Repository</name>
            <url>http://nxrepository/nexus/content/groups/public</url>
        </repository>

       

1 个答案:

答案 0 :(得分:0)

您可以使用deploy:deploy-file目标来部署其他工件。但是你应该知道,从一个项目中建立两个罐子是违反Maven标准的。在您的情况下,您最好在项目中定义包含不同包的两个模块。