[Maven] Filter duplicated source roots to avoid multiple module declarations exception

After fixing of KT-13995 (99de93bb) there is a case when several maven plugins register the same source roots twice, which leads to the Kotlin compiler exception "Too many source module declarations found". kotlin-maven-plugin should take care of what it passes to the Kotlin compiler to avoid it

#KT-58048 Fixed

Merge-request: KT-MR-9663
Merged-by: Aleksei Cherepanov <aleksei.cherepanov@jetbrains.com>
This commit is contained in:
Aleksei.Cherepanov
2023-04-20 10:14:32 +00:00
committed by Space Team
parent c3bfe72394
commit 07d20c6ee1
6 changed files with 126 additions and 1 deletions
@@ -41,6 +41,7 @@ import java.lang.reflect.Field;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import static org.jetbrains.kotlin.maven.Util.joinArrays;
@@ -82,7 +83,7 @@ public abstract class KotlinCompileMojoBase<A extends CommonCompilerArguments> e
List<String> list = new ArrayList<>();
if (sourceDirs != null && !sourceDirs.isEmpty()) list.addAll(sourceDirs);
list.addAll(project.getCompileSourceRoots());
return list;
return list.stream().distinct().collect(Collectors.toList());
}
@NotNull