<?xml version="1.0" encoding="UTF-8"?>
<!--

    Copyright (C) 2010 Marvin Herman Froeder (marvin@marvinformatics.com)

    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
    You may obtain a copy of the License at

         http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.

-->
<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/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>

  <parent>
    <groupId>com.marvinformatics.formatter</groupId>
    <artifactId>parent</artifactId>
    <version>2.2.0</version>
  </parent>

  <artifactId>formatters</artifactId>
  <packaging>pom</packaging>
  <name>formatters</name>

  <modules>
    <module>formatter-api</module>
    <module>java-formatter</module>
    <module>java-formatter-test</module>
    <module>javascript-formatter</module>
    <module>javascript-formatter-test</module>
    <!--
    <module>groovy-formatter</module>
    <module>groovy-formatter-test</module>
-->
  </modules>

  <profiles>
    <profile>
      <id>formatter-jars</id>

      <activation>
        <file>
          <exists>${basedir}/shade</exists>
        </file>
      </activation>

      <build>
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-dependency-plugin</artifactId>
            <version>3.0.1</version>
            <executions>
              <execution>
                <id>copy-dependencies</id>
                <goals>
                  <goal>copy-dependencies</goal>
                </goals>
                <phase>package</phase>
                <configuration>
                  <outputDirectory>${project.build.directory}/libs</outputDirectory>
                  <overWriteReleases>false</overWriteReleases>
                  <overWriteSnapshots>false</overWriteSnapshots>
                  <overWriteIfNewer>true</overWriteIfNewer>
                  <excludeTransitive>true</excludeTransitive>
                </configuration>
              </execution>
            </executions>
          </plugin>
          <plugin>
            <groupId>com.googlecode.addjars-maven-plugin</groupId>
            <artifactId>addjars-maven-plugin</artifactId>
            <version>1.0.5</version>
            <configuration>

              <resources>
                <resource>
                  <directory>${project.build.directory}/libs</directory>
                </resource>
              </resources>
            </configuration>
            <executions>
              <execution>
                <goals>
                  <goal>add-jars</goal>
                </goals>
                <phase>package</phase>
              </execution>
            </executions>
          </plugin>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-shade-plugin</artifactId>
            <version>3.1.0</version>
            <configuration>
              <minimizeJar>true</minimizeJar>
              <!-- pom will be generated by flatten-maven-plugin -->
              <createDependencyReducedPom>false</createDependencyReducedPom>

              <filters>
                <filter>
                  <artifact>*:*</artifact>
                  <excludes>
                    <exclude>META-INF/*</exclude>
                    <exclude>META-INF/maven/**</exclude>
                    <exclude>**/com/ibm/icu/impl/data/**</exclude>
                    <exclude>**/*.exsd</exclude>
                    <exclude>**/*.gif</exclude>
                    <exclude>**/*.html</exclude>
                    <exclude>**/*.jar</exclude>
                    <exclude>**/*.jnilib</exclude>
                    <exclude>**/*.js</exclude>
                    <exclude>**/*.png</exclude>
                    <exclude>**/*.profile</exclude>
                    <exclude>**/*.so</exclude>
                    <exclude>**/*.txt</exclude>
                    <exclude>**/*.xsd</exclude>
                    <exclude>**/*.zip</exclude>
                  </excludes>
                </filter>
              </filters>
              <relocations>
                <relocation>
                  <pattern>org</pattern>
                  <shadedPattern>${formatter.relocation}org</shadedPattern>
                  <excludes>
                    <exclude>org.xml.**.*</exclude>
                    <exclude>org.eclipse.jdt.core.**.*</exclude>
                    <exclude>org.eclipse.wst.jsdt.core.**.*</exclude>
                  </excludes>
                </relocation>
                <relocation>
                  <pattern>com.ibm</pattern>
                  <shadedPattern>${formatter.relocation}com.ibm</shadedPattern>
                </relocation>
                <relocation>
                  <pattern>com.google</pattern>
                  <shadedPattern>${formatter.relocation}com.google</shadedPattern>
                </relocation>
              </relocations>
            </configuration>
            <executions>
              <execution>
                <goals>
                  <goal>shade</goal>
                </goals>
                <phase>package</phase>
              </execution>
            </executions>
          </plugin>
          <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>flatten-maven-plugin</artifactId>
            <version>1.0.1</version>
            <configuration>
              <flattenMode>ossrh</flattenMode>

              <!-- Remove dependencies and build from fat jar pom -->
              <pomElements>
                <parent>flatten</parent>
                <profiles>flatten</profiles>
                <name>keep</name>
                <build>remove</build>
                <dependencies>remove</dependencies>
                <repositories>remove</repositories>
              </pomElements>
            </configuration>
            <executions>
              <execution>
                <goals>
                  <goal>flatten</goal>
                </goals>
                <phase>package</phase>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>

</project>
