mirror of
https://github.com/ethauvin/version-processor.git
synced 2025-04-24 15:37:12 -07:00
Initial commit
This commit is contained in:
commit
71c48e2f65
19 changed files with 326 additions and 0 deletions
3
.gitignore
vendored
Normal file
3
.gitignore
vendored
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
.idea/workspace.xml
|
||||||
|
.idea/tasks.xml
|
||||||
|
.kobalt
|
1
.idea/.name
generated
Normal file
1
.idea/.name
generated
Normal file
|
@ -0,0 +1 @@
|
||||||
|
apt-example
|
22
.idea/compiler.xml
generated
Normal file
22
.idea/compiler.xml
generated
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
<?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" />
|
||||||
|
</wildcardResourcePatterns>
|
||||||
|
<annotationProcessing>
|
||||||
|
<profile default="true" name="Default" enabled="false">
|
||||||
|
<processorPath useClasspath="true" />
|
||||||
|
</profile>
|
||||||
|
</annotationProcessing>
|
||||||
|
</component>
|
||||||
|
</project>
|
6
.idea/encodings.xml
generated
Normal file
6
.idea/encodings.xml
generated
Normal 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>
|
12
.idea/libraries/KotlinJavaRuntime.xml
generated
Normal file
12
.idea/libraries/KotlinJavaRuntime.xml
generated
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
<component name="libraryTable">
|
||||||
|
<library name="KotlinJavaRuntime">
|
||||||
|
<CLASSES>
|
||||||
|
<root url="jar://$KOTLIN_BUNDLED$/lib/kotlin-runtime.jar!/" />
|
||||||
|
<root url="jar://$KOTLIN_BUNDLED$/lib/kotlin-reflect.jar!/" />
|
||||||
|
</CLASSES>
|
||||||
|
<JAVADOC />
|
||||||
|
<SOURCES>
|
||||||
|
<root url="jar://$KOTLIN_BUNDLED$/lib/kotlin-runtime-sources.jar!/" />
|
||||||
|
</SOURCES>
|
||||||
|
</library>
|
||||||
|
</component>
|
19
.idea/misc.xml
generated
Normal file
19
.idea/misc.xml
generated
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="EntryPointsManager">
|
||||||
|
<entry_points version="2.0" />
|
||||||
|
</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_8" default="true" assert-keyword="true" jdk-15="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
||||||
|
<output url="file://$PROJECT_DIR$/out" />
|
||||||
|
</component>
|
||||||
|
</project>
|
9
.idea/modules.xml
generated
Normal file
9
.idea/modules.xml
generated
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="ProjectModuleManager">
|
||||||
|
<modules>
|
||||||
|
<module fileurl="file://$PROJECT_DIR$/example/example.iml" filepath="$PROJECT_DIR$/example/example.iml" />
|
||||||
|
<module fileurl="file://$PROJECT_DIR$/processor/processor.iml" filepath="$PROJECT_DIR$/processor/processor.iml" />
|
||||||
|
</modules>
|
||||||
|
</component>
|
||||||
|
</project>
|
42
Build.kt
Normal file
42
Build.kt
Normal file
|
@ -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"
|
||||||
|
}
|
||||||
|
}
|
12
apt-example.iml
Normal file
12
apt-example.iml
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<module type="JAVA_MODULE" version="4">
|
||||||
|
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||||
|
<exclude-output />
|
||||||
|
<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" />
|
||||||
|
</component>
|
||||||
|
</module>
|
13
example/example.iml
Normal file
13
example/example.iml
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<module type="JAVA_MODULE" version="4">
|
||||||
|
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||||
|
<exclude-output />
|
||||||
|
<content url="file://$MODULE_DIR$">
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
|
||||||
|
</content>
|
||||||
|
<orderEntry type="inheritedJdk" />
|
||||||
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
|
<orderEntry type="library" name="KotlinJavaRuntime" level="project" />
|
||||||
|
<orderEntry type="module" module-name="processor" />
|
||||||
|
</component>
|
||||||
|
</module>
|
15
example/src/main/java/com/beust/apt/example/Example.java
Normal file
15
example/src/main/java/com/beust/apt/example/Example.java
Normal file
|
@ -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();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
123
kobalt/src/Build.kt
Normal file
123
kobalt/src/Build.kt
Normal file
|
@ -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"
|
||||||
|
//}
|
||||||
|
|
BIN
kobalt/wrapper/kobalt-wrapper.jar
Normal file
BIN
kobalt/wrapper/kobalt-wrapper.jar
Normal file
Binary file not shown.
1
kobalt/wrapper/kobalt-wrapper.properties
Normal file
1
kobalt/wrapper/kobalt-wrapper.properties
Normal file
|
@ -0,0 +1 @@
|
||||||
|
kobalt.version=0.234
|
1
kobaltw
Normal file
1
kobaltw
Normal file
|
@ -0,0 +1 @@
|
||||||
|
java -jar $(dirname $0)/kobalt/wrapper/kobalt-wrapper.jar $*
|
13
processor/processor.iml
Normal file
13
processor/processor.iml
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<module type="JAVA_MODULE" version="4">
|
||||||
|
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||||
|
<exclude-output />
|
||||||
|
<content url="file://$MODULE_DIR$">
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
|
||||||
|
</content>
|
||||||
|
<orderEntry type="inheritedJdk" />
|
||||||
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
|
<orderEntry type="library" name="KotlinJavaRuntime" level="project" />
|
||||||
|
</component>
|
||||||
|
</module>
|
|
@ -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<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
|
||||||
|
System.out.println("Processing annotations $annotations");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Set<String> getSupportedAnnotationTypes() {
|
||||||
|
Set<String> result = new HashSet<>();
|
||||||
|
result.add("Version");
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
12
processor/src/main/java/com/beust/apt/processor/Version.java
Normal file
12
processor/src/main/java/com/beust/apt/processor/Version.java
Normal file
|
@ -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();
|
||||||
|
}
|
|
@ -0,0 +1 @@
|
||||||
|
com.beust.apt.processor.MainProcessor
|
Loading…
Add table
Add a link
Reference in a new issue