簡體   English   中英

Maven:需要一種方法來更改屬性或URL值(無論是否發布項目)

[英]Maven: Need a way to change a property or URL value if the project is being released or not

我們正在使用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插件對SNAPSHOT短語的${project.build.finalName}進行正則表達式,但它不會覆蓋現有屬性。

任何想法都歡迎。

嗯,解決方案不是很好,但是可以像我們在中西部所說的那樣完成:

<plugin>
    <groupId>org.codehaus.gmaven</groupId>
    <artifactId>gmaven-plugin</artifactId>
    <executions>
        <execution>
            <id>add-dynamic-properties</id>
            <phase>package</phase>
            <goals>
                <goal>execute</goal>
            </goals>
            <configuration>
                <source>
                <![CDATA[
                    if (project.version.contains('SNAPSHOT')) {
                        project.properties['aptRepoName'] = 'xxx-apt-pre'
                    } else {
                        project.properties['aptRepoName'] = 'xxx-apt-dist'
                    }
                ]]>
                </source>
            </configuration>
        </execution>
    </executions>
</plugin>
<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/${aptRepoName}</url>
            </configuration>
        </execution>
    </executions>
</plugin>

我希望這可以幫助某人或某天某人發布更好的方法。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM