diff --git a/spring-boot-tools/pom.xml b/spring-boot-tools/pom.xml index ff57ff49f3e..6365a4eafa0 100644 --- a/spring-boot-tools/pom.xml +++ b/spring-boot-tools/pom.xml @@ -19,4 +19,25 @@ spring-boot-maven-plugin spring-boot-gradle-plugin + + + + pl.project13.maven + git-commit-id-plugin + + + + revision + + + + + true + yyyy-MM-dd'T'HH:mm:ssZ + true + src/main/resources/org/springframework/boot/git.properties + + + + diff --git a/spring-boot-tools/spring-boot-gradle-plugin/src/main/resources/org/springframework/boot/git.properties b/spring-boot-tools/spring-boot-gradle-plugin/src/main/resources/org/springframework/boot/git.properties new file mode 100644 index 00000000000..b86db7116be --- /dev/null +++ b/spring-boot-tools/spring-boot-gradle-plugin/src/main/resources/org/springframework/boot/git.properties @@ -0,0 +1,13 @@ +#Generated by Git-Commit-Id-Plugin +#Mon Oct 14 16:04:34 EDT 2013 +git.commit.id.abbrev=b0c54a6 +git.commit.user.email=dsyer@gopivotal.com +git.commit.message.full=Add parent class loader entries if possible\n\n...otherwise you can see cryptic NoClassDefFound errors\nbecause the application class was loaded from the parent\non the file system, but then it doesn't have access to the\nchild loaders nested jars.\n +git.commit.id=b0c54a65885de569cc20d4a1fb59b5372c73adcc +git.commit.message.short=Add parent class loader entries if possible +git.commit.user.name=Dave Syer +git.build.user.name=Dave Syer +git.build.user.email=dsyer@gopivotal.com +git.branch=master +git.commit.time=2013-10-14T16\:02\:04-0400 +git.build.time=2013-10-14T16\:04\:34-0400 diff --git a/spring-boot-tools/spring-boot-loader-tools/src/main/java/org/springframework/boot/loader/tools/Repackager.java b/spring-boot-tools/spring-boot-loader-tools/src/main/java/org/springframework/boot/loader/tools/Repackager.java index 9914588b660..6133b637f83 100644 --- a/spring-boot-tools/spring-boot-loader-tools/src/main/java/org/springframework/boot/loader/tools/Repackager.java +++ b/spring-boot-tools/spring-boot-loader-tools/src/main/java/org/springframework/boot/loader/tools/Repackager.java @@ -18,6 +18,8 @@ package org.springframework.boot.loader.tools; import java.io.File; import java.io.IOException; +import java.io.InputStream; +import java.util.Properties; import java.util.jar.JarFile; import java.util.jar.Manifest; @@ -33,6 +35,10 @@ public class Repackager { private static final String START_CLASS_ATTRIBUTE = "Start-Class"; + private static final String GIT_COMMIT_ATTRIBUTE = "Spring-Boot-Commit-Id"; + + private static final String GIT_COMMIT_PROPERTY = "git.commit.id"; + private String mainClass; private boolean backupSource = true; @@ -176,6 +182,21 @@ public class Repackager { manifest.getMainAttributes().putValue(MAIN_CLASS_ATTRIBUTE, this.layout.getLauncherClassName()); manifest.getMainAttributes().putValue(START_CLASS_ATTRIBUTE, startClass); + Properties gitProperties = new Properties(); + try { + InputStream resource = getClass().getResourceAsStream( + "/org/springframework/boot/git.properties"); + if (resource != null) { + gitProperties.load(resource); + } + } + catch (IOException e) { + // ignore + } + if (gitProperties.getProperty(GIT_COMMIT_PROPERTY) != null) { + manifest.getMainAttributes().putValue(GIT_COMMIT_ATTRIBUTE, + gitProperties.getProperty(GIT_COMMIT_PROPERTY)); + } return manifest; } diff --git a/spring-boot-tools/spring-boot-loader-tools/src/main/resources/org/springframework/boot/git.properties b/spring-boot-tools/spring-boot-loader-tools/src/main/resources/org/springframework/boot/git.properties new file mode 100644 index 00000000000..24bd75bd166 --- /dev/null +++ b/spring-boot-tools/spring-boot-loader-tools/src/main/resources/org/springframework/boot/git.properties @@ -0,0 +1,13 @@ +#Generated by Git-Commit-Id-Plugin +#Mon Oct 14 16:04:26 EDT 2013 +git.commit.id.abbrev=b0c54a6 +git.commit.user.email=dsyer@gopivotal.com +git.commit.message.full=Add parent class loader entries if possible\n\n...otherwise you can see cryptic NoClassDefFound errors\nbecause the application class was loaded from the parent\non the file system, but then it doesn't have access to the\nchild loaders nested jars.\n +git.commit.id=b0c54a65885de569cc20d4a1fb59b5372c73adcc +git.commit.message.short=Add parent class loader entries if possible +git.commit.user.name=Dave Syer +git.build.user.name=Dave Syer +git.build.user.email=dsyer@gopivotal.com +git.branch=master +git.commit.time=2013-10-14T16\:02\:04-0400 +git.build.time=2013-10-14T16\:04\:26-0400 diff --git a/spring-boot-tools/spring-boot-loader/src/main/resources/org/springframework/boot/git.properties b/spring-boot-tools/spring-boot-loader/src/main/resources/org/springframework/boot/git.properties new file mode 100644 index 00000000000..04887cb5dec --- /dev/null +++ b/spring-boot-tools/spring-boot-loader/src/main/resources/org/springframework/boot/git.properties @@ -0,0 +1,13 @@ +#Generated by Git-Commit-Id-Plugin +#Mon Oct 14 16:04:25 EDT 2013 +git.commit.id.abbrev=b0c54a6 +git.commit.user.email=dsyer@gopivotal.com +git.commit.message.full=Add parent class loader entries if possible\n\n...otherwise you can see cryptic NoClassDefFound errors\nbecause the application class was loaded from the parent\non the file system, but then it doesn't have access to the\nchild loaders nested jars.\n +git.commit.id=b0c54a65885de569cc20d4a1fb59b5372c73adcc +git.commit.message.short=Add parent class loader entries if possible +git.commit.user.name=Dave Syer +git.build.user.name=Dave Syer +git.build.user.email=dsyer@gopivotal.com +git.branch=master +git.commit.time=2013-10-14T16\:02\:04-0400 +git.build.time=2013-10-14T16\:04\:25-0400 diff --git a/spring-boot-tools/spring-boot-maven-plugin/src/main/resources/org/springframework/boot/git.properties b/spring-boot-tools/spring-boot-maven-plugin/src/main/resources/org/springframework/boot/git.properties new file mode 100644 index 00000000000..9e7ac3ecbea --- /dev/null +++ b/spring-boot-tools/spring-boot-maven-plugin/src/main/resources/org/springframework/boot/git.properties @@ -0,0 +1,13 @@ +#Generated by Git-Commit-Id-Plugin +#Mon Oct 14 16:04:29 EDT 2013 +git.commit.id.abbrev=b0c54a6 +git.commit.user.email=dsyer@gopivotal.com +git.commit.message.full=Add parent class loader entries if possible\n\n...otherwise you can see cryptic NoClassDefFound errors\nbecause the application class was loaded from the parent\non the file system, but then it doesn't have access to the\nchild loaders nested jars.\n +git.commit.id=b0c54a65885de569cc20d4a1fb59b5372c73adcc +git.commit.message.short=Add parent class loader entries if possible +git.commit.user.name=Dave Syer +git.build.user.name=Dave Syer +git.build.user.email=dsyer@gopivotal.com +git.branch=master +git.commit.time=2013-10-14T16\:02\:04-0400 +git.build.time=2013-10-14T16\:04\:29-0400