using transitive-dependency’s version


problem

다음과 같은 dependency-tree 가 있다고 하자.

A <- B <- C

C 에서 Aversion 값을 사용하고자 할 때 어떻게 하면 될까?

solution

add direct (redundant) dependency

// C/pom.xml
<properties>
  <a.version>x.y.z</a.version>
</properties>
<dependencies>
  <dependency>
    <artifactId>A</artifactId>
    <version>${a.vresion}</version>
    <scope>compile</scope>
  </dependency>
  <dependency>
    <artifactId>B</artifactId>
    <version>x.y.z</version>
    <scope>compile</scope>
  </dependency>
</dependencies>

Now we can use the value of ${a.version} in other files.

A's version is ${a.version}.

enforce dependency convergence

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-enforcer-plugin</artifactId>
  <executions>
    <execution>
      <id>enforce</id>
      <configuration>
        <rules>
           <dependencyConvergence/>
        </rules>
      </configuration>
      <goals>
        <goal>enforce</goal>
      </goals>
    </execution>
  </executions>
</plugin>
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s