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

More complete pom generation.

This commit is contained in:
Cedric Beust 2015-10-12 23:14:14 -07:00
parent b7ad814ff0
commit f602f6996d
3 changed files with 49 additions and 15 deletions

View file

@ -4,7 +4,6 @@ import com.beust.kobalt.api.annotation.Directive
import com.beust.kobalt.maven.MavenDependency
import com.beust.kobalt.maven.IClasspathDependency
import com.beust.kobalt.misc.KFiles
import com.google.common.base.Preconditions
import java.util.ArrayList
open public class Project(
@ -16,7 +15,11 @@ open public class Project(
open var artifactId: String? = null,
open var dependencies: Dependencies? = null,
open var sourceSuffix : String = "",
open var compilerInfo : ICompilerInfo ) {
open var compilerInfo : ICompilerInfo,
open var description : String = "",
open var scm : Scm? = null,
open var url: String? = null,
open var licenses: List<License> = arrayListOf<License>()) {
var testArgs: ArrayList<String> = arrayListOf()
@ -110,3 +113,14 @@ public class Dependencies(val project: Project, val dependencies: ArrayList<ICla
}
}
public class Scm(val connection: String, val developerConnection: String, val url: String)
public class License(val name: String, val url: String) {
fun toMavenLicense() : org.apache.maven.model.License {
val result = org.apache.maven.model.License()
result.name = name
result.url = url
return result
}
}

View file

@ -6,11 +6,14 @@ import com.beust.kobalt.SystemProperties
import com.google.common.base.Preconditions
import com.google.inject.assistedinject.Assisted
import org.apache.maven.model.Developer
import org.apache.maven.model.License
import org.apache.maven.model.Model
import org.apache.maven.model.Scm
import org.apache.maven.model.io.xpp3.MavenXpp3Writer
import java.io.File
import java.io.StringWriter
import java.nio.charset.Charset
import java.util.*
import javax.inject.Inject
public class PomGenerator @Inject constructor(@Assisted val project: Project) : KobaltLogger {
@ -26,6 +29,16 @@ public class PomGenerator @Inject constructor(@Assisted val project: Project) :
artifactId = project.artifactId
groupId = project.group
version = project.version
description = project.description
licenses = project.licenses.map { it.toMavenLicense() }
url = project.url
scm = Scm().apply {
project.scm?.let {
url = it.url
connection = it.connection
developerConnection = it.developerConnection
}
}
}
with(Developer()) {
name = SystemProperties.username
@ -46,6 +59,6 @@ public class PomGenerator @Inject constructor(@Assisted val project: Project) :
val pomFile = SimpleDep(project.group!!, project.artifactId!!, project.version!!).toPomFileName()
val outputFile = File(outputDir, pomFile)
outputFile.writeText(s.toString(), Charset.defaultCharset())
log(1, "Wrote ${outputFile}")
log(1, "Wrote $outputFile")
}
}