mardi 6 septembre 2016

How to include transitive dependency in test-jar in maven 3?

I have a multi-module project that has several very hierarchical test fixtures. So ideally I would like to have some of their test phase in build lifecycle to be dependent on one another.

E.g. for 3 modules A, B and C, test fixture of B depends on A, and test fixture of C depends on A and B.

Due to maven's constraint on transitive resolution the only effective way of doing this is by using maven-jar-plugin:

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-jar-plugin</artifactId>
            <version>3.0.2</version>
            <executions>
                <execution>
                    <goals>
                        <goal>test-jar</goal>
                    </goals>
                </execution>
            </executions>
            <configuration>
            </configuration>
        </plugin>

However, in this case B has to declare A's test-jar as its test dependency, and C has to declare both A & B's test-jar as its test dependency, which is kind of redundant. Is there a way in maven to generate a 'fat test jar' during the test phase of B that includes both classes of A & B, so C can include it without extra code?

Thanks a lot for any advices.

Aucun commentaire:

Enregistrer un commentaire