我有一個包含3個不同庫的項目。當我運行安裝腳本時,它會從回購庫中獲取所有庫,並在其上運行mvn clean install。但是這個版本的庫已經安裝在repo中。有沒有辦法跳過安裝階段,如果版本在我的本地回購pom.xml版本相等。如何在Maven build中跳過安裝階段(如果我已經在回購站中安裝了此版本)
我知道我可以使用本地回購並只設置依賴關係。但是,我的老闆希望我們的項目只能通過公共回購協議進行構建,而不需要任何回購。
我有一個包含3個不同庫的項目。當我運行安裝腳本時,它會從回購庫中獲取所有庫,並在其上運行mvn clean install。但是這個版本的庫已經安裝在repo中。有沒有辦法跳過安裝階段,如果版本在我的本地回購pom.xml版本相等。如何在Maven build中跳過安裝階段(如果我已經在回購站中安裝了此版本)
我知道我可以使用本地回購並只設置依賴關係。但是,我的老闆希望我們的項目只能通過公共回購協議進行構建,而不需要任何回購。
您可以繞過這樣
-Dmaven.install.skip =真
<profiles>
<profile>
<id>skipInstall</id>
<activation>
<property>
<name>maven.install.skip</name>
<value>true</value>
</property>
</activation>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-install-plugin</artifactId>
<executions>
<execution>
<id>default-install</id>
<phase>none</phase>
</execution>
</executions>
</plugin>
</plugins>
</pluginManagement>
</build>
</profile>
上週奧利維爾·拉米修補了這個JIRA。
此解決方案沒有爲我工作。我還注意到,maven settings.xml文件有一個警告,
我知道我可以使用本地回購和剛剛成立的依賴。但是,我的老闆希望我們的項目只能通過公共回購協議進行構建,而不需要任何回購。
你確定正確認識你的老闆是什麼意思?我將上述解釋爲「不要在本地存儲庫中安裝第三方庫,只使用公共存儲庫中的庫」。這不同於「不要使用本地存儲庫」,這基本上是不可能的,這不僅僅是maven的工作原理。我試圖澄清這一點。
除此之外,我不明白的問題,這是非常令人困惑(你在說什麼回購?什麼是安裝腳本在幹什麼?你爲什麼叫乾淨安裝上庫?等等)。
<plugin>
<artifactId>maven-install-plugin</artifactId>
<version>X.Y</version>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
您還可以設置創建個人資料設置屬性,並用它來確定該值:
大多數Maven插件可以通過指定像被跳過。例如,運行命令:mvn -Pexample將選擇「示例」配置文件。然後,POM將包含:
...
<properties>
<skip.install>false</skip.install>
...
</properties>
...
<profile>
<id>example</id>
<properties>
<skip.install>false</skip.install>
</properties>
</profile>
...
<plugin>
<artifactId>maven-install-plugin</artifactId>
<version>X.Y</version>
<configuration>
<skip>${skip.install}</skip>
</configuration>
</plugin>
...
使用這些POM增加,爲安裝插件的默認行爲將是執行其默認的目標,但如果選擇了例如配置文件,然後安裝插件就可以跳過它的目標。
使用我從其他的答案瞭解到,這對我來說最乾淨的結果。
在我的超級POM我加了一個pluginManagement /插件禁用默認安裝和默認測試階段時,該屬性deployOnly
設置。
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-install-plugin</artifactId>
<version>2.5.2</version>
<executions>
<execution>
<id>default-install</id>
<configuration>
<skip>${deployOnly}</skip>
</configuration>
</execution>
<execution>
<id>default-test</id>
<configuration>
<skip>${deployOnly}</skip>
</configuration>
</execution>
</executions>
</plugin>
所以在命令行中,我可以通過添加-DdeployOnly
禁止安裝和測試階段。
mvn clean install #build and test everything
mvn deploy -DdeployOnly #just deploy it
Olivier Lamy修補也'':https://jira.codehaus.org/browse/MINSTALL-73' – Cemo 2012-07-19 14:23:28