Optional and Exclusions maven difference in the

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 true , It can only be used in case A and B, while not actively transferred to the X, B X need only rely on the active reference of B.

If you do not have A true A reference B, will be transmitted to the X, X B is required if no active transfer from the negative B. 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

Guess you like

Origin www.cnblogs.com/jakaBlog/p/11547401.html