diff --git a/.idea/modules/semver.iml b/.idea/modules/semver.iml new file mode 100644 index 0000000..24fcd77 --- /dev/null +++ b/.idea/modules/semver.iml @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/build.gradle b/build.gradle index 7895e9a..8192c45 100644 --- a/build.gradle +++ b/build.gradle @@ -205,7 +205,7 @@ task release(dependsOn: ['wrapper', 'clean', 'deploy']) << { task pandoc(type: Exec) { group = 'Documentation' - def pandoc_args = ['--from', 'markdown_github', '--to', 'html5', '-s', '-c', 'github-pandoc.css', '-o', 'README.html', 'README.md'] + def pandoc_args = [] if (Os.isFamily(Os.FAMILY_WINDOWS)) { commandLine(['cmd', '/c', 'pandoc'] + pandoc_args) diff --git a/example/kobalt/src/Build.kt b/example/kobalt/src/Build.kt index 2286f83..bd87306 100644 --- a/example/kobalt/src/Build.kt +++ b/example/kobalt/src/Build.kt @@ -1,7 +1,10 @@ +import com.beust.kobalt.localMaven 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.project +import com.beust.kobalt.repos import java.io.FileInputStream import java.util.* @@ -54,6 +57,10 @@ val example = project { dependenciesTest { } + + apt { + outputDir = "/src/generated/java/" + } install { libDir = "deploy" diff --git a/example/kobalt/wrapper/kobalt-wrapper.properties b/example/kobalt/wrapper/kobalt-wrapper.properties index 7018006..40e4395 100644 --- a/example/kobalt/wrapper/kobalt-wrapper.properties +++ b/example/kobalt/wrapper/kobalt-wrapper.properties @@ -1 +1 @@ -kobalt.version=0.842 \ No newline at end of file +kobalt.version=0.843 \ No newline at end of file diff --git a/example/src/generated/java/net/thauvin/erik/semver/example/GeneratedVersion.java b/example/src/generated/java/net/thauvin/erik/semver/example/GeneratedVersion.java deleted file mode 100644 index f5500de..0000000 --- a/example/src/generated/java/net/thauvin/erik/semver/example/GeneratedVersion.java +++ /dev/null @@ -1,157 +0,0 @@ -/* - * This file is automatically generated. - * Do not modify! -- ALL CHANGES WILL BE ERASED! - */ -package net.thauvin.erik.semver.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(1467959174599L); - private final static int major = 3; - private final static int minor = 1; - private final static int patch = 45; - private final static String prerelease = "beta"; - private final static String project = "Example"; - - /** - * 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/kobalt/Build.kt.iml b/kobalt/Build.kt.iml deleted file mode 100644 index 00b83dc..0000000 --- a/kobalt/Build.kt.iml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/kobalt/src/Build.kt b/kobalt/src/Build.kt index 9575571..3187eb1 100644 --- a/kobalt/src/Build.kt +++ b/kobalt/src/Build.kt @@ -1,14 +1,20 @@ import com.beust.kobalt.localMaven import com.beust.kobalt.plugin.application.application +import com.beust.kobalt.plugin.apt.apt +import com.beust.kobalt.plugin.java.javaCompiler import com.beust.kobalt.plugin.packaging.assemble import com.beust.kobalt.plugin.packaging.install +import com.beust.kobalt.plugins import com.beust.kobalt.project import com.beust.kobalt.repos import java.io.FileInputStream import java.util.* +import net.thauvin.erik.kobalt.plugin.exec.* val repos = repos(localMaven()) +val pl = plugins("net.thauvin.erik:kobalt-exec:0.6.0-beta") + fun StringBuilder.prepend(s: String): StringBuilder { if (this.length > 0) { this.insert(0, s) @@ -16,27 +22,26 @@ fun StringBuilder.prepend(s: String): StringBuilder { return this } +fun versionFor(directory: String = "./"): String { + val propsFile = directory + '/' + "version.properties" + val majorKey = "version.major" + val minorKey = "version.minor" + val patchKey = "version.patch" + val metaKey = "version.buildmeta" + val preKey = "version.prerelease" + + val p = Properties().apply { FileInputStream(propsFile).use { fis -> load(fis) } } + + return (p.getProperty(majorKey, "1") + "." + p.getProperty(minorKey, "0") + "." + p.getProperty(patchKey, "0") + + StringBuilder(p.getProperty(preKey, "")).prepend("-") + + StringBuilder(p.getProperty(metaKey, "")).prepend("+")) +} + val semver = project { name = "semver" group = "net.thauvin.erik" artifactId = name - - fun versionFor(): String { - val propsFile = "version.properties" - val majorKey = "version.major" - val minorKey = "version.minor" - val patchKey = "version.patch" - val metaKey = "version.buildmeta" - val preKey = "version.prerelease" - - val p = Properties().apply { FileInputStream(propsFile).use { fis -> load(fis) } } - - return (p.getProperty(majorKey, "1") + "." + p.getProperty(minorKey, "0") + "." + p.getProperty(patchKey, "0") - + StringBuilder(p.getProperty(preKey, "")).prepend("-") - + StringBuilder(p.getProperty(metaKey, "")).prepend("+")) - } - version = versionFor() sourceDirectories { @@ -56,6 +61,9 @@ val semver = project { } + javaCompiler { + } + install { libDir = "deploy" } @@ -68,4 +76,53 @@ val semver = project { mainClass = "com.example.Main" } + exec { + val args = listOf("--from", "markdown_github", "--to", "html5", "-s", "-c", "github-pandoc.css", "-o", "README.html", "README.md") + commandLine(listOf("pandoc") + args, os = setOf(Os.LINUX)) + commandLine(listOf("cmd", "/c", "pandoc") + args, os =setOf(Os.WINDOWS)) + } +} + + +val example = project { + + name = "example" + directory = "example" + version = versionFor(directory) + + val mainClassName = "net.thauvin.erik.semver.example.Example" + val processorJar = "net.thauvin.erik:semver:0.9.6-beta" + + sourceDirectories { + path("src/main/java") + } + + sourceDirectoriesTest { + path("src/test/java") + } + + dependencies { + apt(processorJar) + compile(processorJar) + } + + dependenciesTest { + + } + + install { + libDir = "deploy" + } + + assemble { + jar { + manifest { + attributes("Main-Class", mainClassName) + } + } + } + + application { + mainClass = mainClassName + } } diff --git a/kobalt/wrapper/kobalt-wrapper.jar b/kobalt/wrapper/kobalt-wrapper.jar index c178849..6ca6ca5 100644 Binary files a/kobalt/wrapper/kobalt-wrapper.jar and b/kobalt/wrapper/kobalt-wrapper.jar differ diff --git a/kobalt/wrapper/kobalt-wrapper.properties b/kobalt/wrapper/kobalt-wrapper.properties index 7018006..9c63a2e 100644 --- a/kobalt/wrapper/kobalt-wrapper.properties +++ b/kobalt/wrapper/kobalt-wrapper.properties @@ -1 +1 @@ -kobalt.version=0.842 \ No newline at end of file +kobalt.version=0.853 \ No newline at end of file diff --git a/kobaltw b/kobaltw old mode 100644 new mode 100755 diff --git a/semver.iml b/semver.iml deleted file mode 100644 index 6d651e8..0000000 --- a/semver.iml +++ /dev/null @@ -1,126 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/semver.ipr b/semver.ipr index 2ce7e7e..47c9c27 100644 --- a/semver.ipr +++ b/semver.ipr @@ -62,9 +62,6 @@ - - - + + + - - - - - + - - + + @@ -304,17 +303,76 @@ + - + - + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/java/net/thauvin/erik/semver/VersionProcessor.java b/src/main/java/net/thauvin/erik/semver/VersionProcessor.java index 2100156..4a386f8 100644 --- a/src/main/java/net/thauvin/erik/semver/VersionProcessor.java +++ b/src/main/java/net/thauvin/erik/semver/VersionProcessor.java @@ -247,6 +247,5 @@ public class VersionProcessor extends AbstractProcessor { error("Could not load '" + Constants.VELOCITY_PROPERTIES + "' from jar."); } - } } \ No newline at end of file