<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>
  <parent>
    <groupId>io.apiman</groupId>
    <artifactId>apiman-manager-ui</artifactId>
    <version>2.0.0.Final</version>
    <relativePath>../../pom.xml</relativePath>
  </parent>
  <artifactId>apiman-manager-ui-war-wildfly8</artifactId>
  <packaging>war</packaging>
  <name>apiman-manager-ui-war-wildfly8</name>
  
  <properties>
    <maven.build.timestamp.format>yyyy-MM-dd_HH:mm</maven.build.timestamp.format>
    <ui.webcontext>/apimanui/</ui.webcontext>
    <timestamp>${maven.build.timestamp}</timestamp>
  </properties>

  <dependencies>
    <!-- The base WAR being extended -->
    <dependency>
      <groupId>${project.groupId}</groupId>
      <artifactId>apiman-manager-ui-war</artifactId>
      <type>war</type>
    </dependency>
  </dependencies>

  <build>
    <finalName>apimanui</finalName>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-deploy-plugin</artifactId>
        <configuration>
          <skip>true</skip>
        </configuration>
      </plugin>
      <plugin>
        <artifactId>maven-war-plugin</artifactId>
        <configuration>
          <archive>
            <manifest>
              <addDefaultImplementationEntries>true</addDefaultImplementationEntries>
              <addDefaultSpecificationEntries>true</addDefaultSpecificationEntries>
            </manifest>
          </archive>
          <overlays>
            <overlay>
              <groupId>${project.groupId}</groupId>
              <artifactId>apiman-manager-ui-war</artifactId>
            </overlay>
          </overlays>
        </configuration>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-antrun-plugin</artifactId>
        <dependencies>
          <dependency>
            <groupId>org.apache.ant</groupId>
            <artifactId>ant</artifactId>
            <version>1.8.2</version>
          </dependency>
        </dependencies>
        <executions>
          <execution>
            <id>transform-indexhtml</id>
            <phase>generate-sources</phase>
            <configuration>
              <target>
                <antversion property="antversion" />
                <echo>Ant Version: ${antversion}</echo>

                <echo></echo>
                <echo>********************************************************************</echo>
                <echo>Generating WildFly API Manager index.html file</echo>
                <echo>********************************************************************</echo>
                <echo></echo>

                <delete file="${basedir}/src/main/webapp/index.html" />
                <copy file="${basedir}/../index.html" tofile="${basedir}/src/main/webapp/index.html" overwrite="true" />
                <replaceregexp file="${basedir}/src/main/webapp/index.html"
                  match="&lt;base.href....&gt;" replace="&lt;base href=&apos;${ui.webcontext}&apos;&gt;" byline="true" />
                <replaceregexp file="${basedir}/src/main/webapp/index.html"
                  match="&lt;script.src=&quot;([\w\/\.\-]+)&quot;" replace="&lt;script src=&quot;\1?cid=${timestamp}&quot;" byline="true" />
                <replaceregexp file="${basedir}/src/main/webapp/index.html"
                  match="&lt;link.rel=&quot;stylesheet&quot;.href=&quot;([\w\/\.\-]+)&quot;" replace="&lt;link rel=&quot;stylesheet&quot; href=&quot;\1?cid=${timestamp}&quot;" byline="true" />
                <echo>Successfully processed file ${project.build.directory}/${project.artifactId}-${project.version}/index.html</echo>
              </target>
            </configuration>
            <goals>
              <goal>run</goal>
            </goals>
          </execution>
        </executions>
      </plugin>

    </plugins>
  </build>

</project>
