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

Generate the correct pom file for provided().

This commit is contained in:
Cedric Beust 2016-09-22 11:12:19 -07:00
parent 91baf6e86f
commit b80c996e05
4 changed files with 21 additions and 3 deletions

View file

@ -29,7 +29,7 @@ interface IClasspathDependency {
val jarFile: Future<File>
/** Convert to a Maven <dependency> model tag */
fun toMavenDependencies() : Dependency
fun toMavenDependencies(scope: String? = null) : Dependency
/** The list of dependencies for this element (not the transitive closure) */
fun directDependencies(): List<IClasspathDependency>

View file

@ -72,6 +72,21 @@ class PomGenerator @Inject constructor(@Assisted val project: Project) {
pom.dependencies.add(dep.toMavenDependencies())
}
// Provided dependencies
project.compileProvidedDependencies.forEach { dep ->
pom.dependencies.add(dep.toMavenDependencies("provided"))
}
// Test dependencies
project.testDependencies.forEach { dep ->
pom.dependencies.add(dep.toMavenDependencies("test"))
}
// Test provided dependencies
project.testProvidedDependencies.forEach { dep ->
pom.dependencies.add(dep.toMavenDependencies("test"))
}
// Project dependencies
project.dependsOn.forEach {
pom.dependencies.add(org.apache.maven.model.Dependency().apply {

View file

@ -266,13 +266,15 @@ class AetherDependency(val artifact: Artifact, override val optional: Boolean =
}
}
override fun toMavenDependencies() : org.apache.maven.model.Dependency {
override fun toMavenDependencies(scope: String?) : org.apache.maven.model.Dependency {
val passedScope = scope
val op = this.optional
return org.apache.maven.model.Dependency().apply {
groupId = artifact.groupId
artifactId = artifact.artifactId
version = artifact.version
if (op) optional = op.toString()
if (passedScope != null) this.scope = passedScope
}
}

View file

@ -19,9 +19,10 @@ open class FileDependency(open val fileName: String, override val optional: Bool
override val jarFile = CompletedFuture(File(fileName))
override fun toMavenDependencies(): Dependency {
override fun toMavenDependencies(scope: String?): Dependency {
with(Dependency()) {
systemPath = jarFile.get().absolutePath
this.scope = scope
return this
}
}