@@ -159,6 +159,32 @@ public void run() {
159159 final String orgURL = pom .getOrganizationURL ();
160160 final String title = name == null ? groupId + ":" + artifactId : name ;
161161
162+ final String scmTag = pom .cdata ("//project/scm/tag" );
163+ String sourceRef = null ;
164+ if (scmTag == null || scmTag .isEmpty () || scmTag .equals ("HEAD" ) ||
165+ scmTag .equals ("master" ))
166+ {
167+ // look in the JAR manifest for the commit hash
168+ // TODO: Make POM API support obtaining the associated Manifest.
169+
170+ // grab Implementation-Build entry out of the JAR manifest
171+ if (pomPath != null && pomPath .contains (".jar!" )) {
172+ final String jarPath = pomPath .substring (0 , pomPath .indexOf ("!" ));
173+ try {
174+ final URL jarURL = new URL ("jar:" + jarPath + "!/" );
175+ final JarURLConnection conn =
176+ (JarURLConnection ) jarURL .openConnection ();
177+ final String key = "Implementation-Build" ;
178+ sourceRef = conn .getManifest ().getMainAttributes ().getValue (key );
179+ }
180+ catch (final IOException e ) { }
181+ }
182+ }
183+ else {
184+ // ref is a valid tag
185+ sourceRef = scmTag ;
186+ }
187+
162188 sb .append (NL );
163189 sb .append ("-- Library: " + title + " --" + NL );
164190 if (pomPath != null ) sb .append ("path = " + pomPath + NL );
@@ -169,6 +195,7 @@ public void run() {
169195 if (year != null ) sb .append ("inception year = " + year + NL );
170196 if (orgName != null ) sb .append ("organization name = " + orgName + NL );
171197 if (orgURL != null ) sb .append ("organization URL = " + orgURL + NL );
198+ if (sourceRef != null ) sb .append ("source ref = " + sourceRef + NL );
172199 }
173200
174201 statusService .showProgress (++progress , max );
0 commit comments