1
0
Fork 0
mirror of https://github.com/ethauvin/kobalt.git synced 2025-04-26 08:27:12 -07:00

Prevent duplicate dependency tags in the .pom.

This commit is contained in:
Cedric Beust 2016-09-23 11:32:50 -07:00
parent bee7bd84dd
commit 736062ab8b

View file

@ -1,6 +1,7 @@
package com.beust.kobalt.maven
import com.beust.kobalt.SystemProperties
import com.beust.kobalt.api.IClasspathDependency
import com.beust.kobalt.api.Project
import com.beust.kobalt.misc.KFiles
import com.beust.kobalt.misc.kobaltLog
@ -62,8 +63,17 @@ class PomGenerator @Inject constructor(@Assisted val project: Project) {
//
pom.dependencies = arrayListOf<org.apache.maven.model.Dependency>()
/**
* optional and provided dependencies are added both to the compile dependencies (since they are needed
* to build the project) and to their respective list as well (for POM generation). Make sure they
* don't get added twice to the .pom in such cases.
*/
fun providedOrOptional(dep: IClasspathDependency) =
project.compileProvidedDependencies.contains(dep) ||
project.optionalDependencies.contains(dep)
// Compile dependencies
project.compileDependencies.forEach { dep ->
project.compileDependencies.filterNot(::providedOrOptional).forEach { dep ->
pom.dependencies.add(dep.toMavenDependencies())
}