From 53ae9850a506ed9c1a6738411e5c306b6c647214 Mon Sep 17 00:00:00 2001
From: Gaetan Boismal <gaetan.boismal@forgerock.com>
Date: Fri, 20 Nov 2015 17:57:43 +0000
Subject: [PATCH] OPENDJ-2450 Fix upgrade OEM on windows

---
 opendj-packages/pom.xml                                                                          |    1 
 opendj-packages/opendj-zip/opendj-zip-oem/src/main/resources/bootstrap/manifest-bootstrap-client |    6 ++
 opendj-packages/opendj-zip/opendj-zip-oem/src/main/assembly/opendj-zip-oem-archive-assembly.xml  |   12 ++++
 opendj-packages/opendj-zip/opendj-zip-oem/src/main/resources/bootstrap/manifest-bootstrap        |    6 ++
 opendj-packages/opendj-zip/opendj-zip-oem/pom.xml                                                |  139 ++++++++++++++++++++++++++++++++++++++++++++++
 5 files changed, 163 insertions(+), 1 deletions(-)

diff --git a/opendj-packages/opendj-zip/opendj-zip-oem/pom.xml b/opendj-packages/opendj-zip/opendj-zip-oem/pom.xml
index 3d90419..1b62374 100644
--- a/opendj-packages/opendj-zip/opendj-zip-oem/pom.xml
+++ b/opendj-packages/opendj-zip/opendj-zip-oem/pom.xml
@@ -47,20 +47,155 @@
     <properties>
         <!-- Comma separated list of file patterns to remove from standard archive -->
         <oem.file.exclusion.list>
+            ${product.name.lowercase}/lib/bootstrap.jar,
+            ${product.name.lowercase}/lib/bootstrap-client.jar,
             ${product.name.lowercase}/lib/je.jar,
             ${product.name.lowercase}/lib/opendj-je-backend-changelog.jar,
             ${product.name.lowercase}/legal-notices/THIRDPARTYREADME.txt
         </oem.file.exclusion.list>
+        <product.locales>ca_ES,es,de,fr,ja,ko,pl,zh_CN,zh_TW</product.locales>
     </properties>
 
+    <dependencies>
+        <!--
+          ! Add this dependency to have opendj-server-legacy dependencies in
+          ! our classpath to build boostrap.jar and boostrap-client.jar
+        -->
+        <dependency>
+            <groupId>org.forgerock.opendj</groupId>
+            <artifactId>opendj-server-legacy</artifactId>
+            <version>${project.version}</version>
+            <exclusions>
+                <exclusion>
+                    <groupId>com.sleepycat</groupId>
+                    <artifactId>je</artifactId>
+                </exclusion>
+            </exclusions>
+        </dependency>
+    </dependencies>
+
     <build>
         <plugins>
             <plugin>
+                <groupId>org.forgerock.opendj</groupId>
+                <artifactId>opendj-maven-plugin</artifactId>
+                <version>${project.version}</version>
+                <configuration>
+                    <productJarName>${product.name}</productJarName>
+                    <supportedLocales>${product.locales}</supportedLocales>
+                </configuration>
+
+                <executions>
+                    <execution>
+                        <id>generate-bootstrap-manifest</id>
+                        <goals>
+                            <goal>generate-manifest</goal>
+                        </goals>
+                        <configuration>
+                            <classPathProperty>classpath.bootstrap</classPathProperty>
+                            <excludes>
+                                <exclude>org.slf4j:slf4j-jdk14</exclude>
+                                <exclude>org.forgerock.opendj:opendj-server-legacy</exclude>
+                            </excludes>
+                            <additionalJars>
+                                <additionalJar>opendj-slf4j-adapter.jar</additionalJar>
+                            </additionalJars>
+                        </configuration>
+                    </execution>
+
+                    <execution>
+                        <id>generate-bootstrap-client-manifest</id>
+                        <goals>
+                            <goal>generate-manifest</goal>
+                        </goals>
+                        <configuration>
+                            <classPathProperty>classpath.bootstrap-client</classPathProperty>
+                            <excludes>
+                                <exclude>org.forgerock.opendj:opendj-server-legacy</exclude>
+                            </excludes>
+                        </configuration>
+                    </execution>
+                </executions>
+            </plugin>
+
+            <plugin>
                 <groupId>org.codehaus.mojo</groupId>
                 <artifactId>build-helper-maven-plugin</artifactId>
             </plugin>
 
             <plugin>
+                <artifactId>maven-resources-plugin</artifactId>
+                <executions>
+                    <execution>
+                        <goals>
+                            <goal>copy-resources</goal>
+                        </goals>
+                        <phase>generate-resources</phase>
+                        <configuration>
+                            <outputDirectory>${project.build.outputDirectory}</outputDirectory>
+                            <resources>
+                                <resource>
+                                    <directory>src/main/resources</directory>
+                                    <filtering>true</filtering>
+                                </resource>
+                            </resources>
+                        </configuration>
+                    </execution>
+                </executions>
+            </plugin>
+
+            <plugin>
+                <artifactId>maven-jar-plugin</artifactId>
+                <configuration>
+                    <archive>
+                        <addMavenDescriptor>false</addMavenDescriptor>
+                        <index>false</index>
+                    </archive>
+                    <includes>
+                        <include>nothing</include>
+                    </includes>
+                </configuration>
+
+                <executions>
+                    <!-- Package bootstrap jar - contains only a manifest with classpath for the server -->
+                    <execution>
+                        <id>build-bootstrap-jar</id>
+                        <phase>prepare-package</phase>
+                        <goals>
+                            <goal>jar</goal>
+                        </goals>
+                        <configuration>
+                            <finalName>bootstrap</finalName>
+                            <archive>
+                                <index>false</index>
+                                <manifestFile>
+                                    ${project.build.outputDirectory}/bootstrap/manifest-bootstrap
+                                </manifestFile>
+                            </archive>
+                        </configuration>
+                    </execution>
+
+                    <!-- Package bootstrap-client jar - contains only a manifest with classpath for clients -->
+                    <execution>
+                        <id>build-bootstrap-client-jar</id>
+                        <phase>prepare-package</phase>
+                        <goals>
+                            <goal>jar</goal>
+                        </goals>
+                        <configuration>
+                            <finalName>bootstrap-client</finalName>
+                            <archive>
+                                <index>false</index>
+                                <manifestFile>
+                                    ${project.build.outputDirectory}/bootstrap/manifest-bootstrap-client
+                                </manifestFile>
+                            </archive>
+                        </configuration>
+                    </execution>
+                </executions>
+            </plugin>
+
+            <plugin>
                 <artifactId>maven-dependency-plugin</artifactId>
                 <executions>
                     <!-- Unpack files from OpenDJ standard archive -->
@@ -92,7 +227,9 @@
                             <goal>single</goal>
                         </goals>
                         <configuration>
-                            <finalName>${product.name}-OEM-${parsedVersion.majorVersion}.${parsedVersion.minorVersion}.${parsedVersion.incrementalVersion}</finalName>
+                            <finalName>
+                                ${product.name}-OEM-${parsedVersion.majorVersion}.${parsedVersion.minorVersion}.${parsedVersion.incrementalVersion}
+                            </finalName>
                             <descriptors>
                                 <descriptor>src/main/assembly/opendj-zip-oem-archive-assembly.xml</descriptor>
                             </descriptors>
diff --git a/opendj-packages/opendj-zip/opendj-zip-oem/src/main/assembly/opendj-zip-oem-archive-assembly.xml b/opendj-packages/opendj-zip/opendj-zip-oem/src/main/assembly/opendj-zip-oem-archive-assembly.xml
index 1f72230..171cda5 100644
--- a/opendj-packages/opendj-zip/opendj-zip-oem/src/main/assembly/opendj-zip-oem-archive-assembly.xml
+++ b/opendj-packages/opendj-zip/opendj-zip-oem/src/main/assembly/opendj-zip-oem-archive-assembly.xml
@@ -42,5 +42,17 @@
             <source>${basedir}/${legal.folder}/THIRDPARTYREADME.txt</source>
             <outputDirectory>${legal.folder}</outputDirectory>
         </file>
+
+        <!-- bootstrap.jar OEM file -->
+        <file>
+            <source>${project.build.directory}/bootstrap.jar</source>
+            <outputDirectory>${lib.folder}</outputDirectory>
+        </file>
+
+        <!-- bootstrap-client OEM file -->
+        <file>
+            <source>${project.build.directory}/bootstrap-client.jar</source>
+            <outputDirectory>${lib.folder}</outputDirectory>
+        </file>
     </files>
 </assembly>
diff --git a/opendj-packages/opendj-zip/opendj-zip-oem/src/main/resources/bootstrap/manifest-bootstrap b/opendj-packages/opendj-zip/opendj-zip-oem/src/main/resources/bootstrap/manifest-bootstrap
new file mode 100644
index 0000000..5bac7b2
--- /dev/null
+++ b/opendj-packages/opendj-zip/opendj-zip-oem/src/main/resources/bootstrap/manifest-bootstrap
@@ -0,0 +1,6 @@
+Manifest-Version: 1.0
+Archiver-Version: Plexus Archiver
+Created-By: Apache Maven ${maven.version}
+Built-By: ${user.name}
+Build-Jdk: ${java.version}
+${classpath.bootstrap}
diff --git a/opendj-packages/opendj-zip/opendj-zip-oem/src/main/resources/bootstrap/manifest-bootstrap-client b/opendj-packages/opendj-zip/opendj-zip-oem/src/main/resources/bootstrap/manifest-bootstrap-client
new file mode 100644
index 0000000..fa77b70
--- /dev/null
+++ b/opendj-packages/opendj-zip/opendj-zip-oem/src/main/resources/bootstrap/manifest-bootstrap-client
@@ -0,0 +1,6 @@
+Manifest-Version: 1.0
+Archiver-Version: Plexus Archiver
+Created-By: Apache Maven ${maven.version}
+Built-By: ${user.name}
+Build-Jdk: ${java.version}
+${classpath.bootstrap-client}
diff --git a/opendj-packages/pom.xml b/opendj-packages/pom.xml
index c5688ff..7ac158c 100644
--- a/opendj-packages/pom.xml
+++ b/opendj-packages/pom.xml
@@ -131,6 +131,7 @@
         <product.name>OpenDJ</product.name>
         <product.name.lowercase>opendj</product.name.lowercase>
         <legal.folder>legal-notices</legal.folder>
+        <lib.folder>lib</lib.folder>
         <!-- Location of the opendj service file for linux based packages. -->
         <sysv.file.location/>
     </properties>

--
Gitblit v1.10.0