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

    Copyright 2015-2018 Maven Source Dependencies
    Plugin contributors as indicated by the @author tags.

    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>

  <parent>
    <groupId>org.srcdeps.core</groupId>
    <artifactId>srcdeps-core-parent</artifactId>
    <version>3.3.12</version>
  </parent>

  <groupId>org.srcdeps.mvn</groupId>
  <artifactId>srcdeps-maven-parent</artifactId>
  <version>3.3.2</version>
  <packaging>pom</packaging>

  <name>Srcdeps Maven Parent</name>
  <description>A set of tools for building dependencies from their sources during the build</description>
  <url>https://github.com/srcdeps/srcdeps-maven</url>
  <inceptionYear>2015</inceptionYear>
  <licenses>
    <license>
      <name>Apache License, Version 2.0</name>
      <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
      <distribution>repo</distribution>
    </license>
  </licenses>

  <developers>
    <developer>
      <id>ppalaga</id>
      <name>Peter Palaga</name>
      <timezone>Europe/Prague</timezone>
    </developer>
  </developers>

  <modules>
    <module>srcdeps-maven-plugin</module>
    <module>srcdeps-maven-base</module>
    <module>srcdeps-maven-local-repository</module>
    <module>srcdeps-maven-enforcer</module>
    <module>srcdeps-maven-quickstarts</module>
  </modules>

  <scm>
    <connection>scm:git:git@github.com:srcdeps/srcdeps-maven.git</connection>
    <developerConnection>scm:git:git@github.com:srcdeps/srcdeps-maven.git</developerConnection>
    <url>https://github.com/srcdeps/srcdeps-maven</url>
    <tag>3.3.2</tag>
  </scm>
  <issueManagement>
    <system>GitHub Issues</system>
    <url>https://github.com/srcdeps/srcdeps-maven/issues</url>
  </issueManagement>
  <distributionManagement>
    <snapshotRepository>
      <id>ossrh</id>
      <url>${snapshots.repo.url}</url>
    </snapshotRepository>
    <repository>
      <id>ossrh</id>
      <url>${releases.repo.url}</url>
    </repository>
  </distributionManagement>

  <properties>

    <!-- dependencies -->
    <version.io.takari.aether.takari-local-repository>0.11.2</version.io.takari.aether.takari-local-repository>
    <version.io.takari.maven.plugins>2.9.2</version.io.takari.maven.plugins>
    <version.junit>4.12</version.junit>
    <version.org.apache.maven>3.3.9</version.org.apache.maven>
    <version.org.apache.maven.plugin-tools>3.5</version.org.apache.maven.plugin-tools>
    <!-- keep in sync with aetherVersion in maven
         around https://github.com/apache/maven/blob/master/pom.xml#L67 -->
    <version.org.eclipse.aether>1.0.2.v20150114</version.org.eclipse.aether>
    <!-- keep in sync with sisuInjectVersion in maven
         around https://github.com/apache/maven/blob/master/pom.xml#L61 -->
    <version.org.eclipse.sisu>0.3.2</version.org.eclipse.sisu>
    <version.org.slf4j>1.7.5</version.org.slf4j>
    <version.xerces>2.11.0</version.xerces>

    <!--
      Maven plugin versions
        Naming convention: version.${artifactId} whenever unique enough; otherwise version.${groupId}.${artifactId}
        Ordering: alphabetic
    -->

  </properties>

  <dependencyManagement>
    <dependencies>

      <dependency>
        <groupId>io.takari.aether</groupId>
        <artifactId>takari-local-repository</artifactId>
        <version>${version.io.takari.aether.takari-local-repository}</version>
      </dependency>

      <dependency>
        <groupId>io.takari.maven.plugins</groupId>
        <artifactId>takari-plugin-testing</artifactId>
        <version>${version.io.takari.maven.plugins}</version>
      </dependency>
      <dependency>
        <groupId>io.takari.maven.plugins</groupId>
        <artifactId>takari-plugin-integration-testing</artifactId>
        <version>${version.io.takari.maven.plugins}</version>
        <type>pom</type>
      </dependency>

      <dependency>
        <groupId>org.apache.maven</groupId>
        <artifactId>maven-artifact</artifactId>
        <version>${version.org.apache.maven}</version>
      </dependency>

      <dependency>
        <groupId>org.apache.maven</groupId>
        <artifactId>maven-core</artifactId>
        <version>${version.org.apache.maven}</version>
      </dependency>

      <dependency>
        <groupId>org.apache.maven</groupId>
        <artifactId>maven-model</artifactId>
        <version>${version.org.apache.maven}</version>
      </dependency>

      <dependency>
        <groupId>org.apache.maven</groupId>
        <artifactId>maven-model-builder</artifactId>
        <version>${version.org.apache.maven}</version>
      </dependency>

      <dependency>
        <groupId>org.apache.maven</groupId>
        <artifactId>maven-plugin-api</artifactId>
        <version>${version.org.apache.maven}</version>
      </dependency>

      <dependency>
        <groupId>org.apache.maven.plugin-tools</groupId>
        <artifactId>maven-plugin-annotations</artifactId>
        <version>${version.org.apache.maven.plugin-tools}</version>
      </dependency>

      <dependency>
        <groupId>org.eclipse.aether</groupId>
        <artifactId>aether-api</artifactId>
        <version>${version.org.eclipse.aether}</version>
      </dependency>
      <dependency>
        <groupId>org.eclipse.aether</groupId>
        <artifactId>aether-spi</artifactId>
        <version>${version.org.eclipse.aether}</version>
      </dependency>
      <dependency>
        <groupId>org.eclipse.aether</groupId>
        <artifactId>aether-impl</artifactId>
        <version>${version.org.eclipse.aether}</version>
      </dependency>

      <dependency>
        <groupId>org.srcdeps.mvn</groupId>
        <artifactId>srcdeps-maven-local-repository</artifactId>
        <version>3.3.2</version>
      </dependency>
      <dependency>
        <groupId>org.srcdeps.mvn</groupId>
        <artifactId>srcdeps-maven-base</artifactId>
        <version>3.3.2</version>
      </dependency>
      <dependency>
        <groupId>org.srcdeps.mvn</groupId>
        <artifactId>srcdeps-maven-enforcer</artifactId>
        <version>3.3.2</version>
      </dependency>
      <dependency>
        <groupId>org.srcdeps.mvn</groupId>
        <artifactId>srcdeps-maven-quickstarts</artifactId>
        <version>3.3.2</version>
      </dependency>

      <dependency>
        <groupId>xerces</groupId>
        <artifactId>xercesImpl</artifactId>
        <version>${version.xerces}</version>
      </dependency>

    </dependencies>
  </dependencyManagement>

  <build>
    <plugins>

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-checkstyle-plugin</artifactId>
        <dependencies>
          <dependency>
            <groupId>com.puppycrawl.tools</groupId>
            <artifactId>checkstyle</artifactId>
            <version>${version.com.puppycrawl.tools.checkstyle}</version>
            <exclusions>
              <exclusion>
                <groupId>com.sun</groupId>
                <artifactId>tools</artifactId>
              </exclusion>
            </exclusions>
          </dependency>
          <dependency>
            <groupId>org.srcdeps.core</groupId>
            <artifactId>srcdeps-core-buildconfig</artifactId>
            <version>${version.org.srcdeps.core}</version>
          </dependency>
        </dependencies>
        <executions>
          <execution>
            <id>checkstyle</id>
            <phase>verify</phase>
            <goals>
              <goal>checkstyle</goal>
            </goals>
            <configuration>
              <configLocation>srcdeps-checkstyle/checkstyle.xml</configLocation>
              <consoleOutput>${checkstyle.consoleOutput}</consoleOutput>
              <failsOnError>${checkstyle.failOnError}</failsOnError>
              <excludes>${checkstyle.excludes}</excludes>
              <includes>${checkstyle.includes}</includes>
              <sourceDirectory>${basedir}</sourceDirectory>
              <useFile />
            </configuration>
          </execution>
        </executions>
      </plugin>

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-release-plugin</artifactId>
        <configuration>
          <tagNameFormat>@{project.version}</tagNameFormat>
          <preparationGoals>clean generate-sources -Psync-project-versions-release -Psync-project-versions "-Dsrcdeps.version.commit.message.prefix=[maven-release-plugin] Prepare release"</preparationGoals>
          <completionGoals>clean generate-sources -Psync-project-versions-snapshot -Psync-project-versions "-Dsrcdeps.version.commit.message.prefix=[maven-release-plugin] Set next development version"</completionGoals>
          <goals>deploy</goals>
          <releaseProfiles>release</releaseProfiles>
          <autoVersionSubmodules>true</autoVersionSubmodules>
        </configuration>
      </plugin>

      <plugin>
        <groupId>org.commonjava.maven.plugins</groupId>
        <artifactId>directory-maven-plugin</artifactId>
        <executions>
          <execution>
            <id>directories</id>
            <phase>none</phase>
          </execution>
        </executions>
      </plugin>

    </plugins>
  </build>

  <profiles>

    <profile>
      <id>sync-project-versions-release</id>
      <properties>
        <!-- Comma separated list of source files where we need to update the version literals marked by @srcdeps.version@ -->
        <srcdeps.version.files>doc/srcdeps-maven-configuration.adoc,srcdeps-maven-quickstarts/**/.mvn/extensions.xml,srcdeps-maven-base/src/main/java/org/srcdeps/mvn/Constants.java</srcdeps.version.files>
      </properties>
    </profile>

    <profile>
      <id>sync-project-versions-snapshot</id>
      <properties>
        <!-- Comma separated list of source files where we need to update the version literals marked by @srcdeps.version@ -->
        <srcdeps.version.files>srcdeps-maven-base/src/main/java/org/srcdeps/mvn/Constants.java</srcdeps.version.files>
      </properties>
    </profile>

    <profile>
      <id>sync-project-versions</id>
      <build>
        <plugins>

          <plugin>
            <groupId>com.google.code.maven-replacer-plugin</groupId>
            <artifactId>replacer</artifactId>
            <inherited>false</inherited>
            <executions>
              <execution>
                <id>replace-release-version</id>
                <phase>generate-sources</phase>
                <goals>
                  <goal>replace</goal>
                </goals>
                <configuration>
                  <basedir>${basedir}</basedir>
                  <filesToInclude>${srcdeps.version.files}</filesToInclude>
                  <replacements>
                    <replacement>
                      <token>&lt;version&gt;[^&lt;]*&lt;/version&gt;&lt;!-- @srcdeps.version@ --&gt;</token>
                      <value>&lt;version&gt;${project.version}&lt;/version&gt;&lt;!-- @srcdeps.version@ --&gt;</value>
                    </replacement>
                    <replacement>
                      <token>SRCDEPS_MAVEN_VERSION = "[^"]*"; // @srcdeps.version@</token>
                      <value>SRCDEPS_MAVEN_VERSION = "${project.version}"; // @srcdeps.version@</value>
                    </replacement>
                  </replacements>
                </configuration>
              </execution>
            </executions>
          </plugin>

          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-scm-plugin</artifactId>
            <inherited>false</inherited>
            <executions>
              <execution>
                <id>add-changed-files-to-scm</id>
                <phase>generate-sources</phase>
                <goals>
                  <goal>add</goal>
                </goals>
                <configuration>
                  <basedir>${basedir}</basedir>
                  <includes>${srcdeps.version.files}</includes>
                </configuration>
              </execution>
              <execution>
                <id>commit-changed-files-to-scm</id>
                <phase>generate-sources</phase>
                <goals>
                  <goal>checkin</goal>
                </goals>
                <configuration>
                  <message>${srcdeps.version.commit.message.prefix} ${project.version}</message>
                </configuration>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>

  </profiles>

</project>
