From 723b1bd2df194b640e3a5d2e92175803dc9bc494 Mon Sep 17 00:00:00 2001
From: Gaetan Boismal <gaetan.boismal@forgerock.com>
Date: Fri, 04 Mar 2016 14:50:52 +0000
Subject: [PATCH] OPENDJ-2741 Fix maven default lifecycle

---
 opendj-maven-plugin/src/main/java/org/forgerock/opendj/maven/GenerateConfigMojo.java |   11 +++++
 opendj-server-legacy/pom.xml                                                         |   60 ++----------------------------
 2 files changed, 14 insertions(+), 57 deletions(-)

diff --git a/opendj-maven-plugin/src/main/java/org/forgerock/opendj/maven/GenerateConfigMojo.java b/opendj-maven-plugin/src/main/java/org/forgerock/opendj/maven/GenerateConfigMojo.java
index ae7e9d8..2711cb0 100644
--- a/opendj-maven-plugin/src/main/java/org/forgerock/opendj/maven/GenerateConfigMojo.java
+++ b/opendj-maven-plugin/src/main/java/org/forgerock/opendj/maven/GenerateConfigMojo.java
@@ -430,7 +430,16 @@
         }
 
         final URL url = getClass().getClassLoader().getResource(parentPath);
-        loadXMLDescriptorsFromJar(parentPath, ((JarURLConnection) url.openConnection()).getJarFile());
+        final String protocol = url.getProtocol();
+        if ("file".equals(protocol)) {
+            loadXMLDescriptorsFromFolder(parentPath);
+        } else if ("jar".equals(protocol)) {
+            loadXMLDescriptorsFromJar(parentPath, ((JarURLConnection) url.openConnection()).getJarFile());
+        } else {
+            final String errorMsg = "Impossible to read XML descriptors from path '" + parentPath + "'";
+            getLog().error(errorMsg);
+            throw new MojoExecutionException(errorMsg);
+        }
     }
 
     private void loadXMLDescriptorsFromFolder(final String parentPath) {
diff --git a/opendj-server-legacy/pom.xml b/opendj-server-legacy/pom.xml
index 6dcea3b..4f3fde2 100644
--- a/opendj-server-legacy/pom.xml
+++ b/opendj-server-legacy/pom.xml
@@ -349,58 +349,6 @@
         </configuration>
       </plugin>
 
-      <plugin>
-        <groupId>org.apache.maven.plugins</groupId>
-        <artifactId>maven-dependency-plugin</artifactId>
-        <executions>
-          <!-- Unpack configuration files from opendj-maven-plugin -->
-          <!-- This plugin could be removed once the migration to the new config framework will be done -->
-          <execution>
-            <id>unpack-config-files</id>
-            <phase>generate-sources</phase>
-            <goals>
-              <goal>unpack</goal>
-            </goals>
-            <configuration>
-              <artifactItems>
-                <artifactItem>
-                  <groupId>org.forgerock.opendj</groupId>
-                  <artifactId>opendj-maven-plugin</artifactId>
-                  <version>${project.version}</version>
-                  <type>jar</type>
-                  <overWrite>true</overWrite>
-                  <outputDirectory>${old.config.files.path}</outputDirectory>
-                  <includes>config/xml/**/*.xml</includes>
-                </artifactItem>
-              </artifactItems>
-            </configuration>
-          </execution>
-
-          <!-- Unpack legacy classes to include them in main jar.
-               This "hacked" approach is needed since using the maven shade plugin
-               is too complex with this multi-artefact maven module. -->
-          <execution>
-            <id>unpack-legacy-classes</id>
-            <phase>generate-sources</phase>
-            <goals>
-              <goal>unpack</goal>
-            </goals>
-            <configuration>
-              <artifactItems>
-                <artifactItem>
-                  <groupId>org.forgerock.opendj</groupId>
-                  <artifactId>opendj-legacy</artifactId>
-                  <version>${project.version}</version>
-                  <type>jar</type>
-                  <overWrite>true</overWrite>
-                  <outputDirectory>${project.build.directory}/classes</outputDirectory>
-                </artifactItem>
-              </artifactItems>
-            </configuration>
-          </execution>
-        </executions>
-      </plugin>
-
       <!-- Generate i18n messages -->
       <plugin>
         <groupId>org.forgerock.commons</groupId>
@@ -602,6 +550,7 @@
                 <source>src/admin/generated</source>
                 <source>src/build-tools</source>
                 <source>${project.build.directory}/java-stubs</source>
+                <source>../opendj-legacy/src/main/java</source>
               </sources>
             </configuration>
           </execution>
@@ -1121,10 +1070,9 @@
             <phase>generate-sources</phase>
             <configuration>
               <target>
-                <move todir="${old.config.files.path}">
-                  <fileset dir="${old.config.files.path}/config/xml/org/forgerock/opendj/server/config/" />
-                </move>
-                <delete dir="${old.config.files.path}/config" />
+                <copy todir="${old.config.files.path}">
+                  <fileset dir="../opendj-maven-plugin/src/main/resources/config/xml/org/forgerock/opendj/server/config/" />
+                </copy>
                 <replace dir="${old.config.files.path}" token="org.forgerock.opendj.server.config" value="org.opends.server.admin.std" />
                 <replace dir="${old.config.files.path}" token="http://opendj.forgerock.org/admin" value="http://www.opends.org/admin" />
               </target>

--
Gitblit v1.10.0