From f98cf29f4e7e256e6429cdc8c8ef2833e2dd2b0c Mon Sep 17 00:00:00 2001
From: Jean-Noël Rouvignac <jean-noel.rouvignac@forgerock.com>
Date: Fri, 10 Jun 2016 10:51:05 +0000
Subject: [PATCH] OPENDJ-3013 Embed an example-plugin.zip in opendj zip

---
 opendj-server-legacy/pom.xml                                       |   18 +++++++++
 opendj-server-example-plugin/README.example.plugin                 |   46 +++++++++++++++--------
 opendj-server-legacy/src/main/assembly/example-plugin-assembly.xml |   41 ++++++++++++++++++++
 3 files changed, 89 insertions(+), 16 deletions(-)

diff --git a/opendj-server-example-plugin/README.example.plugin b/opendj-server-example-plugin/README.example.plugin
old mode 100644
new mode 100755
index 39e3a2c..c9f63ec
--- a/opendj-server-example-plugin/README.example.plugin
+++ b/opendj-server-example-plugin/README.example.plugin
@@ -6,33 +6,47 @@
 In order to build and use this example plugin, perform the following
 steps while the server is stopped:
 
-  1. Then unzip the example-plugin.zip (in place):
+# 1. ensure OpenDJ is stopped:
+
+     bin/stop-ds
+
+# 2. unzip the example-plugin.zip (in place):
 
      unzip example-plugin.zip
 
-  2. Go into the example-plugin source folder:
+# 3. Go into the example-plugin source folder:
 
-     cd example-plugin
+     cd opendj-server-example-plugin
 
-  3. And build the plugin (this requires Maven version 3):
+# 4. Build the plugin (this requires Maven version 3):
 
      mvn clean install
 
-  4. This will copy the following files into the parent OpenDJ installation:
+# 5. Unzip the built example-plugin zip
 
-     lib/extensions/example-plugin.jar
-     config/example-plugin.ldif
-     config/schema/99-example-plugin.ldif
+     unzip target/opendj-server-example-plugin-*.zip -d target
 
-  5. Add the plugin's config to the server configuration.
+# 6. Copy the example-plugin's content into the parent OpenDJ installation:
 
-     cd ../bin
-     ./start-ds
-     ./dsconfig -h `hostname` -p 4444 -D "cn=Directory Manager" -w password
-      create-plugin --plugin-name "Example Plugin" --type example
+     cp -r target/opendj-server-example-plugin-*/* ..
+
+# 7. This will copy the following files:
+
+#     lib/extensions/opendj-server-example-plugin-*.jar
+#     lib/extensions/commons-lang3-3.3.2.jar      (included to demonstrate how to include a 3rd party dependency)
+#     config/example-plugin.ldif
+#     config/schema/99-example-plugin.ldif
+#     README.example.plugin
+
+# 8. Add the plugin's config to the server configuration.
+
+     cd ..
+     bin/start-ds
+     bin/dsconfig -h `hostname` -p 4444 -D "cn=Directory Manager" -w password \
+      create-plugin --plugin-name "Example Plugin" --type example \
       --set enabled:true --set plugin-type:startup -X -n
 
-  6. Restart the server and look for the "HELLO WORLD" notice in the start
-     up log:
+# 9. Restart the server and look for the "HELLO WORLD" notice in the start up log:
 
-     ./stop-ds --restart
+     bin/stop-ds --restart
+
diff --git a/opendj-server-legacy/pom.xml b/opendj-server-legacy/pom.xml
index 60ada92..4d2f25d 100644
--- a/opendj-server-legacy/pom.xml
+++ b/opendj-server-legacy/pom.xml
@@ -1002,6 +1002,24 @@
               </archive>
             </configuration>
           </execution>
+
+          <!-- Creates the archive folder -->
+          <execution>
+            <id>build-example-plugin.zip</id>
+            <phase>package</phase>
+            <goals>
+              <goal>single</goal>
+            </goals>
+            <configuration>
+              <finalName>example-plugin</finalName>
+              <outputDirectory>${project.build.directory}/package/${product.name.lowercase}/</outputDirectory>
+              <appendAssemblyId>false</appendAssemblyId>
+              <attach>false</attach>
+              <descriptors>
+                <descriptor>src/main/assembly/example-plugin-assembly.xml</descriptor>
+              </descriptors>
+            </configuration>
+          </execution>
         </executions>
       </plugin>
 
diff --git a/opendj-server-legacy/src/main/assembly/example-plugin-assembly.xml b/opendj-server-legacy/src/main/assembly/example-plugin-assembly.xml
new file mode 100644
index 0000000..2c4b650
--- /dev/null
+++ b/opendj-server-legacy/src/main/assembly/example-plugin-assembly.xml
@@ -0,0 +1,41 @@
+<!--
+  The contents of this file are subject to the terms of the Common Development and
+  Distribution License (the License). You may not use this file except in compliance with the
+  License.
+
+  You can obtain a copy of the License at legal/CDDLv1.0.txt. See the License for the
+  specific language governing permission and limitations under the License.
+
+  When distributing Covered Software, include this CDDL Header Notice in each file and include
+  the License file at legal/CDDLv1.0.txt. If applicable, add the following below the CDDL
+  Header, with the fields enclosed by brackets [] replaced by your own identifying
+  information: "Portions Copyright [year] [name of copyright owner]".
+
+  Copyright 2016 ForgeRock AS.
+-->
+<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2"
+  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd">
+  <id>example-plugin.zip</id>
+  <includeBaseDirectory>false</includeBaseDirectory>
+  <formats>
+    <format>zip</format>
+  </formats>
+  <fileSets>
+    <!-- Creates example-plugin.zip -->
+    <fileSet>
+      <directory>${basedir}/../opendj-server-example-plugin</directory>
+      <includes>
+        <include>**</include>
+      </includes>
+      <excludes>
+        <exclude>target/</exclude>
+        <exclude>src/main/assembly/config/*.ldif.tmp</exclude>
+        <exclude>.*</exclude>
+        <exclude>.*/</exclude>
+      </excludes>
+      <fileMode>744</fileMode>
+      <directoryMode>755</directoryMode>
+    </fileSet>
+  </fileSets>
+</assembly>

--
Gitblit v1.10.0