Skip to content

Commit

Permalink
Merge pull request #432 from gritGmbH/bugfix/restore-build-information
Browse files Browse the repository at this point in the history
Bugfix/restore build information via ModuleInfo
  • Loading branch information
MrSnyder committed Nov 11, 2014
2 parents a45e062 + ca3922b commit d8058b8
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
*
* @author <a href="mailto:bezema@lat-lon.de">Rutger Bezema</a>
* @author <a href="mailto:schneider@lat-lon.de">Markus Schneider</a>
* @author <a href="mailto:reichhelm@grit.de">Stephan Reichhelm</a>
*
* @since 3.4
*/
Expand Down Expand Up @@ -154,7 +155,7 @@ public static ModuleInfo extractModuleInfo( URL classpathURL )
builder = builder.setScanners( new ResourcesScanner() );
Reflections r = new Reflections( builder );

Set<String> resources = r.getResources( Pattern.compile( "buildinfo\\.properties" ) );
Set<String> resources = r.getResources( Pattern.compile( "(MANIFEST\\.MF|buildinfo\\.properties)" ) );
if ( !resources.isEmpty() ) {
URLClassLoader classLoader = new URLClassLoader( new URL[] { classpathURL }, null );
String resourcePath = resources.iterator().next();
Expand All @@ -163,12 +164,18 @@ public static ModuleInfo extractModuleInfo( URL classpathURL )
Properties props = new Properties();
buildInfoStream = classLoader.getResourceAsStream( resourcePath );
props.load( buildInfoStream );
String buildBy = props.getProperty( "build.by" );
String buildArtifactId = props.getProperty( "build.artifactId" );
String buildDate = props.getProperty( "build.date" );
String buildRev = props.getProperty( "build.svnrev" );
String buildBy = props.getProperty( "deegree-build-by", props.getProperty( "build.by" ) );
String buildArtifactId = props.getProperty( "deegree-build-artifactId",
props.getProperty( "build.artifactId" ) );
String buildDate = props.getProperty( "deegree-build-date", props.getProperty( "build.date" ) );
String buildRev = props.getProperty( "deegree-build-rev", props.getProperty( "build.svnrev" ) );
String pomVersion = null;

if ( buildArtifactId == null ) {
// skipping because this jar is not from deegree
return null;
}

resources = r.getResources( Pattern.compile( "pom\\.properties" ) );
InputStream pomInputStream = null;
if ( !resources.isEmpty() ) {
Expand All @@ -179,8 +186,8 @@ public static ModuleInfo extractModuleInfo( URL classpathURL )
props.load( pomInputStream );
String pomArtifactId = props.getProperty( "artifactId" );
if ( !pomArtifactId.equals( buildArtifactId ) ) {
LOG.warn( "ArtifactId mismatch for module on path: " + classpathURL
+ " (buildinfo.properties vs. pom.properties)." );
LOG.warn( "ArtifactId mismatch for module on path: {} (MANIFEST.MF/buildinfo.properties vs. pom.properties).",
classpathURL );
}
pomVersion = props.getProperty( "version" );
} finally {
Expand All @@ -190,7 +197,7 @@ public static ModuleInfo extractModuleInfo( URL classpathURL )
moduleInfo = new ModuleInfo( buildArtifactId, pomVersion, buildRev, buildDate, buildBy );
} finally {
closeQuietly( buildInfoStream );
//* closeQuietly( classLoader ); */ // TODO enable for JDK 1.7
// * closeQuietly( classLoader ); */ // TODO enable for JDK 1.7
}
}
return moduleInfo;
Expand Down
21 changes: 15 additions & 6 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,21 @@
<goals>install</goals>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<!-- extend default manifest with deegree build information -->
<manifestEntries>
<deegree-build-artifactId>${project.artifactId}</deegree-build-artifactId>
<deegree-build-by>${user.name}</deegree-build-by>
<deegree-build-date>${buildTimestamp}</deegree-build-date>
<deegree-build-rev>${buildNumber}</deegree-build-rev>
</manifestEntries>
</archive>
</configuration>
</plugin>
</plugins>
</build>

Expand Down Expand Up @@ -983,12 +998,6 @@
<groupId>org.deegree</groupId>
<artifactId>deegree-maven-plugin</artifactId>
<executions>
<execution>
<id>buildinfo</id>
<goals>
<goal>generate-buildinfo</goal>
</goals>
</execution>
<execution>
<id>jaxbcatalog</id>
<phase>generate-sources</phase>
Expand Down

0 comments on commit d8058b8

Please sign in to comment.