Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 368445 - avoid injecting duplicate source folders into maven model
Summary: avoid injecting duplicate source folders into maven model
Status: RESOLVED FIXED
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: Tycho (show other bugs)
Version: unspecified   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Jan Sievers CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-01-12 07:38 EST by Jan Sievers CLA
Modified: 2021-04-28 16:55 EDT (History)
1 user (show)

See Also:


Attachments
sample project reproducing the bug (3.40 KB, application/zip)
2012-01-13 07:47 EST, Jan Sievers CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Jan Sievers CLA 2012-01-12 07:38:10 EST
See http://dev.eclipse.org/mhonarc/lists/tycho-user/msg01707.html

The same source folder (once as compile source root and once as test compile source root) in the maven model causes a DuplicatedSourceException with sonar.

Idea: only inject source folder into compile source roots of maven model if it's not already present in test compile source roots.

Note that duplicates can only occur between compile source roots and test compile source roots. Each of the two source folder lists is actually a set so duplicates are avoided within the set.
Comment 1 Tobias Oberlies CLA 2012-01-12 08:51:56 EST
(In reply to comment #0)
> Idea: only inject source folder into compile source roots of maven model if
> it's not already present in test compile source roots.
This is unstable: assuming that it is really necessary (e.g. for interoperability), that the compile root of eclipse-test-plugin is set as Maven compile source root, Tycho should not behave differently if the Tycho source root happens to be src/test/java.

Instead, the duplicate entry should be removed the Maven test source roots.
Comment 2 Jan Sievers CLA 2012-01-12 08:53:53 EST
(In reply to comment #1)
> (In reply to comment #0)
> > Idea: only inject source folder into compile source roots of maven model if
> > it's not already present in test compile source roots.
> This is unstable: assuming that it is really necessary (e.g. for
> interoperability), that the compile root of eclipse-test-plugin is set as Maven
> compile source root, Tycho should not behave differently if the Tycho source
> root happens to be src/test/java.
> 
> Instead, the duplicate entry should be removed the Maven test source roots.

just need to make sure an empty test compile roots list will not cause trouble somewhere else (in maven it's never be empty)
Comment 3 Jan Sievers CLA 2012-01-13 07:47:59 EST
Created attachment 209449 [details]
sample project reproducing the bug

Steps to reproduce:

1. download sonar from http://www.sonarsource.org/downloads/
2. unzip and start it http://docs.codehaus.org/display/SONAR/Install+Sonar#InstallSonar-The2minutestutorial
3. unzip example
4. run mvn -X clean install sonar:sonar

=> build fails with 

Caused by: org.sonar.api.resources.DuplicatedSourceException: test.TestMe
        at org.sonar.batch.index.SourcePersister.saveSource(SourcePersister.java:45)
        at org.sonar.batch.index.DefaultPersistenceManager.setSource(DefaultPersistenceManager.java:78)
        at org.sonar.batch.index.DefaultIndex.setSource(DefaultIndex.java:411)
        at org.sonar.batch.DefaultSensorContext.saveSource(DefaultSensorContext.java:159)
        at org.sonar.plugins.squid.JavaSourceImporter.importSource(JavaSourceImporter.java:83)
        ... 39 more
[ERROR]
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException