Java – duplicate resource error using Duplicate Finder plug-in

I have a project consisting of many subprojects Consider the three modules a, B, C. B depends on a and C, depends on a and B.A, and C has a test ApplicationContext XML file C uses a and B as test jar dependencies The problem is that the Duplicate Finder plug-in threw test ApplicationContext when compiling C XML duplicate resource error I tried to delete test resources from module B by using < excludes > Mark on the test jar target, but Maven still copies the test resources from the test classes directory I verified that the test jar created for module B does not have an XML file Can anyone say anything?

A is only packaged as a test tank, while B has both a main tank and a test tank target The POM file of C is as follows:

<dependency>
      <groupId>my.project</groupId>
      <artifactId>A</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>my.project</groupId>
      <artifactId>B</artifactId>
      <type>test-jar</type>
      <scope>test</scope>
</dependency>

A has test ApplicationContext XML, as follows:

A ---> src/main/resources/test-applicationContext.xml

The XML of B is as follows

B ---> src/test/resources/test-applicationContext.xml

The following error occurred while executing MVN install on C

[WARNING] Found duplicate and different resources in [my.project:B:jar:tests,my.project:A]:
[WARNING]   test-applicationContext.xml
[WARNING] Found duplicate classes/resources in test classpath.

I can't rename these files because they are references in the spring configuration class I wrote I've added this to B:

<plugin>
       <groupId>org.apache.maven.plugins</groupId>
       <artifactId>maven-jar-plugin</artifactId>
       <executions>
         <execution>
           <goals>
             <goal>test-jar</goal>
           </goals>
           <configuration>
             <excludes>
               <exclude>*.xml</exclude>
             </excludes>
           </configuration>
         </execution>
       </executions>
</plugin>

I don't want to delete test resources from a because they are like reference resources running by default. If the module that depends on it doesn't have its own module

Please help!!!!

Solution

Will the checktestclasspath of Maven Duplicate Finder plugin be adjusted? I encountered a similar problem and it disappeared when I added it:

<plugin>
    <groupId>com.ning.maven.plugins</groupId>
    <artifactId>maven-duplicate-finder-plugin</artifactId>
    <version>...</version>
    <executions>
        <execution>
            <phase>verify</phase>
            <goals>
                <goal>check</goal>
            </goals>
        </execution>
    </executions>
    <configuration>
        <failBuildInCaSEOfConflict>true</failBuildInCaSEOfConflict>
        <checkTestClasspath>false</checkTestClasspath>
        <ignoredResources>
            ...
        </ignoredResources>
    </configuration>
</plugin>

Main warning: assuming I understand what's going on here, you need to be careful that you don't break the stability of the test That is, if all of the following conditions are met:

>Project C has a resource foo Props, and > project a have the same resource foo in their test jar Props > project C has a < type > test jar < / type > / < scope > test < / scope > dependent on a and > project C has a dependent on foo Test of its own value in props

... then, which foo will be used in the test of project C Props is unpredictable

If this is not your problem, or I am wrong on this point, then I think this change can solve your problem

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>