<?xml version="1.0" encoding="UTF-8"?>
<!--
  Copyright 2015 The original authors.

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

    <groupId>io.sundr</groupId>
    <artifactId>sundr-pom</artifactId>
    <packaging>pom</packaging>
    <version>0.201.0</version>
    <name>Sundrio :: POM</name>
    
    <description>Code generation tools and annotation processors for Builder, Fluent APIs and DSLs.</description>
    <url>https://github.com/sundrio/sundrio</url>
    <licenses>
        <license>
            <name>The Apache Software License, Version 2.0</name>
            <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
            <distribution>repo</distribution>
        </license>
    </licenses>

    <scm>
      <connection>scm:git:https://github.com/sundrio/sundrio.git</connection>
      <developerConnection>scm:git:https://github.com/sundrio/sundrio.git</developerConnection>
      <url>https://github.com/sundrio/sundrio</url>
      <tag>0.201.0</tag>
  </scm>

    <developers>
        <developer>
            <id>iocanel</id>
            <name>Ioannis Canellos</name>
            <email>iocanel@gmail.com</email>
            <url>http://iocanel.blogspot.com</url>
        </developer>
    </developers>

    <properties>
        <format.skip>false</format.skip>
        <javadoc.opts>-Xdoclint:none</javadoc.opts>
        <java.version>11</java.version>

        <maven.version>3.6.3</maven.version>
        <maven.invoker.version>3.3.0</maven.invoker.version>
        <maven-plugin-annotations.version>3.15.1</maven-plugin-annotations.version>

        <validation.api.version>2.0.1.Final</validation.api.version>
        <velocity.version>1.7</velocity.version>
        <st4.version>4.3</st4.version>

        <!-- Tooling Versions -->
        <aether.version>1.0.2.v20150114</aether.version>
        <javaparser.version>2.5.1</javaparser.version>
        <swagger-annotations.version>1.5.17</swagger-annotations.version>
        <swagger-codegen.version>3.0.68</swagger-codegen.version>
        <swagger-codegen-generator.version>1.0.56</swagger-codegen-generator.version>

        <!-- Transitive Versions -->
        <commons-collections.version>3.2.2</commons-collections.version>

        <!-- Maven Plugin Versions -->
        <maven-compiler-plugin.version>3.14.0</maven-compiler-plugin.version>
        <maven-deploy-plugin.version>3.1.1</maven-deploy-plugin.version>
        <maven-jar-plugin.version>3.4.2</maven-jar-plugin.version>
        <maven-release-plugin.version>3.1.1</maven-release-plugin.version>
        <maven-surefire-plugin.version>3.5.2</maven-surefire-plugin.version>
        <maven-invoker-plugin.version>3.9.0</maven-invoker-plugin.version>
        <maven-plugin-plugin.version>3.12.0</maven-plugin-plugin.version>
        <maven-shade-plugin.version>3.6.0</maven-shade-plugin.version>

        <!-- Release Plugins -->
        <maven-gpg-plugin.version>3.2.7</maven-gpg-plugin.version>
        <maven-enforcer-plugin.version>3.5.0</maven-enforcer-plugin.version>
        <maven-javadoc-plugin.version>3.11.2</maven-javadoc-plugin.version>
        <maven-source-plugin.version>3.3.1</maven-source-plugin.version>
        <maven-central-publishing-plugin.version>0.8.0</maven-central-publishing-plugin.version>

        <!-- Formatting Plugins -->
        <formatter-maven-plugin.version>2.23.0</formatter-maven-plugin.version>
        <impsort-maven-plugin.version>1.12.0</impsort-maven-plugin.version>

        <!-- Testing Version -->
        <compile-testing.version>0.5</compile-testing.version>
        <junit.version>4.13.1</junit.version>
        <hamcrest.version>1.3</hamcrest.version>
        
        <!--maven.javadoc.failOnError>false</maven.javadoc.failOnError-->
    </properties>

    <modules>
        <module>core</module>
        <module>model</module>
        <module>adapters</module>
        <module>codegen</module>
        <module>maven-plugin</module>
        <module>annotations</module>
        <module>components</module>
    </modules>
    
    <build>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-surefire-plugin</artifactId>
                    <version>${maven-surefire-plugin.version}</version>
                </plugin>
            </plugins>
        </pluginManagement>

        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-release-plugin</artifactId>
                <version>${maven-release-plugin.version}</version>
                <configuration>
                    <preparationGoals>clean install</preparationGoals>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>${maven-compiler-plugin.version}</version>
                <configuration>
                <release>${java.version}</release>
                    <!-- The option below starting causing `Unknown compilation error` as soon as SourceVersion annotations were removed
                         in favor of SourceVersion.latest().
                         According to: https://stackoverflow.com/questions/56646698/what-causes-an-unknown-compilation-problem-occurred the
                         Removing -Werror usually fixes the problem. -->

                    <!--compilerArgs>
                        <arg>-Werror</arg>
                    </compilerArgs-->
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-enforcer-plugin</artifactId>
                <version>3.4.1</version>
                <executions>
                    <execution>
                        <id>enforce-java</id>
                        <goals>
                            <goal>enforce</goal>
                        </goals>
                        <configuration>
                            <rules>
                                <requireJavaVersion>
                                    <version>(11,)</version>
                                </requireJavaVersion>
                            </rules>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

    <dependencyManagement>
        <dependencies>

            <dependency>
                <groupId>javax.validation</groupId>
                <artifactId>validation-api</artifactId>
                <version>${validation.api.version}</version>
            </dependency>
            
            <dependency>
                <groupId>org.apache.velocity</groupId>
                <artifactId>velocity</artifactId>
                <version>${velocity.version}</version>
            </dependency>

            <dependency>
                <groupId>commons-collections</groupId>
                <artifactId>commons-collections</artifactId>
                <version>${commons-collections.version}</version>
            </dependency>

            <dependency>
                <groupId>com.github.javaparser</groupId>
                <artifactId>javaparser-core</artifactId>
                <version>${javaparser.version}</version>
            </dependency>

            <dependency>
                <groupId>junit</groupId>
                <artifactId>junit</artifactId>
                <version>${junit.version}</version>
                <scope>test</scope>
            </dependency>

            <dependency>
                <groupId>org.hamcrest</groupId>
                <artifactId>hamcrest-all</artifactId>
                <version>${hamcrest.version}</version>
                <scope>test</scope>
            </dependency>
            
            <dependency>
                <groupId>com.google.testing.compile</groupId>
                <artifactId>compile-testing</artifactId>
                <version>${compile-testing.version}</version>
                <scope>test</scope>
                <exclusions>
                    <exclusion>
                        <groupId>com.sun</groupId>
                        <artifactId>tools</artifactId>
                    </exclusion>
                </exclusions>
            </dependency>
            
        </dependencies>
    </dependencyManagement>

    <profiles>
        <profile>
            <id>normal</id>
        </profile>
        <profile>
            <id>format</id>
            <activation>
              <property>
                <name>format.skip</name>
                <value>!true</value>
              </property>
            </activation>
            <build>
              <plugins>
                <plugin>
                  <groupId>net.revelc.code.formatter</groupId>
                  <artifactId>formatter-maven-plugin</artifactId>
                  <version>${formatter-maven-plugin.version}</version>
                  <inherited>true</inherited>
                  <executions>
                    <execution>
                      <goals>
                        <goal>format</goal>
                      </goals>
                      <configuration>
                        <configFile>${maven.multiModuleProjectDirectory}/.code-format.xml</configFile>
                        <lineEnding>LF</lineEnding>
                        <skip>${format.skip}</skip>
                        <encoding>UTF-8</encoding>
                      </configuration>
                    </execution>
                  </executions>
                </plugin>
                <plugin>
                  <groupId>net.revelc.code</groupId>
                  <artifactId>impsort-maven-plugin</artifactId>
                  <version>${impsort-maven-plugin.version}</version>
                  <inherited>true</inherited>
                  <executions>
                    <execution>
                      <goals>
                        <goal>sort</goal>
                      </goals>
                      <configuration>
                        <compliance>${java.version}</compliance>
                        <groups>java.,javax.,org.,com.</groups>
                        <staticGroups>*</staticGroups>
                        <skip>${format.skip}</skip>
                        <removeUnused>true</removeUnused>
                      </configuration>
                    </execution>
                  </executions>
               </plugin>
           </plugins>
          </build>
        </profile>
        <profile>
          <id>release</id>
          <properties>
            <skipITs>true</skipITs>
            <format.skip>true</format.skip>
          </properties>
          <build>
            <plugins>
              <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-gpg-plugin</artifactId>
                <version>${maven-gpg-plugin.version}</version>
                <executions>
                  <execution>
                    <id>sign-artifacts</id>
                    <phase>verify</phase>
                    <goals>
                      <goal>sign</goal>
                    </goals>
                    <configuration>
                      <!-- This is necessary for gpg to not try to use the pinentry programs -->
                      <gpgArguments>
                        <arg>--pinentry-mode</arg>
                        <arg>loopback</arg>
                      </gpgArguments>
                    </configuration>
                  </execution>
                </executions>
              </plugin>
              <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-enforcer-plugin</artifactId>
                <version>${maven-enforcer-plugin.version}</version>
                <executions>
                  <execution>
                    <id>enforce-no-snapshots</id>
                    <goals>
                      <goal>enforce</goal>
                    </goals>
                    <configuration>
                      <rules>
                        <requireReleaseDeps>
                          <message>No Snapshots Allowed!</message>
                        </requireReleaseDeps>
                      </rules>
                      <fail>false</fail>
                    </configuration>
                  </execution>
                </executions>
              </plugin>
              <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-javadoc-plugin</artifactId>
                <version>${maven-javadoc-plugin.version}</version>
                <configuration>
                  <includeDependencySources>${javadoc.include.deps}</includeDependencySources>
                  <dependencySourceIncludes>
                    <dependencySourceInclude>${javadoc.source.includes}</dependencySourceInclude>
                  </dependencySourceIncludes>
                  <excludePackageNames>${javadoc.package.excludes}</excludePackageNames>
                </configuration>
                <executions>
                  <execution>
                    <id>attach-javadocs</id>
                    <goals>
                      <goal>jar</goal>
                    </goals>
                    <configuration>
                      <additionalparam>${javadoc.opts}</additionalparam>
                    </configuration>
                  </execution>
                </executions>
              </plugin>
              <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-source-plugin</artifactId>
                <version>${maven-source-plugin.version}</version>
                <executions>
                  <execution>
                    <id>attach-sources</id>
                    <goals>
                      <goal>jar</goal>
                    </goals>
                  </execution>
                </executions>
              </plugin>
              <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-release-plugin</artifactId>
                <version>${maven-release-plugin.version}</version>
                <configuration>
                  <autoVersionSubmodules>true</autoVersionSubmodules>
                  <tagNameFormat>@{project.version}</tagNameFormat>
                  <localCheckout>true</localCheckout>
                  <pushChanges>false</pushChanges>
                  <remoteTagging>false</remoteTagging>
                  <updateWorkingCopyVersions>false</updateWorkingCopyVersions>
                  <arguments>-DskipTests=true</arguments>
                </configuration>
              </plugin>
              <plugin>
                <groupId>org.sonatype.central</groupId>
                <artifactId>central-publishing-maven-plugin</artifactId>
                <version>${maven-central-publishing-plugin.version}</version>
                <extensions>true</extensions>
                <configuration>
                  <publishingServerId>central</publishingServerId>
                  <autoPublish>true</autoPublish>
                </configuration>
              </plugin>
            </plugins>
          </build>
        </profile>
        <profile>
             <id>with-examples</id>
             <modules>
               <module>examples</module>
             </modules>
        </profile>
        <profile>
             <id>with-tests</id>
             <modules>
               <module>tests</module>
             </modules>
        </profile>
    </profiles>

    <distributionManagement>
        <repository>
          <id>central</id>
          <url>https://central.sonatype.com/repository/maven-releases/</url>
        </repository>
        <snapshotRepository>
          <id>central</id>
          <url>https://central.sonatype.com/repository/maven-snapshots/</url>
        </snapshotRepository>
    </distributionManagement>

</project>
