From 53cff85983c99a70a6496ecd0928d4cbe72a077f Mon Sep 17 00:00:00 2001 From: "Erik C. Thauvin" Date: Tue, 25 Apr 2017 09:11:06 -0700 Subject: [PATCH] Added pom.xml generation. --- .gitignore | 1 + README.md | 48 ++++++++++---- example/kobalt/src/Build.kt | 6 +- example/pom.xml | 43 +++++++++++++ kobalt/src/Build.kt | 30 +++++++-- pom.xml | 2 +- .../erik/kobalt/plugin/versioneye/Utils.kt | 27 +++++++- .../plugin/versioneye/VersionEyePlugin.kt | 64 ++++++++++++------- 8 files changed, 173 insertions(+), 48 deletions(-) create mode 100644 example/pom.xml diff --git a/.gitignore b/.gitignore index fcb0f44..fbd6166 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,7 @@ **/.idea/tasks.xml **/.idea/workspace.xml *.iws +*.sublime-* .classpath .DS_Store .gradle diff --git a/README.md b/README.md index 98f133e..f33cbf7 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # VersionEye plug-in for [Kobalt](http://beust.com/kobalt/home/index.html) -[![License (3-Clause BSD)](https://img.shields.io/badge/license-BSD%203--Clause-blue.svg?style=flat-square)](http://opensource.org/licenses/BSD-3-Clause) [![Build Status](https://travis-ci.org/ethauvin/kobalt-versioneye.svg?branch=master)](https://travis-ci.org/ethauvin/kobalt-versioneye) [![Download](https://api.bintray.com/packages/ethauvin/maven/kobalt-versioneye/images/download.svg) ](https://bintray.com/ethauvin/maven/kobalt-versioneye/_latestVersion) +[![License (3-Clause BSD)](https://img.shields.io/badge/license-BSD%203--Clause-blue.svg?style=flat-square)](http://opensource.org/licenses/BSD-3-Clause) [![Build Status](https://travis-ci.org/ethauvin/kobalt-versioneye.svg?branch=master)](https://travis-ci.org/ethauvin/kobalt-versioneye) [![Dependency Status](https://www.versioneye.com/user/projects/58ff729f6ac171425cd00acf/badge.svg?style=flat-square)](https://www.versioneye.com/user/projects/58ff729f6ac171425cd00acf) [![Download](https://api.bintray.com/packages/ethauvin/maven/kobalt-versioneye/images/download.svg) ](https://bintray.com/ethauvin/maven/kobalt-versioneye/_latestVersion) [![VersionEye Logo](src/site/images/VersionEyeLogo.png)](https://www.versioneye.com) @@ -90,16 +90,17 @@ versionEye { The values are: -| Value | Description | Default | -| :----------- | :---------------------------------------------------------------------------------------------- | :---------------------------- | -| `baseUrl` | For VersionEye Enterprise VM to use your own domain, e.g. `https://versioneye.my-company.com/` | `https://www.versioneye.com/` | -| `colors` | To enable (`true`) or disable (`false`) colors in the plug-in output. | `true` | -| `name` | The name of the VersionEye project, if none is specified the Kobalt project name will be used. | *none* | -| `quiet` | To completely disable output from the plug-in. | `false` | -| `org` | The VersionEye organization, if any. | *none* | -| `team` | The VersionEye team, if any. | *none* | -| `verbose` | To enable or disable extra information in the plug-in output. | `true` | -| `visibility` | To set the project's visibility on VersionEye, either `public` or `private` | `public` | +| Value | Description | Default | +| :----------- | :--------------------------------------------------------------------------------------------------------------------- | :---------------------------- | +| `baseUrl` | For VersionEye Enterprise VM to use your own domain, e.g. `https://versioneye.my-company.com/` | `https://www.versioneye.com/` | +| `colors` | To enable (`true`) or disable (`false`) colors in the plug-in output. | `true` | +| `name` | The name of the VersionEye project, if none is specified the Kobalt project name will be used. | *none* | +| `quiet` | To completely disable output from the plug-in. | `false` | +| `org` | The VersionEye organization, if any. | *none* | +| `pom` | Generate a [pom.xml](https://maven.apache.org/pom.html) for the project. See [Private vs. Public](#private-vs-public). | `false` | +| `team` | The VersionEye team, if any. | *none* | +| `verbose` | To enable or disable extra information in the plug-in output. | `true` | +| `visibility` | To set the project's visibility on VersionEye, either `public` or `private` | `public` | Some of the parameters can be controlled temporarily from the command line, as follows: @@ -126,4 +127,27 @@ versionEye { | `Fail.dependenciesCheck` | Will triggered a failure on outdated dependencies. | | `Fail.licensesUnknownCheck` | Will trigger a failure on unknown licenses. | | `Fail.licensesCheck` | Will trigger a failure on licenses whitelist violations. Licenses and components whitelists can be configured on the [VersionEye](https://www.versioneye.com/) website. | -| `Fail.securityCheck` | Will trigger a failure on known security vulnerabilities, on by default. | \ No newline at end of file +| `Fail.securityCheck` | Will trigger a failure on known security vulnerabilities, on by default. | + +## Private vs. Public + +By default, projects created using the VersionEye API are private. If your project is hosted on [GitHub](https://github.com) or [BitBucket](https://bitbucket.org) and would like to make it public on VersionEye. The plug-in can generate a [pom](https://maven.apache.org/pom.html) file compatible with VersionEye, as follows: + +``` +versionEye { + pom = true +... +} +``` + +and to generate the pom file, but **not** create a new project on VersionEye: + +```bash +./kobaltw -Dve.create=false versionEye +``` + +Be sure to commit `pom.xml` on GitHub or BitBucket, and then import your project at: + + * https://www.versioneye.com/projects/new + +Finally, configure your [project key](#global-configuration). \ No newline at end of file diff --git a/example/kobalt/src/Build.kt b/example/kobalt/src/Build.kt index db314b4..f7a9d31 100644 --- a/example/kobalt/src/Build.kt +++ b/example/kobalt/src/Build.kt @@ -6,8 +6,8 @@ import net.thauvin.erik.kobalt.plugin.versioneye.* // ./kobaltw versionEye val bs = buildScript { - //plugins(file("../kobaltBuild/libs/kobalt-versioneye-0.4.5.jar")) - plugins("net.thauvin.erik:kobalt-versioneye:") + repos(file("K:/maven/repository")) + plugins("net.thauvin.erik:kobalt-versioneye:0.4.5") } val p = project { @@ -44,8 +44,10 @@ val p = project { // colors = true // name = "" // org = "" + pom = true // quiet = false // team = "" + temp = true // verbose = true // visibility = "public" diff --git a/example/pom.xml b/example/pom.xml new file mode 100644 index 0000000..7b9976b --- /dev/null +++ b/example/pom.xml @@ -0,0 +1,43 @@ + + + 4.0.0 + com.example + example + 0.1 + example + + + + com.beust + jcommander + 1.47 + + + ch.qos.logback + logback-core + 0.5 + + + ch.qos.logback + logback-classic + 1.1.7 + + + commons-httpclient + commons-httpclient + 3.1 + + + com.beust + kobalt-plugin-api + 0.878 + + + org.testng + testng + (0,] + test + + + diff --git a/kobalt/src/Build.kt b/kobalt/src/Build.kt index 11958f8..29e3410 100644 --- a/kobalt/src/Build.kt +++ b/kobalt/src/Build.kt @@ -1,12 +1,20 @@ -import com.beust.kobalt.* + +import com.beust.kobalt.buildScript +import com.beust.kobalt.file import com.beust.kobalt.plugin.packaging.assemble import com.beust.kobalt.plugin.publish.autoGitTag import com.beust.kobalt.plugin.publish.bintray -import org.apache.maven.model.* +import com.beust.kobalt.profile +import com.beust.kobalt.project +import net.thauvin.erik.kobalt.plugin.versioneye.* +import org.apache.maven.model.Developer +import org.apache.maven.model.License +import org.apache.maven.model.Model +import org.apache.maven.model.Scm val bs = buildScript { - plugins("net.thauvin.erik:kobalt-maven-local:") - repos(localMaven()) + repos(file("K:/maven/repository")) + plugins("net.thauvin.erik:kobalt-maven-local:0.5.2", "net.thauvin.erik:kobalt-versioneye:0.4.5") } val dev by profile() @@ -40,7 +48,7 @@ val p = project { dependencies { compile("com.beust:$kobaltDependency:") - compile("com.squareup.okhttp3:logging-interceptor:jar:3.6.0") + compile("com.squareup.okhttp3:logging-interceptor:jar:3.7.0") } dependenciesTest { @@ -48,7 +56,13 @@ val p = project { } assemble { - mavenJars {} + jar { + fatJar = true + } + + mavenJars { + fatJar = true + } } autoGitTag { @@ -61,4 +75,8 @@ val p = project { description = "Release version $version" vcsTag = version } + + versionEye { + pom = true + } } \ No newline at end of file diff --git a/pom.xml b/pom.xml index fc3fc64..7c862bc 100644 --- a/pom.xml +++ b/pom.xml @@ -35,7 +35,7 @@ com.squareup.okhttp3 logging-interceptor - 3.6.0 + 3.7.0 org.testng diff --git a/src/main/kotlin/net/thauvin/erik/kobalt/plugin/versioneye/Utils.kt b/src/main/kotlin/net/thauvin/erik/kobalt/plugin/versioneye/Utils.kt index 57a38fa..c8225a4 100644 --- a/src/main/kotlin/net/thauvin/erik/kobalt/plugin/versioneye/Utils.kt +++ b/src/main/kotlin/net/thauvin/erik/kobalt/plugin/versioneye/Utils.kt @@ -67,6 +67,27 @@ open class Utils { } + fun red(text: String, colors: Boolean = true): String { + if (!colors) { + return text + } + return AsciiArt.RED + text + AsciiArt.RESET + } + + fun yellow(text: String, colors: Boolean = true): String { + if (!colors) { + return text + } + return AsciiArt.YELLOW + text + AsciiArt.RESET + } + + fun green(text: String, colors: Boolean = true): String { + if (!colors) { + return text + } + return AsciiArt.GREEN + text + AsciiArt.RESET + } + fun redLight(count: Int, fail: Boolean, colors: Boolean): String { return redLight(count.toString(), count, fail, colors) } @@ -75,11 +96,11 @@ open class Utils { fun redLight(text: String, count: Int, fail: Boolean, colors: Boolean): String { if (colors) { if (fail && count > 0) { - return AsciiArt.RED + text + AsciiArt.RESET + return red(text) } else if (count > 0) { - return AsciiArt.YELLOW + text + AsciiArt.RESET + return yellow(text) } else { - return AsciiArt.GREEN + text + AsciiArt.RESET + return green(text) } } return text diff --git a/src/main/kotlin/net/thauvin/erik/kobalt/plugin/versioneye/VersionEyePlugin.kt b/src/main/kotlin/net/thauvin/erik/kobalt/plugin/versioneye/VersionEyePlugin.kt index 2b48a4b..115a355 100644 --- a/src/main/kotlin/net/thauvin/erik/kobalt/plugin/versioneye/VersionEyePlugin.kt +++ b/src/main/kotlin/net/thauvin/erik/kobalt/plugin/versioneye/VersionEyePlugin.kt @@ -36,13 +36,16 @@ import com.beust.kobalt.TaskResult import com.beust.kobalt.api.* import com.beust.kobalt.api.annotation.Directive import com.beust.kobalt.api.annotation.Task -import com.beust.kobalt.misc.* +import com.beust.kobalt.misc.KobaltLogger +import com.beust.kobalt.misc.log +import com.beust.kobalt.misc.warn import com.google.gson.GsonBuilder import com.google.gson.JsonObject import com.google.inject.Inject import com.google.inject.Singleton import okhttp3.* import okhttp3.logging.HttpLoggingInterceptor +import java.io.File import java.io.FileOutputStream import java.nio.file.Files import java.nio.file.Paths @@ -53,13 +56,14 @@ class VersionEyePlugin @Inject constructor(val configActor: ConfigActor by configActor { private val API_KEY_PROPERTY = "versioneye.apiKey" - private val PROJECT_KEY_PROPERTY = "versioneye.projectKey" private val COLORS_PROPERTY = "ve.colors" - private val VERBOSE_PROPERTY = "ve.verbose" + private val CREATE_PROPERTY = "ve.create" + private val PROJECT_KEY_PROPERTY = "versioneye.projectKey" private val QUIET_PROPERTY = "ve.quiet" + private val VERBOSE_PROPERTY = "ve.verbose" private val debug = System.getProperty("ve.debug", "false").toBoolean() - private val fiddler = System.getProperty("ve.fiddler", "false").toBoolean() + private val proxy = System.getProperty("ve.proxy", "-1").toInt() private val httpClient = if (!debug) { OkHttpClient() @@ -86,13 +90,12 @@ class VersionEyePlugin @Inject constructor(val configActor: ConfigActor - p.store(output, "") + p.store(output, null) } return result @@ -193,15 +210,13 @@ class VersionEyePlugin @Inject constructor(val configActor: ConfigActor = mutableSetOf(Fail.securityCheck) var name = "" var org = "" + var pom = false var quiet = false var team = "" + var temp = false var verbose = true var visibility = "public"