Kotlin 1.1 and Kobalt 1.0.x optimization

This commit is contained in:
Erik C. Thauvin 2017-03-06 14:27:18 -08:00
parent 05ec95cfac
commit 58c5f69792
5 changed files with 15 additions and 16 deletions

View file

@ -11,7 +11,9 @@ To use the plug-in include the following in `Build.kt` file:
```kotlin ```kotlin
import net.thauvin.erik.kobalt.plugin.versioneye.* import net.thauvin.erik.kobalt.plugin.versioneye.*
val pl = plugins("net.thauvin.erik:kobalt-versioneye:") val bs = buildScript {
plugins("net.thauvin.erik:kobalt-versioneye:")
}
val p = project { val p = project {
name = "example" name = "example"

View file

@ -4,10 +4,9 @@ import com.beust.kobalt.plugin.application.*
import com.beust.kobalt.plugin.kotlin.* import com.beust.kobalt.plugin.kotlin.*
import net.thauvin.erik.kobalt.plugin.versioneye.* import net.thauvin.erik.kobalt.plugin.versioneye.*
val repos = repos() val bs = buildScript {
plugins("net.thauvin.erik:kobalt-versioneye:0.4.3-beta")
//val pl = plugins(file("../kobaltBuild/libs/kobalt-versioneye-0.4.3-beta.jar")) }
val pl = plugins("net.thauvin.erik:kobalt-versioneye:0.4.3-beta")
val p = project { val p = project {

View file

@ -1,15 +1,11 @@
import com.beust.kobalt.plugin.packaging.assemble import com.beust.kobalt.plugin.packaging.assemble
import com.beust.kobalt.plugin.publish.bintray import com.beust.kobalt.plugin.publish.bintray
import com.beust.kobalt.project import com.beust.kobalt.project
import com.beust.kobalt.repos
import org.apache.maven.model.Developer import org.apache.maven.model.Developer
import org.apache.maven.model.License import org.apache.maven.model.License
import org.apache.maven.model.Model import org.apache.maven.model.Model
import org.apache.maven.model.Scm import org.apache.maven.model.Scm
val repos = repos()
val p = project { val p = project {
name = "kobalt-versioneye" name = "kobalt-versioneye"

View file

@ -1,7 +1,7 @@
/* /*
* Utils.kt * Utils.kt
* *
* Copyright (c) 2016, Erik C. Thauvin (erik@thauvin.net) * Copyright (c) 2016-2017, Erik C. Thauvin (erik@thauvin.net)
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@ -52,7 +52,7 @@ open class Utils {
// Log text if applicable // Log text if applicable
fun log(text: StringBuilder, flag: Boolean, level: Int = 1) { fun log(text: StringBuilder, flag: Boolean, level: Int = 1) {
if (flag && text.length > 0) { if (flag && text.isNotEmpty()) {
log(level, text) log(level, text)
} }
} }

View file

@ -1,7 +1,7 @@
/* /*
* VersionEyePlugin.kt * VersionEyePlugin.kt
* *
* Copyright (c) 2016, Erik C. Thauvin (erik@thauvin.net) * Copyright (c) 2016-2017, Erik C. Thauvin (erik@thauvin.net)
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@ -278,10 +278,10 @@ class VersionEyePlugin @Inject constructor(val configActor: ConfigActor<VersionE
val onWhitelist = license.get("on_whitelist") val onWhitelist = license.get("on_whitelist")
val onCwl = license.get("on_cwl") val onCwl = license.get("on_cwl")
if (!onWhitelist.isJsonNull) { if (!onWhitelist.isJsonNull) {
if (onWhitelist.asString.equals("false")) { if (onWhitelist.asString == "false") {
if (onCwl.isJsonNull) { if (onCwl.isJsonNull) {
whitelisted++ whitelisted++
} else if (!onCwl.toString().equals("true")) { } else if (onCwl.toString() != "true") {
whitelisted++ whitelisted++
} }
} }
@ -314,7 +314,7 @@ class VersionEyePlugin @Inject constructor(val configActor: ConfigActor<VersionE
// Security vulnerabilities // Security vulnerabilities
val security = dep.get("security_vulnerabilities") val security = dep.get("security_vulnerabilities")
if (!security.isJsonNull) { if (!security.isJsonNull) {
if (securityInfo.length > 0) { if (securityInfo.isNotEmpty()) {
securityInfo.append(lf) securityInfo.append(lf)
} }
val count = security.asJsonArray.size() val count = security.asJsonArray.size()
@ -370,7 +370,7 @@ enum class Fail {
} }
@Directive @Directive
class VersionEyeConfig() { class VersionEyeConfig {
var baseUrl = "https://www.versioneye.com/" var baseUrl = "https://www.versioneye.com/"
var colors = true var colors = true
val failSet: MutableSet<Fail> = mutableSetOf(Fail.securityCheck) val failSet: MutableSet<Fail> = mutableSetOf(Fail.securityCheck)
@ -381,6 +381,7 @@ class VersionEyeConfig() {
var verbose = true var verbose = true
var visibility = "public" var visibility = "public"
@Suppress("unused")
fun failOn(vararg args: Fail) { fun failOn(vararg args: Fail) {
if (failSet.isNotEmpty()) { if (failSet.isNotEmpty()) {
failSet.clear() failSet.clear()
@ -389,6 +390,7 @@ class VersionEyeConfig() {
} }
} }
@Suppress("unused")
@Directive @Directive
fun Project.versionEye(init: VersionEyeConfig.() -> Unit) { fun Project.versionEye(init: VersionEyeConfig.() -> Unit) {
VersionEyeConfig().let { config -> VersionEyeConfig().let { config ->