1
0
Fork 0
mirror of https://github.com/ethauvin/kobalt.git synced 2025-04-25 16:07: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

@ -5,18 +5,18 @@ import com.beust.kobalt.plugin.kotlin.kotlinProject
import com.beust.kobalt.plugin.packaging.assemble
import com.beust.kobalt.plugin.kotlin.kotlinCompiler
import com.beust.kobalt.plugin.publish.jcenter
import com.beust.kobalt.plugin.linecount.lineCount
//val repos = repos("https://dl.bintray.com/cbeust/maven/")
val plugins = plugins(
"com.beust.kobalt:kobalt-line-count:0.15"
// file(homeDir("kotlin/kobalt-line-count/kobaltBuild/libs/kobalt-line-count-0.14.jar"))
)
val lc = lineCount {
suffix = "**Plugin.kt"
}
//import com.beust.kobalt.plugin.linecount.lineCount
//
////val repos = repos("https://dl.bintray.com/cbeust/maven/")
//
//val plugins = plugins(
// "com.beust.kobalt:kobalt-line-count:0.15"
//// file(homeDir("kotlin/kobalt-line-count/kobaltBuild/libs/kobalt-line-count-0.14.jar"))
//)
//
//val lc = lineCount {
// suffix = "**Plugin.kt"
//}
fun readVersion() : String {
val p = java.util.Properties()
@ -43,6 +43,13 @@ val kobalt = kotlinProject(wrapper) {
group = "com.beust"
artifactId = name
version = readVersion()
description = "A build system in Kotlin"
url = "http://beust.com/kobalt"
licenses = listOf(com.beust.kobalt.api.License("Apache 2.0", "http://www.apache.org/licenses/LICENSE-2.0"))
scm = com.beust.kobalt.api.Scm(
url = "http://github.com/cbeust/kobalt",
connection = "https://github.com/cbeust/kobalt.git",
developerConnection = "git@github.com:cbeust/kobalt.git")
dependenciesTest {
compile("org.testng:testng:6.9.6")

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")
}
}