Author: vsiveton Date: Fri Dec 10 11:19:03 2010 New Revision: 1044292 URL: http://svn.apache.org/viewvc?rev=1044292&view=rev Log: o added doap plugin version
Modified: maven/plugins/trunk/maven-doap-plugin/src/main/java/org/apache/maven/plugin/doap/DoapUtil.java Modified: maven/plugins/trunk/maven-doap-plugin/src/main/java/org/apache/maven/plugin/doap/DoapUtil.java URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-doap-plugin/src/main/java/org/apache/maven/plugin/doap/DoapUtil.java?rev=1044292&r1=1044291&r2=1044292&view=diff ============================================================================== --- maven/plugins/trunk/maven-doap-plugin/src/main/java/org/apache/maven/plugin/doap/DoapUtil.java (original) +++ maven/plugins/trunk/maven-doap-plugin/src/main/java/org/apache/maven/plugin/doap/DoapUtil.java Fri Dec 10 11:19:03 2010 @@ -20,6 +20,8 @@ package org.apache.maven.plugin.doap; */ import java.io.File; +import java.io.IOException; +import java.io.InputStream; import java.net.MalformedURLException; import java.text.DateFormat; import java.util.ArrayList; @@ -29,10 +31,12 @@ import java.util.Iterator; import java.util.List; import java.util.Locale; import java.util.Map; +import java.util.Properties; import org.apache.maven.model.Contributor; import org.apache.maven.model.Developer; import org.codehaus.plexus.i18n.I18N; +import org.codehaus.plexus.util.IOUtil; import org.codehaus.plexus.util.StringUtils; import org.codehaus.plexus.util.xml.XMLWriter; import org.codehaus.plexus.util.xml.XmlWriterUtil; @@ -74,7 +78,7 @@ public class DoapUtil XmlWriterUtil.writeComment( writer, "Any modifications will be overwritten." ); XmlWriterUtil.writeComment( writer, " " ); DateFormat dateFormat = DateFormat.getDateTimeInstance( DateFormat.SHORT, DateFormat.SHORT, Locale.US ); - XmlWriterUtil.writeComment( writer, "Generated by Maven Doap Plugin on " + XmlWriterUtil.writeComment( writer, "Generated by Maven Doap Plugin " + getPluginVersion() + " on " + dateFormat.format( new Date( System.currentTimeMillis() ) ) ); XmlWriterUtil.writeComment( writer, "See: http://maven.apache.org/plugins/maven-doap-plugin/" ); XmlWriterUtil.writeComment( writer, " " ); @@ -375,4 +379,34 @@ public class DoapUtil { return i18n.getString( "doap-person", Locale.ENGLISH, key ).toLowerCase( Locale.ENGLISH ); } + + /** + * @return the Maven artefact version. + */ + private static String getPluginVersion() + { + Properties pomProperties = new Properties(); + InputStream is = null; + try + { + is = + DoapUtil.class.getResourceAsStream( "/META-INF/maven/org.apache.maven.plugins/maven-doap-plugin/pom.properties" ); + if ( is == null ) + { + return "<unknown>"; + } + + pomProperties.load( is ); + + return pomProperties.getProperty( "version", "<unknown>" ); + } + catch ( IOException e ) + { + return "<unknown>"; + } + finally + { + IOUtil.close( is ); + } + } }