Revision: 5795
http://squirrel-sql.svn.sourceforge.net/squirrel-sql/?rev=5795&view=rev
Author: manningr
Date: 2010-08-20 22:56:00 +0000 (Fri, 20 Aug 2010)
Log Message:
-----------
Hold onto the rpm version as well. Added an output file for debug purposes, which is currently disabled.
Modified Paths:
--------------
trunk/maven-plugin-workspace/squirrelsql-version-plugin/src/main/java/net/sf/squirrel_sql/SquirrelSqlVersionMojo.java
Modified: trunk/maven-plugin-workspace/squirrelsql-version-plugin/src/main/java/net/sf/squirrel_sql/SquirrelSqlVersionMojo.java
===================================================================
--- trunk/maven-plugin-workspace/squirrelsql-version-plugin/src/main/java/net/sf/squirrel_sql/SquirrelSqlVersionMojo.java 2010-08-15 19:07:29 UTC (rev 5794)
+++ trunk/maven-plugin-workspace/squirrelsql-version-plugin/src/main/java/net/sf/squirrel_sql/SquirrelSqlVersionMojo.java 2010-08-20 22:56:00 UTC (rev 5795)
@@ -19,6 +19,9 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+import java.io.File;
+import java.io.IOException;
+import java.io.PrintWriter;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Properties;
@@ -64,6 +67,9 @@
/** A place to keep the version after it has been generated. */
private static String squirrelsqlVersion = null;
+ /** A place to keep the rpm version after it has been generated from the squirrelsqlVersion */
+ private static String squirrelsqlRpmVersion = null;
+
/**
* The maven project in which this plugin is configured.
*
@@ -92,7 +98,7 @@
* @throws MojoExecutionException
* if the projectVersion isn't specified.
*/
- public void execute() throws MojoExecutionException
+ synchronized public void execute() throws MojoExecutionException
{
// Skip creating a new version if we have already done so in the past.
if (squirrelsqlVersion == null)
@@ -123,8 +129,15 @@
throw e;
}
}
+ // RPM requires that the version string have no dashes. So create a special RPM-safe version of the
+ // version string.
+ squirrelsqlRpmVersion = squirrelsqlVersion.replace('-', '_');
}
+ if (log.isInfoEnabled()) {
+ log.info("squirrelsqlVersion: "+squirrelsqlVersion);
+ }
+
// We set this as a property in the current project where the plugin is configured. This is probably
// unnecessary.
Properties props = project.getProperties();
@@ -134,6 +147,31 @@
// Also a global system property so that this is accessible from any pom as a pom property.
System.setProperty(VERSION_PROPERTY_KEY, squirrelsqlVersion);
System.setProperty(RPM_VERSION_PROPERTY_KEY, squirrelsqlVersion.replace('-', '_'));
+
+ //writeVersionToFile();
}
+
+ private void writeVersionToFile() {
+ File buildDir = new File(project.getBuild().getDirectory());
+ if (!buildDir.exists()) {
+ buildDir.mkdir();
+ }
+ File versionFile = new File(buildDir, "squirrelsql-version-plugin.log");
+ PrintWriter out = null;
+ try {
+ versionFile.createNewFile();
+ out = new PrintWriter(versionFile);
+ SimpleDateFormat sdf = new SimpleDateFormat(TIMESTAMP_PATTERN);
+ out.println(VERSION_PROPERTY_KEY+"="+squirrelsqlVersion);
+ out.println(RPM_VERSION_PROPERTY_KEY+"="+squirrelsqlRpmVersion);
+ out.println("Current Timestamp: "+sdf.format(new Date()));
+ } catch (IOException e) {
+ log.error("Unable to write version ("+squirrelsqlVersion+") to file: "+e.getMessage(), e);
+ } finally {
+ if (out != null) {
+ out.close();
+ }
+ }
+ }
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|