"All Project Files" analysis fails with "Duplicate key"

I am able to analyze an individual Java file, but am not able to “analyze all project files”. When I do, it fails with the following error message:

Error Running SonarLint Analysis
SonarLint analysis failed: Duplicate key
file://…/target/generated-sources/META-INF/build.properties (attempted merging values and)

Versions:

  • sonarcloud.io
  • Intellij Ultimate 2019.3 (build 193.5233.102)
  • sonarlint 4.3.0.3495
  • Java 8 and 11 projects fail
  • Maven and gradle projects fail

Exception:

Analysing 11 files...
Found 32 issues
Error running SonarLint analysis
java.lang.IllegalStateException: Duplicate key file:///Users/nunya/Development/Workspaces/Customer-Services/target/generated-sources/META-INF/build.properties (attempted merging values [] and [])
	at java.base/java.util.stream.Collectors.duplicateKeyException(Collectors.java:133)
	at java.base/java.util.stream.Collectors.lambda$uniqKeysMapAccumulator$1(Collectors.java:180)
	at java.base/java.util.stream.ReduceOps$3ReducingSink.accept(ReduceOps.java:169)
	at java.base/java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:177)
	at java.base/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1654)
	at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:484)
	at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474)
	at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:913)
	at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
	at java.base/java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:578)
	at org.sonarlint.intellij.actions.ShowAnalysisResultsCallable.onSuccess(ShowAnalysisResultsCallable.java:60)
	at org.sonarlint.intellij.issue.IssueProcessor.process(IssueProcessor.java:99)
	at org.sonarlint.intellij.analysis.SonarLintTask.run(SonarLintTask.java:122)
	at org.sonarlint.intellij.analysis.SonarLintUserTask.run(SonarLintUserTask.java:40)
	at org.sonarlint.intellij.analysis.SonarLintJobManager.lambda$runTask$1(SonarLintJobManager.java:120)
	at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$runProcess$2(CoreProgressManager.java:163)
	at com.intellij.openapi.progress.impl.CoreProgressManager.registerIndicatorAndRun(CoreProgressManager.java:585)
	at com.intellij.openapi.progress.impl.CoreProgressManager.executeProcessUnderProgress(CoreProgressManager.java:531)
	at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:59)
	at com.intellij.openapi.progress.impl.CoreProgressManager.runProcess(CoreProgressManager.java:150)
	at org.sonarlint.intellij.analysis.SonarLintJobManager.lambda$runTask$2(SonarLintJobManager.java:120)
	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
	at java.base/java.lang.Thread.run(Thread.java:834)

Quick followup. I am able to successfully analyze the project if I first perform a clean: mvn clean

Interestingly enough, per the log file, the number of files that are being “analyzed” does not differ either way (clean or built), yet the number of issues reported does. There are 7 more issues reported in the log file when the error occurs:

Analysis Log with Clean Project (succeeds)

Using configuration of 'com.containerstore.customer:customer-services-parent' in server 'SonarCloud'
Analysing 42 files...
Using configuration of 'com.containerstore.customer:customer-services-parent' in server 'SonarCloud'
Analysing 94 files...
Using configuration of 'com.containerstore.customer:customer-services-parent' in server 'SonarCloud'
Analysing 169 files...
Using configuration of 'com.containerstore.customer:customer-services-parent' in server 'SonarCloud'
Analysing 11 files...
Found 25 issues

Analysis Log with Built Project (fails)

Using configuration of 'com.containerstore.customer:customer-services-parent' in server 'SonarCloud'
Analysing 42 files...
Using configuration of 'com.containerstore.customer:customer-services-parent' in server 'SonarCloud'
Analysing 94 files...
Using configuration of 'com.containerstore.customer:customer-services-parent' in server 'SonarCloud'
Analysing 169 files...
Using configuration of 'com.containerstore.customer:customer-services-parent' in server 'SonarCloud'
Analysing 11 files...
Found 32 issues

Hello, thank you for your feedback.

I am a bit surprised to see target/generated-sources/META-INF/build.properties appear - twice! - in the list of files considered for analysis.

It seems to be a generated file, which would explain why mvn clean acts as a workaround for the analysis issue.

Would it be possible to you to please share relevant parts of your Maven and/or Gradle build, to understand what generates this file and see whether we can craft a small reproducer for this issue?