commit 71c48e2f6542faa939f532e877e2c4d227dbd51e Author: Cedric Beust Date: Mon Nov 9 20:15:06 2015 -0800 Initial commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..14262c0 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +.idea/workspace.xml +.idea/tasks.xml +.kobalt diff --git a/.idea/.name b/.idea/.name new file mode 100644 index 0000000..52200d2 --- /dev/null +++ b/.idea/.name @@ -0,0 +1 @@ +apt-example \ No newline at end of file diff --git a/.idea/compiler.xml b/.idea/compiler.xml new file mode 100644 index 0000000..9a8b7e5 --- /dev/null +++ b/.idea/compiler.xml @@ -0,0 +1,22 @@ + + + + + \ No newline at end of file diff --git a/.idea/encodings.xml b/.idea/encodings.xml new file mode 100644 index 0000000..97626ba --- /dev/null +++ b/.idea/encodings.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/libraries/KotlinJavaRuntime.xml b/.idea/libraries/KotlinJavaRuntime.xml new file mode 100644 index 0000000..c630c0b --- /dev/null +++ b/.idea/libraries/KotlinJavaRuntime.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..9793229 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..c71e8e9 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/Build.kt b/Build.kt new file mode 100644 index 0000000..94ed7a8 --- /dev/null +++ b/Build.kt @@ -0,0 +1,42 @@ + +import com.beust.kobalt.* +import com.beust.kobalt.plugin.application.* +import com.beust.kobalt.plugin.java.* +import com.beust.kobalt.plugin.packaging.* +import com.beust.kobalt.plugin.packaging.* + +val processor = javaProject { + name = "processor" + version = "0.1" + directory = "processor" + + assemble { + jar { + } + } +} + +val processorExample = javaProject(processor) { + name = "example" + group = "com.beust" + artifactId = name + version = "0.1" + directory = "example" + + dependencies { + compile(file("../processor/kobaltBuild/libs/processor-0.1.jar")) + } + + assemble { + jar { + fatJar = true + manifest { + attributes("Main-Class", "com.beust.apt.example.Example") + } + } + } + + application { + mainClass = "com.beust.apt.example.Example" + } +} diff --git a/apt-example.iml b/apt-example.iml new file mode 100644 index 0000000..245d342 --- /dev/null +++ b/apt-example.iml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/example/example.iml b/example/example.iml new file mode 100644 index 0000000..38412a8 --- /dev/null +++ b/example/example.iml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/example/src/main/java/com/beust/apt/example/Example.java b/example/src/main/java/com/beust/apt/example/Example.java new file mode 100644 index 0000000..dde1faf --- /dev/null +++ b/example/src/main/java/com/beust/apt/example/Example.java @@ -0,0 +1,15 @@ +package com.beust.apt.example; + +import com.beust.apt.processor.Version; + +@Version("1.2") +class Example { + public Example() { + System.out.println("Instantiating Example"); + } + + public static void main(String[] argv) { + new Example(); + } + +} \ No newline at end of file diff --git a/kobalt/src/Build.kt b/kobalt/src/Build.kt new file mode 100644 index 0000000..1c502d7 --- /dev/null +++ b/kobalt/src/Build.kt @@ -0,0 +1,123 @@ + +import com.beust.kobalt.api.License +import com.beust.kobalt.api.Scm +import com.beust.kobalt.homeDir +import com.beust.kobalt.internal.test +import com.beust.kobalt.plugin.application.application +import com.beust.kobalt.plugin.java.javaProject +import com.beust.kobalt.plugin.kotlin.kotlinCompiler +import com.beust.kobalt.plugin.kotlin.kotlinProject +import com.beust.kobalt.plugin.packaging.assemble +import com.beust.kobalt.plugin.publish.jcenter +import com.beust.kobalt.repos +import java.io.File + +val r = repos("http://repo.spongepowered.org/maven") + + +val wrapper = javaProject { + name = "kobalt-wrapper" + version = readVersion() + directory = "modules/wrapper" + + assemble { + jar { + name = projectName + ".jar" + manifest { + attributes("Main-Class", "com.beust.kobalt.wrapper.Main") + } + } + } + + application { + mainClass = "com.beust.kobalt.wrapper.Main" + jvmArgs("-Dtest=foo") + } +} + +val kobalt = kotlinProject(wrapper) { + name = "kobalt" + group = "com.beust" + artifactId = name + version = readVersion() + description = "A build system in Kotlin" + url = "http://beust.com/kobalt" + licenses = arrayListOf(License("Apache 2.0", "http://www.apache.org/licenses/LICENSE-2.0")) + scm = Scm(url = "http://github.com/cbeust/kobalt", + connection = "https://github.com/cbeust/kobalt.git", + developerConnection = "git@github.com:cbeust/kobalt.git") + + dependenciesTest { + compile("org.testng:testng:6.9.9") + } + + dependencies { + compile("org.jetbrains.kotlin:kotlin-stdlib:1.0.0-beta-1038", + "org.jetbrains.kotlin:kotlin-compiler-embeddable:1.0.0-beta-1038", + "org.spongepowered:spongeapi:2.1-SNAPSHOT", + + // file(homeDir("java/jcommander/target/jcommander-1.47.jar")), + "com.beust:jcommander:1.48", + "com.squareup.okhttp:okhttp:2.5.0", + "org.jsoup:jsoup:1.8.3", + "com.google.inject:guice:4.0", + "com.google.inject.extensions:guice-assistedinject:4.0", + "javax.inject:javax.inject:1", + "com.google.guava:guava:19.0-rc2", + "org.apache.maven:maven-model:3.3.3", + "com.github.spullara.mustache.java:compiler:0.9.1", + "io.reactivex:rxjava:1.0.14", + "com.google.code.gson:gson:2.4" + ) + } + + assemble { + mavenJars { + fatJar = true + manifest { + attributes("Main-Class", "com.beust.kobalt.MainKt") + } + } + zip { + include("kobaltw") + include(from("$buildDirectory/libs"), to("kobalt/wrapper"), + "$projectName-$version.jar") + include(from("modules/wrapper/$buildDirectory/libs"), to("kobalt/wrapper"), + "$projectName-wrapper.jar") + } + } + + test { + args("-log", "2", "src/test/resources/testng.xml") + } + + kotlinCompiler { + args("-nowarn") + } + + jcenter { + publish = true + file("$buildDirectory/libs/$name-$version.zip", "$name/$version/$name-$version.zip") + } +} + +fun readVersion() : String { + val p = java.util.Properties() + var localFile = java.io.File("src/main/resources/kobalt.properties") + if (! localFile.exists()) { + localFile = File(homeDir("kotlin", "kobalt", "src/main/resources/kobalt.properties")) + } + p.load(java.io.FileReader(localFile)) + return p.getProperty("kobalt.version") +} + +//import com.beust.kobalt.plugin.linecount.lineCount +//val plugins = plugins( +// "com.beust.kobalt:kobalt-line-count:0.15" +//// file(homeDir("kotlin/kobalt-line-count/kobaltBuild/libs/kobalt-line-count-0.14.jar")) +//) +// +//val lc = lineCount { +// suffix = "**.md" +//} + diff --git a/kobalt/wrapper/kobalt-wrapper.jar b/kobalt/wrapper/kobalt-wrapper.jar new file mode 100644 index 0000000..ef904a4 Binary files /dev/null and b/kobalt/wrapper/kobalt-wrapper.jar differ diff --git a/kobalt/wrapper/kobalt-wrapper.properties b/kobalt/wrapper/kobalt-wrapper.properties new file mode 100644 index 0000000..eee113f --- /dev/null +++ b/kobalt/wrapper/kobalt-wrapper.properties @@ -0,0 +1 @@ +kobalt.version=0.234 \ No newline at end of file diff --git a/kobaltw b/kobaltw new file mode 100644 index 0000000..b27b3d8 --- /dev/null +++ b/kobaltw @@ -0,0 +1 @@ +java -jar $(dirname $0)/kobalt/wrapper/kobalt-wrapper.jar $* diff --git a/processor/processor.iml b/processor/processor.iml new file mode 100644 index 0000000..bdb8176 --- /dev/null +++ b/processor/processor.iml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/processor/src/main/java/com/beust/apt/processor/MainProcessor.java b/processor/src/main/java/com/beust/apt/processor/MainProcessor.java new file mode 100644 index 0000000..330550a --- /dev/null +++ b/processor/src/main/java/com/beust/apt/processor/MainProcessor.java @@ -0,0 +1,21 @@ +package com.beust.apt.processor; + +import javax.annotation.processing.AbstractProcessor; +import javax.annotation.processing.RoundEnvironment; +import javax.lang.model.element.TypeElement; +import java.util.HashSet; +import java.util.Set; + +public class MainProcessor extends AbstractProcessor { + @Override + public boolean process(Set annotations, RoundEnvironment roundEnv) { + System.out.println("Processing annotations $annotations"); + return true; + } + + public Set getSupportedAnnotationTypes() { + Set result = new HashSet<>(); + result.add("Version"); + return result; + } +} diff --git a/processor/src/main/java/com/beust/apt/processor/Version.java b/processor/src/main/java/com/beust/apt/processor/Version.java new file mode 100644 index 0000000..470163b --- /dev/null +++ b/processor/src/main/java/com/beust/apt/processor/Version.java @@ -0,0 +1,12 @@ +package com.beust.apt.processor; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Retention(RetentionPolicy.RUNTIME) +@Target(ElementType.TYPE) +public @interface Version { + String value(); +} diff --git a/processor/src/main/resources/META-INF/services/javax.annotation.processing.Processor b/processor/src/main/resources/META-INF/services/javax.annotation.processing.Processor new file mode 100644 index 0000000..ac0fb56 --- /dev/null +++ b/processor/src/main/resources/META-INF/services/javax.annotation.processing.Processor @@ -0,0 +1 @@ +com.beust.apt.processor.MainProcessor