Maven:如果项目正在发布,则需要一种方法来更改属性或 URL 值

我们正在使用 JDeb maven 插件来构建我们的单罐项目的 debian 包。


我们有两个 APT 存储库,一个用于预发布版本,一个用于发布版本。


我们正在使用 Wagon 插件上传工件,但我们不知道如何只将发布发送到发布存储库,并将快照发送到预发布存储库。


<plugin>

    <groupId>org.codehaus.mojo</groupId>

    <artifactId>wagon-maven-plugin</artifactId>

    <executions>

        <execution>

            <id>upload-to-nexus</id>

            <phase>deploy</phase>

            <goals>

                <goal>upload-single</goal>

            </goals>

            <configuration>

                <serverId>xxx-all</serverId>

                <fromFile>${project.build.directory}/${jdeb.name}</fromFile>

                <url>https://xxx.xxx.xxx/repository/xxx-apt-pre</url>

            </configuration>

        </execution>

    </executions>

</plugin>

我们需要将xxx-apt-pre上面的内容更改xxx-apt-dist为发布插件运行的时间。对于我的一生,我想不出办法做到这一点。


我最初尝试使用 build-helper 插件${project.build.finalName}为短语正则表达式SNAPSHOT,但它不会覆盖现有属性。


欢迎任何想法。


慕尼黑8549860
浏览 103回答 1
1回答

jeck猫

好吧,解决方案并不完美,但正如我们在中西部所说的那样完成了:<plugin>&nbsp; &nbsp; <groupId>org.codehaus.gmaven</groupId>&nbsp; &nbsp; <artifactId>gmaven-plugin</artifactId>&nbsp; &nbsp; <executions>&nbsp; &nbsp; &nbsp; &nbsp; <execution>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <id>add-dynamic-properties</id>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <phase>package</phase>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <goals>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <goal>execute</goal>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </goals>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <configuration>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <source>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <![CDATA[&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (project.version.contains('SNAPSHOT')) {&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; project.properties['aptRepoName'] = 'xxx-apt-pre'&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; } else {&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; project.properties['aptRepoName'] = 'xxx-apt-dist'&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ]]>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </source>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </configuration>&nbsp; &nbsp; &nbsp; &nbsp; </execution>&nbsp; &nbsp; </executions></plugin><plugin>&nbsp; &nbsp; <groupId>org.codehaus.mojo</groupId>&nbsp; &nbsp; <artifactId>wagon-maven-plugin</artifactId>&nbsp; &nbsp; <executions>&nbsp; &nbsp; &nbsp; &nbsp; <execution>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <id>upload-to-nexus</id>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <phase>deploy</phase>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <goals>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <goal>upload-single</goal>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </goals>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <configuration>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <serverId>xxx-all</serverId>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <fromFile>${project.build.directory}/${jdeb.name}</fromFile>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <url>https://xxx.xxx.xxx/repository/${aptRepoName}</url>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </configuration>&nbsp; &nbsp; &nbsp; &nbsp; </execution>&nbsp; &nbsp; </executions></plugin>我希望这可以帮助某人或有一天有人发布更好的方式。
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Java