
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>

  <groupId>org.jboss.errai</groupId>
  <artifactId>wildfly-dist</artifactId>
  <name>Errai::WildFly::Distribution</name>
  <packaging>jar</packaging>
  <version>23.0.2.Final</version>
  
  <description>
    A modified WildFly Dist that does not process ServletContainerInitializers.
  </description>

  <url>http://erraiframework.org</url>

  <developers>
    <developer>
      <name>JBoss Errai Team</name>
    </developer>
  </developers>
  
  <licenses>
    <license>
      <name>lgpl</name>
      <url>http://repository.jboss.org/licenses/lgpl-2.1.txt</url>
      <distribution>repo</distribution>
    </license>
  </licenses>

  <scm>
    <connection>scm:git:git@github.com:errai/errai.git</connection>
    <developerConnection>scm:git:git@github.com:errai/errai.git</developerConnection>
    <url>scm:git:git@github.com:errai/errai.git</url>
  </scm>

  <distributionManagement>
    <repository>
      <id>jboss-releases-repository</id>
      <name>JBoss Releases Repository</name>
      <url>https://repository.jboss.org/nexus/service/local/staging/deploy/maven2/</url>
    </repository>

    <snapshotRepository>
      <id>jboss-snapshots-repository</id>
      <name>JBoss Snapshots Repository</name>
      <url>https://repository.jboss.org/nexus/content/repositories/snapshots/</url>
    </snapshotRepository>
  </distributionManagement>

  <properties>
    <as.version>23.0.2.Final</as.version>
  </properties>

  <dependencies>
    <dependency>
      <groupId>org.wildfly.core</groupId>
      <artifactId>wildfly-server</artifactId>
      <version>15.0.1.Final</version>
    </dependency>
  </dependencies>

  <build>
    <outputDirectory>${project.build.directory}/wildfly-undertow-${as.version}/</outputDirectory>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-dependency-plugin</artifactId>
        <executions>
          <execution>
            <id>unpack</id>
            <phase>process-resources</phase>
            <goals>
              <goal>unpack</goal>
            </goals>
            <configuration>
              <artifactItems>
                <!-- Unpacks Wildfly without the wildfly-undertow jar -->
                <artifactItem>
                  <groupId>org.wildfly</groupId>
                  <artifactId>wildfly-dist</artifactId>
                  <version>${as.version}</version>
                  <type>zip</type>
                  <overWrite>false</overWrite>
                  <outputDirectory>${project.build.directory}</outputDirectory>
                  <excludes>**/org/wildfly/extension/undertow/main/wildfly-undertow-${as.version}.jar</excludes>
                </artifactItem>
                <!-- Unpack everything but ServletContainerInitializerDeploymentProcessor.class 
                  from wildfly-undertow.jar -->
                <artifactItem>
                  <groupId>org.wildfly</groupId>
                  <artifactId>wildfly-undertow</artifactId>
                  <version>${as.version}</version>
                  <type>jar</type>
                  <overWrite>false</overWrite>
                  <outputDirectory>${project.build.directory}/wildfly-undertow-${as.version}/</outputDirectory>
                  <excludes>**/ServletContainerInitializerDeploymentProcessor.class</excludes>
                </artifactItem>
              </artifactItems>
            </configuration>
          </execution>
          <execution>
            <id>unpack-src</id>
            <phase>process-resources</phase>
            <goals>
              <goal>unpack</goal>
            </goals>
            <configuration>
              <artifactItems>
                <!-- Unpacks Wildfly src without the ServletContainerInitializerDeploymentProcessor -->
                <artifactItem>
                  <groupId>org.wildfly</groupId>
                  <artifactId>wildfly-dist</artifactId>
                  <version>${as.version}</version>
                  <classifier>src</classifier>
                  <type>zip</type>
                  <overWrite>false</overWrite>
                  <outputDirectory>${project.build.directory}</outputDirectory>
                </artifactItem>
              </artifactItems>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <!-- Builds replacement jar for wildfly-undertow that has replaced 
        ServletContainerInitializerDeploymentProcessor.class -->
      <plugin>
        <artifactId>maven-antrun-plugin</artifactId>
        <executions>
          <execution>
            <phase>process-classes</phase>
            <goals>
              <goal>run</goal>
            </goals>
            <configuration>
              <tasks>
                <jar
                  destfile="${project.build.directory}/wildfly-${as.version}/modules/system/layers/base/org/wildfly/extension/undertow/main/wildfly-undertow-${as.version}.jar"
                  basedir="${project.build.directory}/wildfly-undertow-${as.version}"
                  compress="false" />
              </tasks>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-assembly-plugin</artifactId>
        <executions>
          <execution>
            <id>assemble</id>
            <phase>package</phase>
            <goals>
              <goal>single</goal>
            </goals>
            <configuration>
              <descriptors>
                <descriptor>assembly.xml</descriptor>
              </descriptors>
              <finalName>wildfly-${project.version}</finalName>
              <appendAssemblyId>false</appendAssemblyId>
              <outputDirectory>target/</outputDirectory>
              <workDirectory>target/assembly/work</workDirectory>              
            </configuration>
          </execution>        
          <execution>
            <id>assemble-src</id>
            <phase>package</phase>
            <goals>
              <goal>single</goal>
            </goals>
            <configuration>
              <descriptors>
                <descriptor>assembly-src.xml</descriptor>
              </descriptors>
              <finalName>wildfly-${project.version}</finalName>
              <appendAssemblyId>true</appendAssemblyId>
              <outputDirectory>${project.build.directory}</outputDirectory>
              <workDirectory>${project.build.directory}/assembly-src/work</workDirectory>
              <tarLongFileMode>gnu</tarLongFileMode>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-source-plugin</artifactId>
        <executions>
          <execution>
            <id>attach-sources</id>
            <goals>
              <goal>jar</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
    </plugins>

  </build>
</project>
