Committing patch from Karl to make framework version a
compile-time substition. (FELIX-3035)


git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1173825 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/framework/pom.xml b/framework/pom.xml
index e2bc4b8..5de46e4 100644
--- a/framework/pom.xml
+++ b/framework/pom.xml
@@ -79,5 +79,32 @@
         </configuration>
       </plugin>
     </plugins>
+    <resources>
+      <!-- Add back in the default resources, since we are overriding resources. -->
+      <resource>
+        <directory>src/main/resources</directory>
+        <filtering>true</filtering>
+      </resource>
+      <!-- Copy Felix.java with property substitution enabled to get version. -->
+      <resource>
+        <directory>src/main/java</directory>
+        <includes>
+            <include>org/apache/felix/framework/Felix.java</include>
+        </includes>
+        <filtering>true</filtering>
+        <targetPath>../filtered-sources/java</targetPath>
+      </resource>
+      <!-- Copy other source files with no property substitution. -->
+      <resource>
+        <directory>src/main/java</directory>
+        <excludes>
+            <exclude>org/apache/felix/framework/Felix.java</exclude>
+        </excludes>
+        <filtering>false</filtering>
+        <targetPath>../filtered-sources/java</targetPath>
+      </resource>
+    </resources>
+    <!-- Set the source directory to be the filtered source files. -->
+    <sourceDirectory>target/filtered-sources/java</sourceDirectory>
   </build>
 </project>
diff --git a/framework/src/main/java/org/apache/felix/framework/Felix.java b/framework/src/main/java/org/apache/felix/framework/Felix.java
index f1e71f7..78e46ef 100644
--- a/framework/src/main/java/org/apache/felix/framework/Felix.java
+++ b/framework/src/main/java/org/apache/felix/framework/Felix.java
@@ -73,6 +73,9 @@
 
 public class Felix extends BundleImpl implements Framework
 {
+    // This value is substituted by maven when building the framework.
+    private static final String m_frameworkVersion = "${pom.version}";
+
     // The secure action used to do privileged calls
     static final SecureAction m_secureAction = new SecureAction();
 
@@ -4304,27 +4307,9 @@
     **/
     private static String getFrameworkVersion()
     {
-        // The framework version property.
-        Properties props = new Properties();
-        InputStream in = Felix.class.getResourceAsStream("Felix.properties");
-        if (in != null)
-        {
-            try
-            {
-                props.load(in);
-            }
-            catch (IOException ex)
-            {
-                ex.printStackTrace();
-            }
-        }
-
         // Maven uses a '-' to separate the version qualifier,
         // while OSGi uses a '.', so we need to convert to a '.'
-        StringBuffer sb =
-            new StringBuffer(
-                props.getProperty(
-                    FelixConstants.FELIX_VERSION_PROPERTY, "0.0.0"));
+        StringBuffer sb = new StringBuffer(m_frameworkVersion);
         if (sb.toString().indexOf("-") >= 0)
         {
             sb.setCharAt(sb.toString().indexOf("-"), '.');
diff --git a/framework/src/main/resources/org/apache/felix/framework/Felix.properties b/framework/src/main/resources/org/apache/felix/framework/Felix.properties
deleted file mode 100644
index 768c415..0000000
--- a/framework/src/main/resources/org/apache/felix/framework/Felix.properties
+++ /dev/null
@@ -1 +0,0 @@
-felix.version=${pom.version}