我在解決這個問題時遇到了一些麻煩,所以我會盡我所能去儘可能多地抽象出不相關的細節。如果需要更多細節,請詢問。在maven中設置屬性標誌時如何跳過下載依賴關係
我有一個包含pom的項目,其中包含一個依賴關係,當用戶在該pom上執行mvn clean install
時,該依賴關係總是會下載並解壓縮到目錄中。不過,我希望在用戶通過諸如mvn clean install -Dcontent=false
之類的屬性時下載並解壓該依賴關係,但在該pom中執行其他所有操作。
對於缺乏更好的方式來說這個,我想知道如何在maven中使可選的依賴項?在這裏描述的意義上不是可選的: http://maven.apache.org/guides/introduction/introduction-to-optional-and-excludes-dependencies.html
但在構建時可選,如上所述。
編輯:
生成步驟
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>3.0.1</version>
<executions>
<execution>
<id>unpack</id>
<phase>compile</phase>
<goals>
<goal>unpack</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>com.company.random</groupId>
<artifactId>content</artifactId>
<version>${contentVersion}</version>
<type>zip</type>
<outputDirectory>contentdir/target</outputDirectory>
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>
<plugins>
</build>
@Mikita目前該會一直執行,我怎麼能做出這樣執行,只有當-Dcontent=true
一個依賴或者是可選的,就像你給的鏈接中描述的那樣,或者你需要它......你能舉個例子嗎? – khmarbaise