|
From: <svn...@os...> - 2011-12-19 17:01:08
|
Author: jdeolive
Date: 2011-12-19 09:00:57 -0800 (Mon, 19 Dec 2011)
New Revision: 38432
Modified:
trunk/modules/library/metadata/pom.xml
trunk/modules/library/metadata/src/main/java/org/geotools/factory/GeoTools.java
trunk/pom.xml
Log:
GEOT-3983, bundling git revision info in builds
Modified: trunk/modules/library/metadata/pom.xml
===================================================================
--- trunk/modules/library/metadata/pom.xml 2011-12-19 17:00:34 UTC (rev 38431)
+++ trunk/modules/library/metadata/pom.xml 2011-12-19 17:00:57 UTC (rev 38432)
@@ -137,4 +137,39 @@
</resources>
</build>
+ <profiles>
+ <profile>
+ <id>gitinfo</id>
+ <activation>
+ <file>
+ <!-- .git directory specified relative to working directory, so
+ this profile only engaged when building from root. This is
+ changed/fixed in maven 3, so when build server switches to
+ maven 3 change this to '../../../.git' -->
+ <exists>.git</exists>
+ </file>
+ </activation>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>pl.project13.maven</groupId>
+ <artifactId>git-commit-id-plugin</artifactId>
+ <executions>
+ <execution>
+ <phase>generate-resources</phase>
+ <goals>
+ <goal>revision</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <generateGitPropertiesFile>true</generateGitPropertiesFile>
+ <generateGitPropertiesFilename>target/classes/git.properties</generateGitPropertiesFilename>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ </profiles>
+
</project>
Modified: trunk/modules/library/metadata/src/main/java/org/geotools/factory/GeoTools.java
===================================================================
--- trunk/modules/library/metadata/src/main/java/org/geotools/factory/GeoTools.java 2011-12-19 17:00:34 UTC (rev 38431)
+++ trunk/modules/library/metadata/src/main/java/org/geotools/factory/GeoTools.java 2011-12-19 17:00:57 UTC (rev 38432)
@@ -82,6 +82,11 @@
Properties props = new Properties();
try {
props.load(GeoTools.class.getResourceAsStream("GeoTools.properties"));
+
+ //load git info if it is avaialble
+ if (GeoTools.class.getResource("/git.properties") != null) {
+ props.load(GeoTools.class.getResourceAsStream("/git.properties"));
+ }
}
catch(Exception e) {}
@@ -96,8 +101,15 @@
/**
* The version control (svn) revision at which this version of geotools was built.
*/
- private static final String BUILD_REVISION = PROPS.getProperty("build.revision", "-1");
-
+ private static final String BUILD_REVISION;
+ static {
+ String rev = PROPS.getProperty("build.revision", "-1");
+ if ("-1".equals(rev)) {
+ rev = PROPS.getProperty("git.commit.id", "-1");
+ }
+ BUILD_REVISION = rev;
+ }
+
/**
* The timestamp at which this version of geotools was built.
*/
@@ -332,7 +344,7 @@
public static String getBuildRevision() {
return BUILD_REVISION;
}
-
+
/**
* Reports back the timestamp at which the version of GeoTools of built.
*
@@ -343,6 +355,15 @@
}
/**
+ * Returns the raw properties object containing all properties about this GeoTools build.
+ */
+ public static Properties getBuildProperties() {
+ Properties props = new Properties();
+ props.putAll(PROPS);
+ return props;
+ }
+
+ /**
* Sets the global {@linkplain LoggerFactory logger factory}.
*
* This method is the same as {@code Logging.GEOTOOLS.setLoggerFactory(factory)}.
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2011-12-19 17:00:34 UTC (rev 38431)
+++ trunk/pom.xml 2011-12-19 17:00:57 UTC (rev 38432)
@@ -1241,8 +1241,17 @@
</entry>
</entries>
</configuration>
- </plugin>
+ </plugin>
+ <!-- ======================================================= -->
+ <!-- Git revision info. -->
+ <!-- ======================================================= -->
+ <plugin>
+ <groupId>pl.project13.maven</groupId>
+ <artifactId>git-commit-id-plugin</artifactId>
+ <version>1.9</version>
+ </plugin>
+
</plugins>
</build>
@@ -1404,6 +1413,14 @@
<name>OpenGeo Maven Repository</name>
<url>http://repo.opengeo.org</url>
</pluginRepository>
+ <pluginRepository>
+ <id>sonatype-snapshots</id>
+ <name>sonatype-snapshots</name>
+ <url>https://oss.sonatype.org/content/repositories/snapshots/</url>
+ <snapshots>
+ <enabled>false</enabled>
+ </snapshots>
+ </pluginRepository>
</pluginRepositories>
|