maven-deploy-plugin没有执行它的执行

时间:2016-06-01 05:48:56

标签: maven maven-deploy-plugin

我需要从我的项目本身部署自定义jar,我将使用默认执行再覆盖两次maven-deploy-plugin。下面是我的pom.xml,其中包含我用于部署的distributionManagement和maven-deploy-plugin。

<groupId>mycompany</groupId>
<artifactId>myproject</artifactId>
<packaging>jar</packaging>

<distributionManagement>
    <repository>
        <id>temp</id>
        <name>Release Repository</name>
        <url>http://localhost:8000/nexus/content/repositories/temp/</url>
    </repository>
</distributionManagement>

<dependencies>
    <dependency>
        some dependency
    </dependency>

    <dependency>
        some dependency
    </dependency>

    <dependency>
        some dependency
    </dependency>
</dependencies>
<build>
    <plugins>


        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-deploy-plugin</artifactId>
            <executions>
                <execution>
                    <id>default-deploy</id>
                    <phase>none</phase>
                </execution>

                <execution>
                    <id>myjar-one</id>
                    <phase>deploy</phase>
                    <configuration>
                        <repositoryId>temp</repositoryId>
                        <url>http://localhost:8000/nexus/content/repositories/temp/</url>
                        <packaging>jar</packaging>
                        <artifactId>myjar-one</artifactId>
                        <groupId>${project.groupId}</groupId>
                        <version>${project.version}</version>
                        <sources>${project.build.directory}/build/lib/myjar-one.jar</sources>
                    </configuration>
                </execution>


                <execution>
                    <id>myjar-two</id>
                    <phase>deploy</phase>
                    <configuration>
                        <repositoryId>temp</repositoryId>
                        <url>http://localhost:8000/nexus/content/repositories/temp/</url>
                        <packaging>jar</packaging>
                        <artifactId>myjar-two</artifactId>
                        <groupId>${project.groupId}</groupId>
                        <version>${project.version}</version>
                        <sources>${project.build.directory}/build/lib/myjar-two.jar</sources>
                    </configuration>
                </execution>
            </executions>
        </plugin>
    </plugins>


</build>

1 个答案:

答案 0 :(得分:0)

伙计我找出了问题,我需要解决以下问题。

  1. 需要添加目标。
  2. 需要使用文件标记而不是源标记。 所以最终的maven-deploy-plugin看起来像。

    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-deploy-plugin</artifactId>
        <executions>
            <execution>
                <id>default-deploy</id>
                <phase>none</phase>
            </execution>
    
            <execution>
                <id>myjar-one</id>
                <phase>deploy</phase>
                <goals>
                    <goal>deploy-file</goal>
                </goals>
                <configuration>
                    <repositoryId>temp</repositoryId>
                    <url>http://localhost:8000/nexus/content/repositories/temp/</url>
                    <packaging>jar</packaging>
                    <artifactId>myjar-one</artifactId>
                    <groupId>${project.groupId}</groupId>
                    <version>${project.version}</version>
                    <file>${project.build.directory}/build/lib/myjar-one.jar</file>
                </configuration>
            </execution>
    
    
            <execution>
                <id>myjar-two</id>
                <phase>deploy</phase>
                <goals>
                    <goal>deploy-file</goal>
                </goals>
                <configuration>
                    <repositoryId>temp</repositoryId>
                    <url>http://localhost:8000/nexus/content/repositories/temp/</url>
                    <packaging>jar</packaging>
                    <artifactId>myjar-two</artifactId>
                    <groupId>${project.groupId}</groupId>
                    <version>${project.version}</version>
                    <file>${project.build.directory}/build/lib/myjar-two.jar</file>
                </configuration>
            </execution>
        </executions>
    </plugin>
    
    修复此问题后,我的两个自定义jar都部署在我的maven资源库中。感谢您的帮助