diff --git a/.gitignore b/.gitignore index 24f188e..ba3d3ee 100644 --- a/.gitignore +++ b/.gitignore @@ -4,8 +4,8 @@ **/.idea/tasks.xml **/.idea/workspace.xml *.iws -.DS_Store .classpath +.DS_Store .gradle .kobalt .nb-gradle @@ -17,12 +17,13 @@ /dist /gen /gradle.properties +/lib /local.properties /out /proguard-project.txt /project.properties /target /test-output -Thumbs.db ehthumbs.db -kobaltBuild \ No newline at end of file +kobaltBuild +Thumbs.db \ 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/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml new file mode 100644 index 0000000..8ff795e --- /dev/null +++ b/.idea/inspectionProfiles/Project_Default.xml @@ -0,0 +1,53 @@ + + + + \ No newline at end of file diff --git a/.idea/kobalt-test.iml b/.idea/kobalt-test.iml new file mode 100644 index 0000000..671b7d1 --- /dev/null +++ b/.idea/kobalt-test.iml @@ -0,0 +1,78 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/kobalt.xml b/.idea/kobalt.xml new file mode 100644 index 0000000..c5fd14d --- /dev/null +++ b/.idea/kobalt.xml @@ -0,0 +1,19 @@ + + + + + + \ No newline at end of file diff --git a/.idea/kotlinc.xml b/.idea/kotlinc.xml new file mode 100644 index 0000000..1c24f9a --- /dev/null +++ b/.idea/kotlinc.xml @@ -0,0 +1,7 @@ + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..de2c941 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,77 @@ + + + + + + + + + + + Java + + + Portability issuesJava + + + + + Android + + + + + + + + + + + commons-logging-api + + + + + + + + 1.8.x + + + + + + + + 1.8.x + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..75e0758 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..8306744 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/kobalt/Build.kt.iml b/kobalt/Build.kt.iml new file mode 100644 index 0000000..85fc542 --- /dev/null +++ b/kobalt/Build.kt.iml @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/kobalt/src/Build.kt b/kobalt/src/Build.kt index f7a7e50..723b234 100644 --- a/kobalt/src/Build.kt +++ b/kobalt/src/Build.kt @@ -1,14 +1,20 @@ import com.beust.kobalt.* -import com.beust.kobalt.plugin.packaging.* -import com.beust.kobalt.plugin.publish.* -import com.beust.kobalt.plugin.application.* -import com.beust.kobalt.plugin.java.* +import com.beust.kobalt.plugin.application.application +import com.beust.kobalt.plugin.apt.apt +import com.beust.kobalt.plugin.packaging.assemble +import com.beust.kobalt.plugin.packaging.install +import com.beust.kobalt.plugin.publish.autoGitTag +import com.beust.kobalt.plugin.publish.bintray import org.apache.maven.model.* val bs = buildScript { repos() } +val processorJar = "net.thauvin.erik:semver:0.9.6-beta" + +val mainClassName = "com.example.Main" +val lib = "lib" val p = project { @@ -34,25 +40,26 @@ val p = project { }) } - sourceDirectories { - path("src/main/java") - } - - sourceDirectoriesTest { - path("src/test/java") - } - dependencies { -// compile("com.beust:jcommander:1.48") + apt(processorJar) + compile("org.twitter4j:twitter4j-core:4.0.6") + compileOnly(processorJar) } dependenciesTest { - compile("org.testng:testng:6.10") + compile("org.testng:testng:6.11") } assemble { jar { + manifest { + attributes("Main-Class", mainClassName) + attributes("Class-Path", + collect(compileDependencies) + .map { it.file.name } + .joinToString(" ./$lib/", prefix = ". ./$lib/")) + } } } @@ -60,6 +67,22 @@ val p = project { mainClass = "com.example.Main" } + install { + target = "deploy" + include(from("kobaltBuild/libs"), to(target), glob("**/*")) + collect(compileDependencies).forEach { + copy(from(it.file.absolutePath), to("$target/$lib")) + } + } + + apt { + outputDir = "src/generated/java/" + } + + application { + mainClass = mainClassName + } + autoGitTag { enabled = true message = "Version $version" @@ -69,4 +92,4 @@ val p = project { bintray { publish = false } -} +} \ No newline at end of file diff --git a/kobalt/wrapper/kobalt-wrapper.properties b/kobalt/wrapper/kobalt-wrapper.properties index bb9154b..11e416c 100644 --- a/kobalt/wrapper/kobalt-wrapper.properties +++ b/kobalt/wrapper/kobalt-wrapper.properties @@ -1 +1 @@ -kobalt.version=1.0.18 +kobalt.version=1.0.60 \ No newline at end of file diff --git a/kobaltw b/kobaltw index 3636641..c5186d5 100644 --- a/kobaltw +++ b/kobaltw @@ -1,3 +1,2 @@ #!/usr/bin/env sh -JAR=$(ls -1 -t /k/GitHub/kobalt/kobaltBuild/libs/*.jar | grep -v javadoc | grep -v sources | head -1) -java -jar $JAR $* +java -jar "`dirname "$0"`/kobalt/wrapper/kobalt-wrapper.jar" $* diff --git a/kobaltw-test b/kobaltw-test new file mode 100644 index 0000000..06230ec --- /dev/null +++ b/kobaltw-test @@ -0,0 +1,4 @@ +#!/usr/bin/env sh +JAR=$(ls -1 -t /k/GitHub/kobalt/kobaltBuild/libs/*.jar | egrep -v "(sources|javadoc)" | head -1) +export KOBALT_JAR=$JAR +java -jar $JAR $* diff --git a/kobaltw.bat b/kobaltw.bat new file mode 100644 index 0000000..d578071 --- /dev/null +++ b/kobaltw.bat @@ -0,0 +1,4 @@ +@echo off +set DIRNAME=%~dp0 +if "%DIRNAME%" == "" set DIRNAME=. +java -jar "%DIRNAME%/kobalt/wrapper/kobalt-wrapper.jar" %* diff --git a/src/generated/java/com/example/GeneratedVersion.java b/src/generated/java/com/example/GeneratedVersion.java new file mode 100644 index 0000000..75d2688 --- /dev/null +++ b/src/generated/java/com/example/GeneratedVersion.java @@ -0,0 +1,157 @@ +/* + * This file is automatically generated. + * Do not modify! -- ALL CHANGES WILL BE ERASED! + */ +package com.example; + +import java.util.Date; + +/** + * Provides semantic version information. + * + * @author Semantic Version + * Annotation Processor + */ +public final class GeneratedVersion { + private final static String buildmeta = ""; + private final static Date date = new Date(1492033276280L); + private final static int major = 1; + private final static int minor = 0; + private final static int patch = 0; + private final static String prerelease = "beta"; + private final static String project = ""; + + /** + * Disables the default constructor. + * + * @throws UnsupportedOperationException If the constructor is called. + */ + private GeneratedVersion() + throws UnsupportedOperationException { + throw new UnsupportedOperationException("Illegal constructor call."); + } + + /** + * Returns the build date. + * + * @return The build date. + */ + public static Date getBuildDate() { + return date; + } + + /** + * Returns the project name. + * + * @return The project name, if any. + */ + public static String getProject() { + return project; + } + + /** + * Returns the full version string. + *

+ * Formatted as: + *

+ * MAJOR.MINOR.PATCH[-PRERELEASE][+BUILDMETADATA] + *
+ *

+ * For example: + *

+ * + * @return The version string. + */ + public static String getVersion() { + return Integer.toString(getMajor()) + '.' + + Integer.toString(getMinor()) + '.' + + Integer.toString(getPatch()) + + getPreRelease(true) + getBuildMetadata(true); + } + + /** + * Returns the major version. + * + * @return The major version. + */ + public static int getMajor() { + return major; + } + + /** + * Returns the minor version. + * + * @return The minor version. + */ + public static int getMinor() { + return minor; + } + + /** + * Returns the patch version. + * + * @return The patch version. + */ + public static int getPatch() { + return patch; + } + + /** + * Returns the pre-release version. + * + * @param isHyphen Prepend a hyphen, if true. + * @return The pre-release version, if any. + */ + public static String getPreRelease(final boolean isHyphen) { + if (prerelease.length() > 0) { + if (isHyphen) { + return '-' + prerelease; + } else { + return prerelease; + } + } + + return ""; + } + + /** + * Returns the pre-release version. + * + * @return The pre-release version, if any. + */ + public static String getPreRelease() { + return getPreRelease(false); + } + + /** + * Returns the build metadata. + * + * @param isPlus Prepend a plus sign, if true. + * @return The build metadata, if any. + */ + public static String getBuildMetadata(final boolean isPlus) { + if (buildmeta.length() > 0) { + if (isPlus) { + return '+' + buildmeta; + } else { + return buildmeta; + } + } + + return ""; + } + + /** + * Returns the build metadata. + * + * @return The build metadata, if any. + */ + public static String getBuildMetadata() { + return getBuildMetadata(false); + } +} \ No newline at end of file diff --git a/src/main/java/com/example/Main.java b/src/main/java/com/example/Main.java index c07945d..9ad5eeb 100644 --- a/src/main/java/com/example/Main.java +++ b/src/main/java/com/example/Main.java @@ -1,7 +1,10 @@ package com.example; +import net.thauvin.erik.semver.Version; + +@Version(major = 1, minor = 0, patch = 0, prerelease = "beta") class Main { public static void main(String[] argv) { - System.out.println("\n\nHello Java world from Kobalt\n\n"); + System.out.println(GeneratedVersion.getVersion()); } } \ No newline at end of file