Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Detect duplicate resources within a single project #16

Closed
jerith666 opened this issue Nov 30, 2012 · 1 comment
Closed

Detect duplicate resources within a single project #16

jerith666 opened this issue Nov 30, 2012 · 1 comment

Comments

@jerith666
Copy link

I posed a question on StackOverflow about how to detect when multiple resource folders contain a resource of the same name, within the same project. I thought that sort of thing was out of scope for this plugin, but this answer claims it's exactly what this plugin is supposed to detect. So, I'm filing this issue to find out who's right, and if khmarbaise, then get this fixed. :)

A simple test case looks like this (reproduced from the SO question):

$ cat pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
                      http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>

  <groupId>com.stackoverflow.mattmchenry</groupId>
  <artifactId>mvn-dups</artifactId>
  <version>1.0</version>

  <build>
    <resources>
      <resource>
        <directory>src/main/resources</directory>
      </resource>
      <resource>
        <directory>src/main/resources_es</directory>
      </resource>
    </resources>
  </build>
</project>

$ find src/ -type f
src/main/resources/Strings_es.properties
src/main/resources/Strings.properties
src/main/resources_es/Strings_es.properties    

$ mvn com.ning.maven.plugins:maven-duplicate-finder-plugin:1.0.2:check[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Building Unnamed - com.stackoverflow.mattmchenry:mvn-dups:jar:1.0
[INFO]    task-segment: [com.ning.maven.plugins:maven-duplicate-finder-plugin:1.0.2:check]
[INFO] ------------------------------------------------------------------------
[INFO] [duplicate-finder:check {execution: default-cli}]
[INFO] Checking compile classpath
[INFO] Checking runtime classpath
[INFO] Checking test classpath
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1 second
[INFO] Finished at: Thu Nov 22 22:44:40 EST 2012
[INFO] Final Memory: 7M/88M
[INFO] ------------------------------------------------------------------------```
@hgschmie
Copy link
Contributor

I answered the question on Stack overflow. The short answer is "the plugin works on the classpath and you have duplicates in the source folders". The slightly longer answer is that the plugin can detect this case if one file is in src/main/resources and one is in src/test/resources but nothing else. In your case, the plugin executes after the files have been copied into target/classes and there, only a single copy exists.

I added an integration test to ensure the main/test behavior. It passes. :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants