From 407fe631aec08ec4b0f24462b3fa2cee67a83914 Mon Sep 17 00:00:00 2001
From: Matthias Sohn <matthias.sohn@sap.com>
Date: Sat, 23 Jan 2010 01:03:37 +0100
Subject: [PATCH] Use build timestamp as OSGi version qualifier

Translate the version qualifier using maven-antrun-plugin since we want
manifest-first and currently cannot rely on Tycho for the JGit build.

Introduce property for Eclipse p2 repository to enable builds against
other Eclipse versions.

Change-Id: I62c4e77ae91fe17f56c5a5338d53828d4e225395
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
---
 org.eclipse.jgit.console/pom.xml     |  7 ++++++-
 org.eclipse.jgit.http.server/pom.xml |  7 ++++++-
 org.eclipse.jgit.junit/pom.xml       |  7 ++++++-
 org.eclipse.jgit.packaging/pom.xml   |  3 ++-
 org.eclipse.jgit.ui/pom.xml          |  7 ++++++-
 org.eclipse.jgit/pom.xml             |  7 ++++++-
 pom.xml                              | 25 +++++++++++++++++++++++++
 7 files changed, 57 insertions(+), 6 deletions(-)

diff --git a/org.eclipse.jgit.console/pom.xml b/org.eclipse.jgit.console/pom.xml
index 1dea0d840..f91793aaf 100644
--- a/org.eclipse.jgit.console/pom.xml
+++ b/org.eclipse.jgit.console/pom.xml
@@ -2,6 +2,7 @@
 <!--
    Copyright (C) 2009, Google Inc.
    Copyright (C) 2008, Imran M Yousuf <imyousuf@smartitengineering.com>
+   Copyright (C) 2010, Matthias Sohn <matthias.sohn@sap.com>
    and other copyright owners as documented in the project's IP log.
 
    This program and the accompanying materials are made available
@@ -61,6 +62,10 @@
     Console based user interface
   </description>
 
+  <properties>
+    <translate-qualifier/>
+  </properties>
+
   <dependencies>
     <dependency>
       <groupId>org.eclipse.jgit</groupId>
@@ -86,7 +91,7 @@
         <artifactId>maven-jar-plugin</artifactId>
         <configuration>
           <archive>
-            <manifestFile>META-INF/MANIFEST.MF</manifestFile>
+            <manifestFile>${bundle-manifest}</manifestFile>
           </archive>
         </configuration>
       </plugin>
diff --git a/org.eclipse.jgit.http.server/pom.xml b/org.eclipse.jgit.http.server/pom.xml
index cb49402ae..65101b656 100644
--- a/org.eclipse.jgit.http.server/pom.xml
+++ b/org.eclipse.jgit.http.server/pom.xml
@@ -2,6 +2,7 @@
 <!--
    Copyright (C) 2009-2010, Google Inc.
    Copyright (C) 2008, Imran M Yousuf <imyousuf@smartitengineering.com>
+   Copyright (C) 2010, Matthias Sohn <matthias.sohn@sap.com>
    and other copyright owners as documented in the project's IP log.
 
    This program and the accompanying materials are made available
@@ -61,6 +62,10 @@
     Git aware HTTP server implementation.
   </description>
 
+  <properties>
+    <translate-qualifier/>
+  </properties>
+
   <dependencies>
     <dependency>
       <groupId>org.eclipse.jgit</groupId>
@@ -92,7 +97,7 @@
         <artifactId>maven-jar-plugin</artifactId>
         <configuration>
           <archive>
-            <manifestFile>META-INF/MANIFEST.MF</manifestFile>
+            <manifestFile>${bundle-manifest}</manifestFile>
           </archive>
         </configuration>
       </plugin>
diff --git a/org.eclipse.jgit.junit/pom.xml b/org.eclipse.jgit.junit/pom.xml
index 095d21a2d..e2973fa9d 100644
--- a/org.eclipse.jgit.junit/pom.xml
+++ b/org.eclipse.jgit.junit/pom.xml
@@ -2,6 +2,7 @@
 <!--
    Copyright (C) 2009, Google Inc.
    Copyright (C) 2008, Imran M Yousuf <imyousuf@smartitengineering.com>
+   Copyright (C) 2010, Matthias Sohn <matthias.sohn@sap.com>
    and other copyright owners as documented in the project's IP log.
 
    This program and the accompanying materials are made available
@@ -61,6 +62,10 @@
     Utility classes to support JUnit testing of JGit applications.
   </description>
 
+  <properties>
+    <translate-qualifier/>
+  </properties>
+
   <dependencies>
     <dependency>
       <groupId>org.eclipse.jgit</groupId>
@@ -92,7 +97,7 @@
         <artifactId>maven-jar-plugin</artifactId>
         <configuration>
           <archive>
-            <manifestFile>META-INF/MANIFEST.MF</manifestFile>
+            <manifestFile>${bundle-manifest}</manifestFile>
           </archive>
         </configuration>
       </plugin>
diff --git a/org.eclipse.jgit.packaging/pom.xml b/org.eclipse.jgit.packaging/pom.xml
index a32a862d9..3c21e26b6 100644
--- a/org.eclipse.jgit.packaging/pom.xml
+++ b/org.eclipse.jgit.packaging/pom.xml
@@ -60,6 +60,7 @@
 
   <properties>
     <tycho-version>0.6.0</tycho-version>
+    <eclipse-site>http://download.eclipse.org/releases/galileo</eclipse-site>
   </properties>
 
   <modules>
@@ -71,7 +72,7 @@
     <repository>
       <id>galileo</id>
       <layout>p2</layout>
-      <url>http://download.eclipse.org/releases/galileo</url>
+      <url>${eclipse-site}</url>
     </repository>
   </repositories>
 
diff --git a/org.eclipse.jgit.ui/pom.xml b/org.eclipse.jgit.ui/pom.xml
index a0e9089ce..04b8049c7 100644
--- a/org.eclipse.jgit.ui/pom.xml
+++ b/org.eclipse.jgit.ui/pom.xml
@@ -2,6 +2,7 @@
 <!--
    Copyright (C) 2009, Google Inc.
    Copyright (C) 2008, Imran M Yousuf <imyousuf@smartitengineering.com>
+   Copyright (C) 2010, Matthias Sohn <matthias.sohn@sap.com>
    and other copyright owners as documented in the project's IP log.
 
    This program and the accompanying materials are made available
@@ -61,6 +62,10 @@
     AWT/Swing based UI
   </description>
 
+  <properties>
+    <translate-qualifier/>
+  </properties>
+
   <dependencies>
     <dependency>
       <groupId>org.eclipse.jgit</groupId>
@@ -86,7 +91,7 @@
         <artifactId>maven-jar-plugin</artifactId>
         <configuration>
           <archive>
-            <manifestFile>META-INF/MANIFEST.MF</manifestFile>
+            <manifestFile>${bundle-manifest}</manifestFile>
           </archive>
         </configuration>
       </plugin>
diff --git a/org.eclipse.jgit/pom.xml b/org.eclipse.jgit/pom.xml
index 066002a7f..0422800af 100644
--- a/org.eclipse.jgit/pom.xml
+++ b/org.eclipse.jgit/pom.xml
@@ -3,6 +3,7 @@
    Copyright (C) 2009, Google Inc.
    Copyright (C) 2009, Igor Fedorenko <igor@ifedorenko.com>
    Copyright (C) 2008, Imran M Yousuf <imyousuf@smartitengineering.com>
+   Copyright (C) 2010, Matthias Sohn <matthias.sohn@sap.com>
    and other copyright owners as documented in the project's IP log.
 
    This program and the accompanying materials are made available
@@ -62,6 +63,10 @@
     Repository access and algorithms
   </description>
 
+  <properties>
+    <translate-qualifier/>
+  </properties>
+
   <dependencies>
     <dependency>
       <groupId>com.jcraft</groupId>
@@ -86,7 +91,7 @@
         <artifactId>maven-jar-plugin</artifactId>
         <configuration>
           <archive>
-            <manifestFile>META-INF/MANIFEST.MF</manifestFile>
+            <manifestFile>${bundle-manifest}</manifestFile>
           </archive>
         </configuration>
       </plugin>
diff --git a/pom.xml b/pom.xml
index d02cafbbe..42630d5e6 100644
--- a/pom.xml
+++ b/pom.xml
@@ -127,6 +127,9 @@
     <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
     <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
 
+    <maven.build.timestamp.format>yyyyMMddHHmm</maven.build.timestamp.format>
+    <bundle-manifest>${project.build.directory}/META-INF/MANIFEST.MF</bundle-manifest>
+
     <jsch-CQ>CQ 3493</jsch-CQ>
     <jsch-version>0.1.41</jsch-version>
 
@@ -207,6 +210,28 @@
         </configuration>
       </plugin>
 
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-antrun-plugin</artifactId>
+        <executions>
+          <execution>
+            <id>translate-qualifier</id>
+            <phase>generate-resources</phase>
+            <configuration>
+	      <tasks unless="${translate-qualifier}">
+		<copy file="META-INF/MANIFEST.MF" tofile="${bundle-manifest}" overwrite="true"/>
+		<replace file="${bundle-manifest}">
+		  <replacefilter token=".qualifier" value=".${maven.build.timestamp}"/>
+	        </replace>
+	      </tasks>
+            </configuration>
+            <goals>
+              <goal>run</goal>
+            </goals>
+          </execution>
+        </executions>
+      </plugin>
+
       <plugin>
         <groupId>org.apache.maven.plugins</groupId>
         <artifactId>maven-source-plugin</artifactId>
-- 
GitLab