mirror of
https://github.com/ethauvin/kobalt.git
synced 2025-04-27 00:38:11 -07:00
Rename build structs to "Config".
This commit is contained in:
parent
fe153d0ea3
commit
5a144065ec
3 changed files with 18 additions and 18 deletions
|
@ -19,13 +19,13 @@ import java.io.File
|
||||||
import java.nio.file.Path
|
import java.nio.file.Path
|
||||||
import java.nio.file.Paths
|
import java.nio.file.Paths
|
||||||
|
|
||||||
class AndroidConfiguration(var compileSdkVersion : String = "23",
|
class AndroidConfig(var compileSdkVersion : String = "23",
|
||||||
var buildToolsVersion : String = "23.0.1",
|
var buildToolsVersion : String = "23.0.1",
|
||||||
var applicationId: String? = null)
|
var applicationId: String? = null)
|
||||||
|
|
||||||
@Directive
|
@Directive
|
||||||
fun Project.android(init: AndroidConfiguration.() -> Unit) : AndroidConfiguration {
|
fun Project.android(init: AndroidConfig.() -> Unit) : AndroidConfig {
|
||||||
val pd = AndroidConfiguration()
|
val pd = AndroidConfig()
|
||||||
pd.init()
|
pd.init()
|
||||||
(Kobalt.findPlugin("android") as AndroidPlugin).setConfiguration(this, pd)
|
(Kobalt.findPlugin("android") as AndroidPlugin).setConfiguration(this, pd)
|
||||||
return pd
|
return pd
|
||||||
|
@ -47,10 +47,10 @@ public class AndroidPlugin @Inject constructor(val javaCompiler: JavaCompiler) :
|
||||||
context.classpathContributors.add(this)
|
context.classpathContributors.add(this)
|
||||||
}
|
}
|
||||||
|
|
||||||
val configurations = hashMapOf<String, AndroidConfiguration>()
|
val configurations = hashMapOf<String, AndroidConfig>()
|
||||||
|
|
||||||
fun setConfiguration(p: Project, configuration: AndroidConfiguration) {
|
fun setConfiguration(p: Project, config: AndroidConfig) {
|
||||||
configurations.put(p.name!!, configuration)
|
configurations.put(p.name!!, config)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun accept(project: Project) = configurations.containsKey(project.name!!)
|
override fun accept(project: Project) = configurations.containsKey(project.name!!)
|
||||||
|
|
|
@ -71,7 +71,7 @@ public class JCenterApi @Inject constructor (@Nullable @Assisted("username") val
|
||||||
// return http.post(username, password, url, jsonString)
|
// return http.post(username, password, url, jsonString)
|
||||||
// }
|
// }
|
||||||
|
|
||||||
fun uploadMaven(project: Project, files: List<File>, configuration : JCenterConfiguration?) : TaskResult {
|
fun uploadMaven(project: Project, files: List<File>, config: JCenterConfig?) : TaskResult {
|
||||||
if (! packageExists(project.name!!)) {
|
if (! packageExists(project.name!!)) {
|
||||||
throw KobaltException("Couldn't find a package called ${project.name} on bintray, please create one first" +
|
throw KobaltException("Couldn't find a package called ${project.name} on bintray, please create one first" +
|
||||||
" as explained at https://bintray.com/docs/usermanual/uploads/uploads_creatinganewpackage.html")
|
" as explained at https://bintray.com/docs/usermanual/uploads/uploads_creatinganewpackage.html")
|
||||||
|
@ -91,16 +91,16 @@ public class JCenterApi @Inject constructor (@Nullable @Assisted("username") val
|
||||||
.joinToString("/")
|
.joinToString("/")
|
||||||
}
|
}
|
||||||
|
|
||||||
return upload(files, configuration, fileToPath, generateMd5 = true, generateAsc = true)
|
return upload(files, config, fileToPath, generateMd5 = true, generateAsc = true)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun uploadFile(file: File, url: String, configuration: JCenterConfiguration, generateMd5: Boolean = false,
|
fun uploadFile(file: File, url: String, config: JCenterConfig, generateMd5: Boolean = false,
|
||||||
generateAsc: Boolean = false) =
|
generateAsc: Boolean = false) =
|
||||||
upload(arrayListOf(file), configuration, {
|
upload(arrayListOf(file), config, {
|
||||||
f: File -> "${UnauthenticatedJCenterApi.BINTRAY_URL_API_CONTENT}/$username/generic/$url"},
|
f: File -> "${UnauthenticatedJCenterApi.BINTRAY_URL_API_CONTENT}/$username/generic/$url"},
|
||||||
generateMd5, generateAsc)
|
generateMd5, generateAsc)
|
||||||
|
|
||||||
private fun upload(files: List<File>, configuration : JCenterConfiguration?, fileToPath: (File) -> String,
|
private fun upload(files: List<File>, config: JCenterConfig?, fileToPath: (File) -> String,
|
||||||
generateMd5: Boolean = false, generateAsc: Boolean) : TaskResult {
|
generateMd5: Boolean = false, generateAsc: Boolean) : TaskResult {
|
||||||
val filesToUpload = arrayListOf<File>()
|
val filesToUpload = arrayListOf<File>()
|
||||||
|
|
||||||
|
@ -125,7 +125,7 @@ public class JCenterApi @Inject constructor (@Nullable @Assisted("username") val
|
||||||
// If any configuration was given, apply them so the URL reflects them, e.g. ?publish=1
|
// If any configuration was given, apply them so the URL reflects them, e.g. ?publish=1
|
||||||
//
|
//
|
||||||
val options = arrayListOf<String>()
|
val options = arrayListOf<String>()
|
||||||
if (configuration?.publish == true) options.add("publish=1")
|
if (config?.publish == true) options.add("publish=1")
|
||||||
|
|
||||||
val optionPath = StringBuffer()
|
val optionPath = StringBuffer()
|
||||||
if (options.size > 0) {
|
if (options.size > 0) {
|
||||||
|
|
|
@ -81,7 +81,7 @@ public class PublishPlugin @Inject constructor(val files: KFiles, val factory: P
|
||||||
//
|
//
|
||||||
// Upload individual files, if applicable
|
// Upload individual files, if applicable
|
||||||
//
|
//
|
||||||
configuration?.let { conf : JCenterConfiguration ->
|
configuration?.let { conf : JCenterConfig ->
|
||||||
conf.files.forEach {
|
conf.files.forEach {
|
||||||
val taskResult = jcenter.uploadFile(File(project.directory, it.first), it.second /* url */, conf)
|
val taskResult = jcenter.uploadFile(File(project.directory, it.first), it.second /* url */, conf)
|
||||||
success = success and taskResult.success
|
success = success and taskResult.success
|
||||||
|
@ -96,14 +96,14 @@ public class PublishPlugin @Inject constructor(val files: KFiles, val factory: P
|
||||||
/**
|
/**
|
||||||
* Map of project name -> JCenterConfiguration
|
* Map of project name -> JCenterConfiguration
|
||||||
*/
|
*/
|
||||||
private val configurations = hashMapOf<String, JCenterConfiguration>()
|
private val configurations = hashMapOf<String, JCenterConfig>()
|
||||||
fun addConfiguration(projectName: String, config: JCenterConfiguration) {
|
fun addConfiguration(projectName: String, config: JCenterConfig) {
|
||||||
configurations.put(projectName, config)
|
configurations.put(projectName, config)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
data class JCenterConfiguration(val project: Project) {
|
data class JCenterConfig(val project: Project) {
|
||||||
var publish: Boolean = false
|
var publish: Boolean = false
|
||||||
val files = arrayListOf<Pair<String, String>>()
|
val files = arrayListOf<Pair<String, String>>()
|
||||||
|
|
||||||
|
@ -114,8 +114,8 @@ data class JCenterConfiguration(val project: Project) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Directive
|
@Directive
|
||||||
public fun Project.jcenter(ini: JCenterConfiguration.() -> Unit) : JCenterConfiguration {
|
public fun Project.jcenter(ini: JCenterConfig.() -> Unit) : JCenterConfig {
|
||||||
val pd = JCenterConfiguration(this)
|
val pd = JCenterConfig(this)
|
||||||
pd.ini()
|
pd.ini()
|
||||||
(Kobalt.findPlugin("publish") as PublishPlugin).addConfiguration(name!!, pd)
|
(Kobalt.findPlugin("publish") as PublishPlugin).addConfiguration(name!!, pd)
|
||||||
return pd
|
return pd
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue