Revision: 5841
http://squirrel-sql.svn.sourceforge.net/squirrel-sql/?rev=5841&view=rev
Author: manningr
Date: 2010-08-22 17:48:14 +0000 (Sun, 22 Aug 2010)
Log Message:
-----------
Rather than filter the source and cause the sourceDirectory to be a generated directory (rather than src/main/java), I introduced a properties file which gets filtered instead. Filtering is disabled for all files in src/main/resources other than Version.properties.
Modified Paths:
--------------
trunk/sql12/app/pom.xml
trunk/sql12/app/src/main/java/net/sourceforge/squirrel_sql/client/Version.java
Added Paths:
-----------
trunk/sql12/app/src/main/resources/net/sourceforge/squirrel_sql/client/Version.properties
Modified: trunk/sql12/app/pom.xml
===================================================================
--- trunk/sql12/app/pom.xml 2010-08-22 12:38:53 UTC (rev 5840)
+++ trunk/sql12/app/pom.xml 2010-08-22 17:48:14 UTC (rev 5841)
@@ -1,6 +1,4 @@
-<project
- xmlns="http://maven.apache.org/POM/4.0.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
@@ -86,21 +84,30 @@
</dependency>
</dependencies>
<build>
- <!-- Filter in the version from the version-plugin below, into Version.java -->
+ <!--
+ Filter in the version from the version-plugin below, into
+ Version.properties. Turn off filtering for all other files here
+ -->
<resources>
<resource>
- <directory>src/main/java</directory>
+ <directory>src/main/resources</directory>
<filtering>true</filtering>
- <targetPath>../filtered-sources/java</targetPath>
+ <includes>
+ <include>**/Version.properties</include>
+ </includes>
</resource>
<resource>
<directory>src/main/resources</directory>
<filtering>false</filtering>
+ <excludes>
+ <exclude>**/Version.properties</exclude>
+ </excludes>
</resource>
</resources>
- <sourceDirectory>target/filtered-sources/java</sourceDirectory>
<plugins>
- <!-- Set the squirrelsql.version property if it has not already been set. -->
+ <!--
+ Set the squirrelsql.version property if it has not already been set.
+ -->
<plugin>
<groupId>net.sf.squirrel-sql</groupId>
<artifactId>squirrelsql-version-plugin</artifactId>
@@ -164,7 +171,8 @@
</build>
<profiles>
<!--
- Since generating javadoc can be time-consuming, this is not done unless a "javadoc" profile is activated.
+ Since generating javadoc can be time-consuming, this is not done
+ unless a "javadoc" profile is activated.
-->
<profile>
<id>javadoc</id>
Modified: trunk/sql12/app/src/main/java/net/sourceforge/squirrel_sql/client/Version.java
===================================================================
--- trunk/sql12/app/src/main/java/net/sourceforge/squirrel_sql/client/Version.java 2010-08-22 12:38:53 UTC (rev 5840)
+++ trunk/sql12/app/src/main/java/net/sourceforge/squirrel_sql/client/Version.java 2010-08-22 17:48:14 UTC (rev 5841)
@@ -17,6 +17,10 @@
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Properties;
+
import net.sourceforge.squirrel_sql.fw.util.StringManager;
import net.sourceforge.squirrel_sql.fw.util.StringManagerFactory;
/**
@@ -35,24 +39,51 @@
private static final String COPYRIGHT = s_stringMgr.getString("Version.copyright");
private static final String WEB_SITE = s_stringMgr.getString("Version.website");
-
+
+ private static String shortVersion = null;
+
public static String getApplicationName()
{
return APP_NAME;
}
/**
+ * Returns a the project version according to the pom.xml file. If this is a release version (like 3.2.0)
+ * then the version will simply be 3.2.0. However, for a snapshot version (like 3.2.0-SNAPSHOT) the
+ * squirrelsql-version-plugin will alter this to have the current timestamp and Snapshot in the form like:
+ *
+ * Snapshot-20100822_1326
+ *
* @return the filtered in value of the version from maven. This property is created in maven by using the
- * squirrelsql-version-plugin. If this string appears as ${squirrelsql.version} in the filtered version
- * of this file (target/classes/net/sourceforge/squirrel_sql/client/Version.java) ensure that the
- * squirrelsql-version-plugin is being bound to the initialize phase, or any phase prior to
+ * squirrelsql-version-plugin. This value is filtered into Version.properties and read from the
+ * classloader at runtime. If this string appears as ${squirrelsql.version} in the filtered version
+ * of Version.properties (target/classes/net/sourceforge/squirrel_sql/client/Version.properties) ensure
+ * that the squirrelsql-version-plugin is being bound to the initialize phase, or any phase prior to
* process-resources.
*/
- public static String getShortVersion()
+ synchronized public static String getShortVersion()
{
- return "${squirrelsql.version}";
+ if (shortVersion == null)
+ {
+ InputStream is = Version.class.getResourceAsStream("Version.properties");
+ Properties props = new Properties();
+ try
+ {
+ props.load(is);
+ shortVersion = props.getProperty("squirrelsql.version");
+ }
+ catch (IOException e)
+ {
+ shortVersion = "Unknown Version";
+ }
+ }
+ return shortVersion;
}
+ public static void main(String[] args) {
+ System.out.println("Version: "+getShortVersion());
+ }
+
public static String getVersion()
{
StringBuffer buf = new StringBuffer();
Added: trunk/sql12/app/src/main/resources/net/sourceforge/squirrel_sql/client/Version.properties
===================================================================
--- trunk/sql12/app/src/main/resources/net/sourceforge/squirrel_sql/client/Version.properties (rev 0)
+++ trunk/sql12/app/src/main/resources/net/sourceforge/squirrel_sql/client/Version.properties 2010-08-22 17:48:14 UTC (rev 5841)
@@ -0,0 +1 @@
+squirrelsql.version=${squirrelsql.version}
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|