Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix/restore build information via ModuleInfo #432

Merged
merged 2 commits into from
Nov 11, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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