Optional and Exclusions maven difference in the
the difference
- Optional: The only dependency is passed in this module / project, the project is not transmitted to the reference to the parent item, the parent item needs to reference the active job dependency.
- Exclusion: Getting Rid dependent subprojects passed over.
Different Uses:
Project-X -> Project-A Project-A -> Project-B
<project>
...
<dependencies>
<!-- declare the dependency to be set as optional -->
<dependency>
<groupId>sample.ProjectA</groupId>
<artifactId>Project-A</artifactId>
<version>1.0</version>
<scope>compile</scope>
<optional>true</optional> <!-- value will be true or false only -->
</dependency>
</dependencies>
</project>
X dependent as A, A with B-dependent
If you do not have A
<project>
...
<dependencies>
<dependency>
<groupId>sample.ProjectA</groupId>
<artifactId>Project-A</artifactId>
<version>1.0</version>
<scope>compile</scope>
<exclusions>
<exclusion> <!-- declare the exclusion here -->
<groupId>sample.ProjectB</groupId>
<artifactId>Project-B</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
</project>
Official documents http://maven.apache.org/guides/introduction/introduction-to-optional-and-excludes-dependencies.html