Is the "<optional>" tag valid in the dependencyManagement element?
I am a bit confused about how the mechanism for additional dependencies works in Maven. It seems that optional dependencies only work when specifying directly, and not through Dependency Management.
I created three test projects p1-p3 with dependencies:
- p3 depends on p2
- p2 depends on p1
If I declare the dependency as optional in the element , this one works as expected . POM for p2: <dependencies>
<dependencies>
<dependency>
<groupId>testgroup</groupId>
<artifactId>p1</artifactId>
<version>1.0-SNAPSHOT</version>
<optional>true</optional>
</dependency>
</dependencies>
Result : p3 is built in p2, but not p1.
However, if I If I declare the dependency as optional in the element , it seems to be ignored . POM for p2: <dependencyManagement>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>testgroup</groupId>
<artifactId>p1</artifactId>
<version>1.0-SNAPSHOT</version>
<optional>true</optional>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>testgroup</groupId>
<artifactId>p1</artifactId>
</dependency>
</dependencies>
: p3 p2 p1.
? .
:
- Maven 3.0.3 3.2.1.
- , p3 p1,
mvn dependency:tree, ,mvn -X( ). <dependencyManagement>POM p1 p2. , ..<optional>.
+4