mirror of https://github.com/OpenIdentityPlatform/OpenDJ.git

Gaetan Boismal
03.50.2016 723b1bd2df194b640e3a5d2e92175803dc9bc494
OPENDJ-2741 Fix maven default lifecycle

The maven default lifecycle build-phases from generate-sources to prepare-package (included)
were broken on the server build because of the following reasons:
* maven-plugin:generate-config expected a jar file to browse XML
descriptors and get a folder instead.
The fix consists to take in account the use case when the URL returned is actually a local folder path.

Once that fixed, we got another error which was related to the maven-dependency-plugin issue MDEP-187.
The maven-dependency-plugin:unpack goal only works for build phase >= package for multi modules projects.
Remove the use of the plugin to address the problem by directly pointing to the local path of:
* opendj-legacy sources
* opendj-maven-plugin xml configuration reference files
2 files modified
71 ■■■■ changed files
opendj-maven-plugin/src/main/java/org/forgerock/opendj/maven/GenerateConfigMojo.java 11 ●●●●● patch | view | raw | blame | history
opendj-server-legacy/pom.xml 60 ●●●●● patch | view | raw | blame | history
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) {
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>