Initial commit.

This commit is contained in:
Erik C. Thauvin 2016-07-27 15:51:42 -07:00
commit 27f1f3e9cc
25 changed files with 635 additions and 0 deletions

29
.gitignore vendored Normal file
View file

@ -0,0 +1,29 @@
**/.idea/dictionaries
**/.idea/gradle.xml
**/.idea/libraries
**/.idea/tasks.xml
**/.idea/workspace.xml
*.iws
.DS_Store
.classpath
.gradle
.kobalt
.nb-gradle
.project
.settings
/bin
/build
/deploy
/dist
/example/libs
/gen
/gradle.properties
/out
/proguard-project.txt
/project.properties
/target
/test-output
Thumbs.db
ehthumbs.db
kobaltBuild
local.properties

23
.idea/compiler.xml generated Normal file
View file

@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CompilerConfiguration">
<option name="DEFAULT_COMPILER" value="Javac" />
<resourceExtensions />
<wildcardResourcePatterns>
<entry name="!?*.java" />
<entry name="!?*.form" />
<entry name="!?*.class" />
<entry name="!?*.groovy" />
<entry name="!?*.scala" />
<entry name="!?*.flex" />
<entry name="!?*.kt" />
<entry name="!?*.clj" />
<entry name="!?*.aj" />
</wildcardResourcePatterns>
<annotationProcessing>
<profile default="true" name="Default" enabled="false">
<processorPath useClasspath="true" />
</profile>
</annotationProcessing>
</component>
</project>

3
.idea/copyright/profiles_settings.xml generated Normal file
View file

@ -0,0 +1,3 @@
<component name="CopyrightManager">
<settings default="" />
</component>

6
.idea/encodings.xml generated Normal file
View file

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Encoding">
<file url="PROJECT" charset="UTF-8" />
</component>
</project>

View file

@ -0,0 +1,53 @@
<component name="InspectionProjectProfileManager">
<profile version="1.0">
<option name="myName" value="Project Default" />
<option name="myLocal" value="true" />
<inspection_tool class="FieldMayBeFinal" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="JavaDoc" enabled="true" level="WARNING" enabled_by_default="true">
<option name="TOP_LEVEL_CLASS_OPTIONS">
<value>
<option name="ACCESS_JAVADOC_REQUIRED_FOR" value="none" />
<option name="REQUIRED_TAGS" value="" />
</value>
</option>
<option name="INNER_CLASS_OPTIONS">
<value>
<option name="ACCESS_JAVADOC_REQUIRED_FOR" value="none" />
<option name="REQUIRED_TAGS" value="" />
</value>
</option>
<option name="METHOD_OPTIONS">
<value>
<option name="ACCESS_JAVADOC_REQUIRED_FOR" value="none" />
<option name="REQUIRED_TAGS" value="@return@param@throws or @exception" />
</value>
</option>
<option name="FIELD_OPTIONS">
<value>
<option name="ACCESS_JAVADOC_REQUIRED_FOR" value="none" />
<option name="REQUIRED_TAGS" value="" />
</value>
</option>
<option name="IGNORE_DEPRECATED" value="false" />
<option name="IGNORE_JAVADOC_PERIOD" value="true" />
<option name="IGNORE_DUPLICATED_THROWS" value="false" />
<option name="IGNORE_POINT_TO_ITSELF" value="false" />
<option name="myAdditionalJavadocTags" value="created" />
</inspection_tool>
<inspection_tool class="LocalCanBeFinal" enabled="true" level="WARNING" enabled_by_default="true">
<option name="REPORT_VARIABLES" value="true" />
<option name="REPORT_PARAMETERS" value="false" />
<option name="REPORT_CATCH_PARAMETERS" value="false" />
</inspection_tool>
<inspection_tool class="LoggerInitializedWithForeignClass" enabled="false" level="WARNING" enabled_by_default="false">
<option name="loggerClassName" value="org.apache.log4j.Logger,org.slf4j.LoggerFactory,org.apache.commons.logging.LogFactory,java.util.logging.Logger" />
<option name="loggerFactoryMethodName" value="getLogger,getLogger,getLog,getLogger" />
</inspection_tool>
<inspection_tool class="UnnecessarySemicolon" enabled="false" level="WARNING" enabled_by_default="false" />
<inspection_tool class="WeakerAccess" enabled="true" level="WARNING" enabled_by_default="true">
<option name="SUGGEST_PACKAGE_LOCAL_FOR_MEMBERS" value="true" />
<option name="SUGGEST_PACKAGE_LOCAL_FOR_TOP_CLASSES" value="false" />
<option name="SUGGEST_PRIVATE_FOR_INNERS" value="false" />
</inspection_tool>
</profile>
</component>

View file

@ -0,0 +1,7 @@
<component name="InspectionProjectProfileManager">
<settings>
<option name="PROJECT_PROFILE" value="Project Default" />
<option name="USE_PROJECT_PROFILE" value="true" />
<version value="1.0" />
</settings>
</component>

17
.idea/kobalt.xml generated Normal file
View file

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="KobaltSettings">
<option name="linkedExternalProjectsSettings">
<KobaltProjectSettings>
<option name="autoDownloadKobalt" value="true" />
<option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="kobaltHome" value="$USER_HOME$/.kobalt/wrapper/dist/kobalt-0.871" />
<option name="modules">
<set>
<option value="$PROJECT_DIR$" />
</set>
</option>
</KobaltProjectSettings>
</option>
</component>
</project>

100
.idea/misc.xml generated Normal file
View file

@ -0,0 +1,100 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ClientPropertiesManager">
<properties class="javax.swing.AbstractButton">
<property name="hideActionText" class="java.lang.Boolean" />
</properties>
<properties class="javax.swing.JComponent">
<property name="html.disable" class="java.lang.Boolean" />
</properties>
<properties class="javax.swing.JEditorPane">
<property name="JEditorPane.w3cLengthUnits" class="java.lang.Boolean" />
<property name="JEditorPane.honorDisplayProperties" class="java.lang.Boolean" />
<property name="charset" class="java.lang.String" />
</properties>
<properties class="javax.swing.JList">
<property name="List.isFileList" class="java.lang.Boolean" />
</properties>
<properties class="javax.swing.JPasswordField">
<property name="JPasswordField.cutCopyAllowed" class="java.lang.Boolean" />
</properties>
<properties class="javax.swing.JSlider">
<property name="Slider.paintThumbArrowShape" class="java.lang.Boolean" />
<property name="JSlider.isFilled" class="java.lang.Boolean" />
</properties>
<properties class="javax.swing.JTable">
<property name="Table.isFileList" class="java.lang.Boolean" />
<property name="JTable.autoStartsEdit" class="java.lang.Boolean" />
<property name="terminateEditOnFocusLost" class="java.lang.Boolean" />
</properties>
<properties class="javax.swing.JToolBar">
<property name="JToolBar.isRollover" class="java.lang.Boolean" />
</properties>
<properties class="javax.swing.JTree">
<property name="JTree.lineStyle" class="java.lang.String" />
</properties>
<properties class="javax.swing.text.JTextComponent">
<property name="caretAspectRatio" class="java.lang.Double" />
<property name="caretWidth" class="java.lang.Integer" />
</properties>
</component>
<component name="EntryPointsManager">
<entry_points version="2.0" />
</component>
<component name="MavenImportPreferences">
<option name="generalSettings">
<MavenGeneralSettings>
<option name="mavenHome" value="Bundled (Maven 3)" />
</MavenGeneralSettings>
</option>
</component>
<component name="ProjectInspectionProfilesVisibleTreeState">
<entry key="Project Default">
<profile-state>
<expanded-state>
<State>
<id />
</State>
<State>
<id>Android Lint</id>
</State>
<State>
<id>Java</id>
</State>
<State>
<id>Portability issuesJava</id>
</State>
</expanded-state>
</profile-state>
</entry>
</component>
<component name="ProjectLevelVcsManager" settingsEditedManually="false">
<OptionsSetting value="true" id="Add" />
<OptionsSetting value="true" id="Remove" />
<OptionsSetting value="true" id="Checkout" />
<OptionsSetting value="true" id="Update" />
<OptionsSetting value="true" id="Status" />
<OptionsSetting value="true" id="Edit" />
<ConfirmationsSetting value="0" id="Add" />
<ConfirmationsSetting value="0" id="Remove" />
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_6" assert-keyword="true" jdk-15="true" project-jdk-name="1.8.x" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/kobaltBuild/classes" />
</component>
<component name="masterDetails">
<states>
<state key="ProjectJDKs.UI">
<settings>
<last-edited>1.8.x</last-edited>
<splitter-proportions>
<option name="proportions">
<list>
<option value="0.19944212" />
</list>
</option>
</splitter-proportions>
</settings>
</state>
</states>
</component>
</project>

9
.idea/modules.xml generated Normal file
View file

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/kobalt/Build.kt.iml" filepath="$PROJECT_DIR$/kobalt/Build.kt.iml" />
<module fileurl="file://$PROJECT_DIR$/kobalt-versioneye.iml" filepath="$PROJECT_DIR$/kobalt-versioneye.iml" />
</modules>
</component>
</project>

View file

@ -0,0 +1,48 @@
import com.beust.kobalt.*
import com.beust.kobalt.plugin.packaging.*
import com.beust.kobalt.plugin.application.*
import com.beust.kobalt.plugin.kotlin.*
import net.thauvin.erik.kobalt.plugin.versioneye.*
val repos = repos()
val pl = plugins(file("../kobaltBuild/libs/kobalt-versioneye-0.4.0-beta.jar"))
//val pl = plugins("net.thauvin.erik:kobalt-maven-local:0.5.0")
val p = project {
name = "example"
group = "com.example"
artifactId = name
version = "0.1"
sourceDirectories {
path("src/main/kotlin")
}
sourceDirectoriesTest {
path("src/test/kotlin")
}
dependencies {
// compile("com.beust:jcommander:1.48")
}
dependenciesTest {
compile("org.testng:testng:")
}
assemble {
jar {
}
}
application {
mainClass = "com.example.MainKt"
}
versionEye {
//baseUrl = ""
}
}

Binary file not shown.

View file

@ -0,0 +1 @@
kobalt.version=0.871

2
example/kobaltw Normal file
View file

@ -0,0 +1,2 @@
#!/usr/bin/env sh
java -jar "`dirname "$0"`/kobalt/wrapper/kobalt-wrapper.jar" $*

4
example/kobaltw.bat Normal file
View file

@ -0,0 +1,4 @@
@echo off
set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
java -jar "%DIRNAME%/kobalt/wrapper/kobalt-wrapper.jar" %*

View file

@ -0,0 +1,3 @@
package com.example
fun main(args: Array<String>) = println("\n\nHello Kotlin world from Kobalt\n\n")

View file

@ -0,0 +1,8 @@
package com.example
import org.testng.annotations.Test
class ExampleTest {
@Test
fun f() = println("Running test")
}

37
kobalt-versioneye.iml Normal file
View file

@ -0,0 +1,37 @@
<?xml version="1.0" encoding="UTF-8"?>
<module external.linked.project.id="kobalt-versioneye" external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$" external.system.id="KOBALT" type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="false">
<output url="file://$MODULE_DIR$/kobaltBuild/classes" />
<output-test url="file://$MODULE_DIR$/kobaltBuild/test-classes" />
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/kotlin" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/kotlin" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/resources" type="java-test-resource" />
<excludeFolder url="file://$MODULE_DIR$/kobaltBuild" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="module-library">
<library name="Kobalt: com.beust:kobalt-plugin-api:jar:0.863">
<CLASSES>
<root url="jar://$USER_HOME$/.kobalt/cache/com/beust/kobalt-plugin-api/0.863/kobalt-plugin-api-0.863.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</orderEntry>
<orderEntry type="module-library" scope="TEST">
<library name="Kobalt: org.testng:testng:jar:6.9.10">
<CLASSES>
<root url="jar://$USER_HOME$/.kobalt/cache/org/testng/testng/6.9.10/testng-6.9.10.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</orderEntry>
</component>
</module>

12
kobalt/Build.kt.iml Normal file
View file

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<module version="4">
<component name="NewModuleRootManager" inherit-compiler-output="false">
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="KotlinJavaRuntime" level="project" />
<orderEntry type="library" name="kobalt.jar" level="project" />
</component>
</module>

63
kobalt/src/Build.kt Normal file
View file

@ -0,0 +1,63 @@
import com.beust.kobalt.plugin.packaging.assemble
import com.beust.kobalt.plugin.publish.bintray
import com.beust.kobalt.project
import com.beust.kobalt.repos
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 repos = repos()
val p = project {
name = "kobalt-versioneye"
group = "net.thauvin.erik"
artifactId = name
version = "0.4.0-beta"
pom = Model().apply {
description = "VersionEye plug-in for the Kobalt build system."
url = "https://github.com/ethauvin/kobalt-versioneye"
licenses = listOf(License().apply {
name = "BSD 3-Clause"
url = "https://opensource.org/licenses/BSD-3-Clause"
})
scm = Scm().apply {
url = "https://github.com/ethauvin/kobalt-versioneye"
connection = "https://github.com/ethauvin/kobalt-versioneye.git"
developerConnection = "git@github.com:ethauvin/kobalt-versioneye.git"
}
developers = listOf(Developer().apply {
id = "ethauvin"
name = "Erik C. Thauvin"
email = "erik@thauvin.net"
})
}
sourceDirectories {
path("src/main/kotlin")
}
sourceDirectoriesTest {
path("src/test/kotlin")
}
dependencies {
compile("com.beust:kobalt-plugin-api:0.863")
}
dependenciesTest {
compile("org.testng:testng:")
}
assemble {
mavenJars {}
}
bintray {
publish = true
}
}

Binary file not shown.

View file

@ -0,0 +1 @@
kobalt.version=0.871

2
kobaltw Normal file
View file

@ -0,0 +1,2 @@
#!/usr/bin/env sh
java -jar "`dirname "$0"`/kobalt/wrapper/kobalt-wrapper.jar" $*

4
kobaltw.bat Normal file
View file

@ -0,0 +1,4 @@
@echo off
set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
java -jar "%DIRNAME%/kobalt/wrapper/kobalt-wrapper.jar" %*

View file

@ -0,0 +1,197 @@
/*
* VersionEyePlugin.kt
*
* Copyright (c) 2016, Erik C. Thauvin (erik@thauvin.net)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* Neither the name of this project nor the names of its contributors may be
* used to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.thauvin.erik.kobalt.plugin.versioneye
import com.beust.kobalt.Plugins
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.warn
import com.google.gson.GsonBuilder
import com.google.gson.JsonObject
import com.google.inject.Inject
import com.google.inject.Singleton
import okhttp3.*
import java.io.File
import java.io.FileOutputStream
import java.nio.file.Files
import java.nio.file.Paths
import java.util.*
@Singleton
class VersionEyePlugin @Inject constructor(val configActor: ConfigActor<VersionEyeConfig>,
val taskContributor: TaskContributor) :
BasePlugin(), ITaskContributor, IConfigActor<VersionEyeConfig> by configActor {
private val debug = true
private val API_KEY_PROPERTY = "versioneye.apiKey"
private val PROJECT_KEY_PROPERTY = "versioneye.projectKey"
private val PROJECT_ID_PROPERTY = "versioneye.projectId"
private val ORG_PROPERTY = "versioneye.organisation"
private val TEAM_PROPERTY = "versioneye.team"
private val httpClient = OkHttpClient()
// ITaskContributor
override fun tasksFor(project: Project, context: KobaltContext): List<DynamicTask> = taskContributor.dynamicTasks
companion object {
const val NAME: String = "VersionEye"
}
override val name = NAME
override fun apply(project: Project, context: KobaltContext) {
super.apply(project, context)
taskContributor.addVariantTasks(this, project, context, "versionEye", group = "publish",
runTask = { versionEye(project) })
}
@Task(name = "versionEye", description = "Update and check dependencies on VersionEye")
fun versionEye(project: Project): TaskResult {
if (debug) {
System.setProperty("http.proxyHost", "127.0.0.1")
System.setProperty("https.proxyHost", "127.0.0.1")
System.setProperty("http.proxyPort", "8888");
System.setProperty("https.proxyPort", "8888")
}
val local = project.directory + "/local.properties"
configurationFor(project)?.let { config ->
if (config.baseUrl.isBlank()) {
warn("Please specify a valid VersionEye base URL.")
return TaskResult()
} else {
var apiKey = System.getProperty(API_KEY_PROPERTY)
val p = Properties()
Paths.get(local).let { path ->
if (path.toFile().exists()) {
Files.newInputStream(path).use {
p.load(it)
}
}
}
if (apiKey.isNullOrBlank()) {
apiKey = p.getProperty(API_KEY_PROPERTY)
if (apiKey.isNullOrBlank()) {
warn("Please provide a valid VersionEye API key.")
return TaskResult()
}
}
p.setProperty(API_KEY_PROPERTY, apiKey)
val result = versionEyeUpdate(if (config.name.isNotBlank()) {
config.name
} else {
project.name
}, config, p)
FileOutputStream(local).use { output ->
p.store(output, "")
}
return result
}
}
return TaskResult()
}
private fun versionEyeUpdate(name: String, config: VersionEyeConfig, p: Properties): TaskResult {
val projectId = p.getProperty(PROJECT_ID_PROPERTY)
val apiKey = p.getProperty(API_KEY_PROPERTY);
val endPoint = if (projectId.isNullOrBlank()) {
"api/v2/projects"
} else {
"api/v2/project/$projectId"
}
val file = File("../kobaltBuild/libs/kobalt-versioneye-0.4.0-beta.pom")
val requestBody = MultipartBody.Builder()
.setType(MultipartBody.FORM)
.addFormDataPart("name", name)
.addFormDataPart("upload", file.name, RequestBody.create(MediaType.parse("application/octet-stream"), file))
if (config.organisation.isNotBlank()) {
requestBody.addFormDataPart("orga_name", config.organisation)
}
if (config.team.isNotBlank()) {
requestBody.addFormDataPart("team_name", config.team)
}
// @TODO remove
requestBody.addFormDataPart("temp", "true")
val url = HttpUrl.parse(config.baseUrl).newBuilder()
.addPathSegments(endPoint)
.setQueryParameter("api_key", apiKey)
.build()
val request = Request.Builder()
.url(url)
.post(requestBody.build())
.build()
val response = httpClient.newCall(request).execute()
if (!response.isSuccessful) {
warn("Unexpected response from VersionEye: " + response)
return TaskResult()
} else {
val builder = GsonBuilder()
val o = builder.create().fromJson(response.body().charStream(), JsonObject::class.java)
println(o)
}
return TaskResult()
}
}
@Directive
class VersionEyeConfig() {
var baseUrl = "https://www.versioneye.com/"
var failOnUnknownLicense = false;
var licenseCheck = false;
var name = "";
var organisation = "";
var securityCheck = false;
var team = "";
var visibility = true;
}
@Directive
fun Project.versionEye(init: VersionEyeConfig.() -> Unit) {
VersionEyeConfig().let { config ->
config.init()
(Plugins.findPlugin(VersionEyePlugin.NAME) as VersionEyePlugin).addConfiguration(this, config)
}
}

View file

@ -0,0 +1,6 @@
<kobalt-plugin>
<name>VersionEye</name>
<plugin-actors>
<class-name>net.thauvin.erik.kobalt.plugin.versioneye.VersionEyePlugin</class-name>
</plugin-actors>
</kobalt-plugin>