Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 368445

Summary: avoid injecting duplicate source folders into maven model
Product: z_Archived Reporter: Jan Sievers <jan.sievers>
Component: TychoAssignee: Jan Sievers <jan.sievers>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: t-oberlies
Version: unspecified   
Target Milestone: ---   
Hardware: All   
OS: All   
Whiteboard:
Attachments:
Description Flags
sample project reproducing the bug none

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