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

    Copyright © ${year} DataSQRL (contact@datasqrl.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>
  <groupId>com.marvinformatics.jacoco</groupId>
  <artifactId>easy-jacoco-maven-plugin</artifactId>
  <version>0.1.3</version>
  <packaging>maven-plugin</packaging>

  <name>easy-jacoco-maven-plugin</name>
  <description>This project aims at making jacoco easy on modular projects.

Runs all things a project need on all modules automatically.
All modules will prepare (for unit and integrationtests)
All modules will report (for unit and integrationtests)
All modules can be checked (for unit and integrationtests)

So far, all things you can do on parent pom, with a few lines.

The juicy bits:

PROJECT wide coverage report (aka report-aggregate) with zero configuration
PROJECT wide coverage check, so you can requite the whole project to have 70% code coverage</description>
  <url>https://github.com/velo/easy-jacoco-maven-plugin</url>

  <licenses>
    <license>
      <name>Apache License, Version 2.0</name>
      <url>https://www.apache.org/licenses/LICENSE-2.0.txt</url>
      <distribution>repo</distribution>
    </license>
  </licenses>

  <developers>
    <developer>
      <id>velo</id>
      <name>Marvin Froeder</name>
      <url>https://github.com/velo</url>
    </developer>
  </developers>

  <scm>
    <connection>scm:git:https://github.com/velo/easy-jacoco-maven-plugin.git</connection>
    <developerConnection>scm:git:git@github.com:velo/easy-jacoco-maven-plugin.git</developerConnection>
    <tag>HEAD</tag>
    <url>https://github.com/velo/easy-jacoco-maven-plugin</url>
  </scm>

  <properties>
    <maven.version>3.9.9</maven.version>
    <jacoco.version>0.8.13</jacoco.version>

    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>

    <license-maven-plugin.version>5.0.0</license-maven-plugin.version>
    <git-code-format-maven-plugin.version>5.3</git-code-format-maven-plugin.version>
    <sortpom.plugin.version>4.0.0</sortpom.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-gpg-plugin.version>3.2.7</maven-gpg-plugin.version>
  </properties>

  <dependencyManagement>
    <dependencies>
      <dependency>
        <groupId>org.codehaus.plexus</groupId>
        <artifactId>plexus-utils</artifactId>
        <version>3.5.1</version>
        <!-- maven runs with a different version, causing all short of class not found issues-->
        <scope>runtime</scope>
      </dependency>
    </dependencies>
  </dependencyManagement>

  <dependencies>
    <dependency>
      <groupId>org.apache.maven</groupId>
      <artifactId>maven-plugin-api</artifactId>
      <version>${maven.version}</version>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>org.apache.maven</groupId>
      <artifactId>maven-core</artifactId>
      <version>${maven.version}</version>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>org.apache.maven.plugin-tools</groupId>
      <artifactId>maven-plugin-annotations</artifactId>
      <version>3.15.1</version>
      <scope>provided</scope>
    </dependency>

    <!-- JaCoCo dependencies -->
    <dependency>
      <groupId>org.jacoco</groupId>
      <artifactId>org.jacoco.core</artifactId>
      <version>${jacoco.version}</version>
    </dependency>
    <dependency>
      <groupId>org.jacoco</groupId>
      <artifactId>org.jacoco.report</artifactId>
      <version>${jacoco.version}</version>
    </dependency>
    <dependency>
      <groupId>org.jacoco</groupId>
      <artifactId>org.jacoco.agent</artifactId>
      <version>${jacoco.version}</version>
      <classifier>runtime</classifier>
      <scope>test</scope>
    </dependency>

    <dependency>
      <groupId>org.apache.maven.shared</groupId>
      <artifactId>maven-invoker</artifactId>
      <version>3.3.0</version>
      <scope>test</scope>
    </dependency>

    <dependency>
      <groupId>org.junit.jupiter</groupId>
      <artifactId>junit-jupiter</artifactId>
      <version>5.8.2</version>
      <scope>test</scope>
    </dependency>

    <dependency>
      <groupId>org.assertj</groupId>
      <artifactId>assertj-core</artifactId>
      <version>3.22.0</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.apache.commons</groupId>
      <artifactId>commons-compress</artifactId>
      <version>1.21</version>
      <scope>test</scope>
    </dependency>

    <dependency>
      <groupId>org.slf4j</groupId>
      <artifactId>slf4j-simple</artifactId>
      <version>1.7.36</version>
      <scope>test</scope>
    </dependency>
  </dependencies>

  <build>
    <testResources>
      <testResource>
        <filtering>true</filtering>
        <directory>src/test/resources</directory>
      </testResource>
    </testResources>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <configuration>
          <release>11</release>
        </configuration>
      </plugin>

      <plugin>
        <groupId>org.eclipse.sisu</groupId>
        <artifactId>sisu-maven-plugin</artifactId>
        <version>0.9.0.M3</version>
        <executions>
          <execution>
            <id>generate-index</id>
            <goals>
              <goal>main-index</goal>
            </goals>
          </execution>
        </executions>
      </plugin>

      <plugin>
        <groupId>com.cosium.code</groupId>
        <artifactId>git-code-format-maven-plugin</artifactId>
        <version>${git-code-format-maven-plugin.version}</version>
        <dependencies>
          <dependency>
            <groupId>com.cosium.code</groupId>
            <artifactId>google-java-format</artifactId>
            <version>${git-code-format-maven-plugin.version}</version>
          </dependency>
        </dependencies>
        <executions>
          <!-- On commit, format the modified files -->
          <execution>
            <id>install-formatter-hook</id>
            <goals>
              <goal>install-hooks</goal>
            </goals>
            <!-- inherited = false means it won't re-run in submodules if not desired -->
            <inherited>false</inherited>
          </execution>
          <!-- On Maven verify, fail if code is not formatted -->
          <execution>
            <id>validate-code-format</id>
            <goals>
              <goal>validate-code-format</goal>
            </goals>
          </execution>
        </executions>
      </plugin>

      <plugin>
        <groupId>com.github.ekryd.sortpom</groupId>
        <artifactId>sortpom-maven-plugin</artifactId>
        <version>${sortpom.plugin.version}</version>
        <configuration>
          <keepBlankLines>true</keepBlankLines>
          <lineSeparator>\n</lineSeparator>
          <predefinedSortOrder>recommended_2008_06</predefinedSortOrder>
          <createBackupFile>false</createBackupFile>
        </configuration>
      </plugin>

      <plugin>
        <groupId>com.mycila</groupId>
        <artifactId>license-maven-plugin</artifactId>
        <version>${license-maven-plugin.version}</version>
        <configuration>
          <properties>
            <owner>DataSQRL</owner>
            <email>contact@datasqrl.com</email>
          </properties>
          <licenseSets>
            <licenseSet>
              <header>com/mycila/maven/plugin/license/templates/APACHE-2.txt</header>
              <excludes>
                <exclude>src/test/resources/**</exclude>
                <exclude>m2e-target/**</exclude>
                <exclude>bin/**</exclude>
              </excludes>
            </licenseSet>
          </licenseSets>
          <strictCheck>true</strictCheck>
        </configuration>
        <dependencies>
          <dependency>
            <groupId>com.mycila</groupId>
            <artifactId>license-maven-plugin-git</artifactId>
            <version>${license-maven-plugin.version}</version>
          </dependency>
        </dependencies>
        <executions>
          <execution>
            <id>check</id>
            <goals>
              <goal>check</goal>
            </goals>
            <phase>compile</phase>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-plugin-plugin</artifactId>
        <version>3.15.1</version>
        <executions>
          <execution>
            <id>generated-helpmojo</id>
            <goals>
              <goal>helpmojo</goal>
            </goals>
          </execution>
        </executions>
      </plugin>

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <version>3.5.3</version>
        <configuration>
          <redirectTestOutputToFile>true</redirectTestOutputToFile>

          <systemPropertyVariables>
            <org.slf4j.simpleLogger.defaultLogLevel>debug</org.slf4j.simpleLogger.defaultLogLevel>
          </systemPropertyVariables>

          <forkCount>1</forkCount>
          <reuseForks>true</reuseForks>

          <trimStackTrace>false</trimStackTrace>
        </configuration>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-failsafe-plugin</artifactId>
        <version>3.5.3</version>

        <configuration>
          <redirectTestOutputToFile>true</redirectTestOutputToFile>

          <systemPropertyVariables>
            <org.slf4j.simpleLogger.defaultLogLevel>debug</org.slf4j.simpleLogger.defaultLogLevel>
          </systemPropertyVariables>

          <forkCount>1</forkCount>
          <reuseForks>true</reuseForks>

          <trimStackTrace>false</trimStackTrace>
        </configuration>

        <executions>
          <execution>
            <goals>
              <goal>integration-test</goal>
              <goal>verify</goal>
            </goals>
          </execution>
        </executions>
      </plugin>

      <plugin>
        <groupId>org.jacoco</groupId>
        <artifactId>jacoco-maven-plugin</artifactId>
        <version>${jacoco.version}</version>
        <executions>
          <execution>
            <goals>
              <goal>prepare-agent</goal>
              <goal>prepare-agent-integration</goal>
            </goals>
          </execution>
        </executions>
      </plugin>

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-install-plugin</artifactId>
        <version>3.1.0</version>
        <executions>
          <execution>
            <id>default-install</id>
            <goals>
              <goal>install</goal>
            </goals>
            <phase>package</phase>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>

  <profiles>
    <!-- Useful profile for local dev (forces code format, etc.) -->
    <profile>
      <id>dev</id>
      <properties>
        <gcf.skipInstallHooks>false</gcf.skipInstallHooks>
      </properties>
      <build>
        <plugins>
          <plugin>
            <groupId>com.cosium.code</groupId>
            <artifactId>git-code-format-maven-plugin</artifactId>
            <executions>
              <execution>
                <id>format-code</id>
                <goals>
                  <goal>format-code</goal>
                </goals>
                <phase>initialize</phase>
              </execution>
            </executions>
          </plugin>
          <plugin>
            <groupId>com.github.ekryd.sortpom</groupId>
            <artifactId>sortpom-maven-plugin</artifactId>
            <executions>
              <execution>
                <id>format</id>
                <goals>
                  <goal>sort</goal>
                </goals>
                <phase>initialize</phase>
              </execution>
              <execution>
                <id>format-example</id>
                <goals>
                  <goal>sort</goal>
                </goals>
                <phase>initialize</phase>
                <configuration>
                  <pomFile>examples/basic/pom.xml</pomFile>
                </configuration>
              </execution>
              <execution>
                <id>format-example-module</id>
                <goals>
                  <goal>sort</goal>
                </goals>
                <phase>initialize</phase>
                <configuration>
                  <pomFile>examples/basic/module-1/pom.xml</pomFile>
                </configuration>
              </execution>
            </executions>
          </plugin>
          <plugin>
            <groupId>com.mycila</groupId>
            <artifactId>license-maven-plugin</artifactId>
            <executions>
              <execution>
                <id>format</id>
                <goals>
                  <goal>format</goal>
                </goals>
                <phase>initialize</phase>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>

    <!-- Extra tasks only meant to be executed by CI -->
    <profile>
      <id>ci</id>
      <properties>
        <gcf.skip>true</gcf.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>
                <goals>
                  <goal>sign</goal>
                </goals>
                <phase>verify</phase>
              </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-no-fork</goal>
                </goals>
                <phase>package</phase>
              </execution>
            </executions>
          </plugin>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-javadoc-plugin</artifactId>
            <version>${maven-javadoc-plugin.version}</version>
            <configuration>
              <failOnError>false</failOnError>
            </configuration>
            <executions>
              <execution>
                <id>attach-javadocs</id>
                <goals>
                  <goal>jar</goal>
                </goals>
                <phase>package</phase>
                <configuration>
                  <show>public</show>
                  <failOnError>false</failOnError>
                  <detectOfflineLinks>false</detectOfflineLinks>
                  <doclint>all,-missing</doclint>
                  <nohelp>true</nohelp>
                  <excludePackageNames>*.internal.*,testutil,demo</excludePackageNames>
                  <quiet>true</quiet>
                </configuration>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>
    <profile>
      <!-- just compile, skip all other checks -->
      <id>quickbuild</id>
      <properties>
        <skipTests>true</skipTests>
        <enforcer.skip>true</enforcer.skip>
        <maven.javadoc.skip>true</maven.javadoc.skip>
        <gcf.skip>true</gcf.skip>
        <license.skip>true</license.skip>
      </properties>
    </profile>
    <profile>
      <!-- helper profile to proper configure eclipse -->
      <id>m2e</id>
      <activation>
        <property>
          <name>m2e.version</name>
        </property>
      </activation>
      <build>
        <directory>${project.basedir}/m2e-target</directory>
      </build>
    </profile>
    <profile>
      <id>release</id>
      <build>
        <plugins>
          <plugin>
            <groupId>org.sonatype.central</groupId>
            <artifactId>central-publishing-maven-plugin</artifactId>
            <version>0.7.0</version>
            <extensions>true</extensions>
            <configuration>
              <publishingServerId>central</publishingServerId>

              <excludeArtifacts>
                <!-- artifacts that only exists to support integration tests and as samples-->
                <excludeArtifact>helpers</excludeArtifact>
                <excludeArtifact>system-functions-sample</excludeArtifact>
                <excludeArtifact>udf-sample</excludeArtifact>
              </excludeArtifacts>

              <autoPublish>true</autoPublish>
            </configuration>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>
</project>
