mirror of
https://github.com/ethauvin/kobalt.git
synced 2025-04-26 16:28:12 -07:00
Better pom generation.
This commit is contained in:
parent
71a9dac639
commit
86abfc3d80
4 changed files with 24 additions and 66 deletions
|
@ -4,6 +4,7 @@ import com.beust.kobalt.TestConfig
|
||||||
import com.beust.kobalt.api.annotation.Directive
|
import com.beust.kobalt.api.annotation.Directive
|
||||||
import com.beust.kobalt.maven.DependencyManager
|
import com.beust.kobalt.maven.DependencyManager
|
||||||
import com.beust.kobalt.misc.KFiles
|
import com.beust.kobalt.misc.KFiles
|
||||||
|
import org.apache.maven.model.Model
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.util.*
|
import java.util.*
|
||||||
import java.util.concurrent.Future
|
import java.util.concurrent.Future
|
||||||
|
@ -18,9 +19,8 @@ open class Project(
|
||||||
@Directive open var artifactId: String? = null,
|
@Directive open var artifactId: String? = null,
|
||||||
@Directive open var packaging: String? = null,
|
@Directive open var packaging: String? = null,
|
||||||
@Directive open var description : String = "",
|
@Directive open var description : String = "",
|
||||||
@Directive open var scm : Scm? = null,
|
|
||||||
@Directive open var url: String? = null,
|
@Directive open var url: String? = null,
|
||||||
@Directive open var licenses: List<License> = arrayListOf<License>(),
|
@Directive open var pom: Model? = null,
|
||||||
@Directive open var dependsOn: ArrayList<Project> = arrayListOf<Project>(),
|
@Directive open var dependsOn: ArrayList<Project> = arrayListOf<Project>(),
|
||||||
@Directive open var packageName: String? = group)
|
@Directive open var packageName: String? = group)
|
||||||
: IBuildConfig, IDependencyHolder by DependencyHolder() {
|
: IBuildConfig, IDependencyHolder by DependencyHolder() {
|
||||||
|
@ -164,18 +164,6 @@ class Dependencies(val project: Project,
|
||||||
fun native(vararg dep: String) = addToDependencies(project, nativeDependencies, dep)
|
fun native(vararg dep: String) = addToDependencies(project, nativeDependencies, dep)
|
||||||
}
|
}
|
||||||
|
|
||||||
class Scm(val connection: String, val developerConnection: String, val url: String)
|
|
||||||
|
|
||||||
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
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
class BuildConfig {
|
class BuildConfig {
|
||||||
class Field(val name: String, val type: String, val value: Any) {
|
class Field(val name: String, val type: String, val value: Any) {
|
||||||
override fun hashCode() = name.hashCode()
|
override fun hashCode() = name.hashCode()
|
||||||
|
|
|
@ -21,9 +21,6 @@ class PomProject {
|
||||||
var description: String? = null
|
var description: String? = null
|
||||||
var url: String? = null
|
var url: String? = null
|
||||||
var packaging: String? = null
|
var packaging: String? = null
|
||||||
var licenses : Licenses? = null
|
|
||||||
var developers: Developers? = null
|
|
||||||
var scm: Scm? = null
|
|
||||||
var properties: Properties? = null
|
var properties: Properties? = null
|
||||||
var parent: Parent? = null
|
var parent: Parent? = null
|
||||||
@XmlElement(name = "dependencies") @JvmField
|
@XmlElement(name = "dependencies") @JvmField
|
||||||
|
@ -46,12 +43,6 @@ class PomProject {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//fun main(argv: Array<String>) {
|
|
||||||
// val p = Pom2(File("/Users/beust/t/pom.xml"))
|
|
||||||
// val pom = p.pom
|
|
||||||
// println("Dependencies: " + pom.dependencies[0])
|
|
||||||
//}
|
|
||||||
|
|
||||||
class Either<E, V>(val exception: E?, val value: V?)
|
class Either<E, V>(val exception: E?, val value: V?)
|
||||||
|
|
||||||
class Pom2(val pomProject: PomProject) {
|
class Pom2(val pomProject: PomProject) {
|
||||||
|
@ -165,12 +156,6 @@ class Dependency {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class Scm {
|
|
||||||
var connection: String? = null
|
|
||||||
var developerConnection: String? = null
|
|
||||||
var url: String? = null
|
|
||||||
}
|
|
||||||
|
|
||||||
class Parent {
|
class Parent {
|
||||||
var groupId: String? = null
|
var groupId: String? = null
|
||||||
var artifactId: String? = null
|
var artifactId: String? = null
|
||||||
|
|
|
@ -7,14 +7,13 @@ import com.beust.kobalt.misc.log
|
||||||
import com.google.inject.assistedinject.Assisted
|
import com.google.inject.assistedinject.Assisted
|
||||||
import org.apache.maven.model.Developer
|
import org.apache.maven.model.Developer
|
||||||
import org.apache.maven.model.Model
|
import org.apache.maven.model.Model
|
||||||
import org.apache.maven.model.Scm
|
|
||||||
import org.apache.maven.model.io.xpp3.MavenXpp3Writer
|
import org.apache.maven.model.io.xpp3.MavenXpp3Writer
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.io.StringWriter
|
import java.io.StringWriter
|
||||||
import java.nio.charset.Charset
|
import java.nio.charset.Charset
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
public class PomGenerator @Inject constructor(@Assisted val project: Project) {
|
class PomGenerator @Inject constructor(@Assisted val project: Project) {
|
||||||
interface IFactory {
|
interface IFactory {
|
||||||
fun create(project: Project) : PomGenerator
|
fun create(project: Project) : PomGenerator
|
||||||
}
|
}
|
||||||
|
@ -24,26 +23,24 @@ public class PomGenerator @Inject constructor(@Assisted val project: Project) {
|
||||||
requireNotNull(project.group, { "group mandatory on project ${project.name}" })
|
requireNotNull(project.group, { "group mandatory on project ${project.name}" })
|
||||||
requireNotNull(project.artifactId, { "artifactId mandatory on project ${project.name}" })
|
requireNotNull(project.artifactId, { "artifactId mandatory on project ${project.name}" })
|
||||||
|
|
||||||
val m = Model().apply {
|
val m =
|
||||||
name = project.name
|
if (project.pom == null) {
|
||||||
artifactId = project.artifactId
|
// No pom specified, create one with default values
|
||||||
groupId = project.group
|
Model().apply {
|
||||||
version = project.version
|
name = project.name
|
||||||
description = project.description
|
artifactId = project.artifactId
|
||||||
licenses = project.licenses.map { it.toMavenLicense() }
|
groupId = project.group
|
||||||
url = project.url
|
version = project.version
|
||||||
scm = Scm().apply {
|
description = project.description
|
||||||
project.scm?.let {
|
url = project.url
|
||||||
url = it.url
|
developers = listOf(Developer().apply {
|
||||||
connection = it.connection
|
name = SystemProperties.username
|
||||||
developerConnection = it.developerConnection
|
})
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
// Use the pom specified on the project
|
||||||
|
project.pom!!
|
||||||
}
|
}
|
||||||
}
|
|
||||||
with(Developer()) {
|
|
||||||
name = SystemProperties.username
|
|
||||||
m.addDeveloper(this)
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Dependencies
|
// Dependencies
|
||||||
|
|
|
@ -6,30 +6,18 @@ import com.beust.kobalt.api.Project
|
||||||
import com.beust.kobalt.maven.Gpg
|
import com.beust.kobalt.maven.Gpg
|
||||||
import com.beust.kobalt.maven.Http
|
import com.beust.kobalt.maven.Http
|
||||||
import com.beust.kobalt.maven.Md5
|
import com.beust.kobalt.maven.Md5
|
||||||
import com.beust.kobalt.misc.CountingFileRequestBody
|
import com.beust.kobalt.misc.*
|
||||||
import com.beust.kobalt.misc.KobaltExecutors
|
|
||||||
import com.beust.kobalt.misc.error
|
|
||||||
import com.beust.kobalt.misc.log
|
|
||||||
import com.beust.kobalt.misc.warn
|
|
||||||
import com.google.gson.Gson
|
import com.google.gson.Gson
|
||||||
import com.google.gson.JsonArray
|
import com.google.gson.JsonArray
|
||||||
import com.google.gson.JsonObject
|
import com.google.gson.JsonObject
|
||||||
import com.google.gson.TypeAdapter
|
import com.google.gson.TypeAdapter
|
||||||
import com.google.gson.reflect.TypeToken
|
import com.google.gson.reflect.TypeToken
|
||||||
import com.google.inject.assistedinject.Assisted
|
import com.google.inject.assistedinject.Assisted
|
||||||
import okhttp3.Credentials
|
import okhttp3.*
|
||||||
import okhttp3.Interceptor
|
|
||||||
import okhttp3.OkHttpClient
|
|
||||||
import okhttp3.RequestBody
|
|
||||||
import okhttp3.ResponseBody
|
|
||||||
import retrofit2.Call
|
import retrofit2.Call
|
||||||
import retrofit2.Converter
|
import retrofit2.Converter
|
||||||
import retrofit2.Retrofit
|
import retrofit2.Retrofit
|
||||||
import retrofit2.http.Body
|
import retrofit2.http.*
|
||||||
import retrofit2.http.GET
|
|
||||||
import retrofit2.http.POST
|
|
||||||
import retrofit2.http.PUT
|
|
||||||
import retrofit2.http.Path
|
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.lang.reflect.Type
|
import java.lang.reflect.Type
|
||||||
import javax.annotation.Nullable
|
import javax.annotation.Nullable
|
||||||
|
@ -113,10 +101,10 @@ class BintrayApi @Inject constructor(val http: Http,
|
||||||
val jsonObject = JsonObject()
|
val jsonObject = JsonObject()
|
||||||
jsonObject.addNonNull("name", project.name)
|
jsonObject.addNonNull("name", project.name)
|
||||||
jsonObject.addNonNull("desc", project.description)
|
jsonObject.addNonNull("desc", project.description)
|
||||||
jsonObject.addNonNull("vcs_url", project.scm?.url)
|
jsonObject.addNonNull("vcs_url", project.pom?.scm?.url)
|
||||||
jsonObject.addNonNull("website_url", project.url)
|
jsonObject.addNonNull("website_url", project.url)
|
||||||
val licenses = JsonArray()
|
val licenses = JsonArray()
|
||||||
project.licenses.forEach {
|
project.pom?.licenses?.forEach {
|
||||||
licenses.add(it.name)
|
licenses.add(it.name)
|
||||||
}
|
}
|
||||||
jsonObject.add("licenses", licenses)
|
jsonObject.add("licenses", licenses)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue