<?xml version="1.0" encoding="UTF-8"?>
<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>dev.dimlight</groupId>
    <artifactId>shellcheck-maven-plugin</artifactId>
    <version>0.5.0</version>
    <packaging>maven-plugin</packaging>

    <name>${project.groupId}:${project.artifactId}</name>
    <url>https://github.com/marco-nicolini/shellcheck-maven-plugin</url>
    <description>A maven plugin to execute shellcheck as part of a maven build</description>
    <inceptionYear>2020</inceptionYear>

    <licenses>
        <license>
            <name>GNU General Public License (GPL) version 3.0</name>
            <url>https://www.gnu.org/licenses/gpl-3.0.txt</url>
        </license>
    </licenses>

    <organization>
        <name>Marco Nicolini</name>
    </organization>

    <developers>
        <developer>
            <name>Marco Nicolini</name>
            <email>marco.nicolii[at]gmail.com</email>
            <url>https://github.com/marco-nicolini</url>
            <roles>
                <role>developer</role>
            </roles>
        </developer>
    </developers>

    <prerequisites>
        <maven>${maven.version}</maven>
    </prerequisites>

    <scm>
        <url>https://github.com/marco-nicolini/shellcheck-maven-plugin</url>
        <connection>scm:git:https://github.com/marco-nicolini/shellcheck-maven-plugin.git</connection>
        <developerConnection>scm:git:git@github.com:marco-nicolini/shellcheck-maven-plugin.git</developerConnection>
    </scm>

    <distributionManagement>
        <snapshotRepository>
            <id>ossrh</id>
            <url>https://oss.sonatype.org/content/repositories/snapshots</url>
        </snapshotRepository>
        <repository>
            <id>ossrh</id>
            <url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
        </repository>
    </distributionManagement>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
        <maven.version>3.5.4</maven.version>

        <shellcheck.version>0.9.0</shellcheck.version>
        <shellcheck.bins.directory>${project.build.directory}/classes/shellcheck-bin</shellcheck.bins.directory>

        <version.junit>4.13.2</version.junit>
        <version.maven-plugin-testing-harness>3.3.0</version.maven-plugin-testing-harness>
        <version.mojo-executor>2.3.2</version.mojo-executor>
        <version.spotbugs-annotations>4.5.0</version.spotbugs-annotations>
        <version.maven-plugin-annotations>3.6.1</version.maven-plugin-annotations>
        <version.file-management>3.0.0</version.file-management>
        <version.maven-plugin-plugin>3.6.0</version.maven-plugin-plugin>
        <version.download-maven-plugin>1.6.0</version.download-maven-plugin>
        <version.spotbugs-maven-plugin>4.5.0.0</version.spotbugs-maven-plugin>
        <version.maven-invoker-plugin>3.1.0</version.maven-invoker-plugin>
        <version.maven-source-plugin>3.2.0</version.maven-source-plugin>
        <version.maven-javadoc-plugin>3.2.0</version.maven-javadoc-plugin>
        <version.license-maven-plugin>2.0.0</version.license-maven-plugin>
        <version.maven-gpg-plugin>1.6</version.maven-gpg-plugin>
        <version.maven-checkstyle-plugin>3.1.2</version.maven-checkstyle-plugin>
        <version.checkstyle>9.3</version.checkstyle>
    </properties>

    <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</groupId>
            <artifactId>maven-artifact</artifactId>
            <version>${maven.version}</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.maven</groupId>
            <artifactId>maven-compat</artifactId>
            <version>${maven.version}</version>
            <scope>test</scope>
        </dependency>

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

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

        <dependency>
            <groupId>org.apache.maven.plugin-testing</groupId>
            <artifactId>maven-plugin-testing-harness</artifactId>
            <version>${version.maven-plugin-testing-harness}</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.twdata.maven</groupId>
            <artifactId>mojo-executor</artifactId>
            <version>${version.mojo-executor}</version>
        </dependency>

        <dependency>
            <groupId>com.github.spotbugs</groupId>
            <artifactId>spotbugs-annotations</artifactId>
            <version>${version.spotbugs-annotations}</version>
            <optional>true</optional>
        </dependency>

        <dependency>
            <groupId>org.apache.maven.shared</groupId>
            <artifactId>file-management</artifactId>
            <version>${version.file-management}</version>
        </dependency>
    </dependencies>

    <build>
        <pluginManagement><!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) -->
            <plugins>
                <plugin>
                    <artifactId>maven-clean-plugin</artifactId>
                    <version>3.1.0</version>
                </plugin>
                <!-- see http://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_maven-plugin_packaging -->
                <plugin>
                    <artifactId>maven-resources-plugin</artifactId>
                    <version>3.0.2</version>
                </plugin>
                <plugin>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <version>3.8.0</version>
                </plugin>
                <plugin>
                    <artifactId>maven-plugin-plugin</artifactId>
                    <version>3.6.0</version>
                </plugin>
                <plugin>
                    <artifactId>maven-surefire-plugin</artifactId>
                    <version>2.22.1</version>
                </plugin>
                <plugin>
                    <artifactId>maven-jar-plugin</artifactId>
                    <version>3.0.2</version>
                </plugin>
                <plugin>
                    <artifactId>maven-install-plugin</artifactId>
                    <version>2.5.2</version>
                </plugin>
                <plugin>
                    <artifactId>maven-deploy-plugin</artifactId>
                    <version>2.8.2</version>
                </plugin>
                <plugin>
                    <artifactId>maven-invoker-plugin</artifactId>
                    <version>3.1.0</version>
                </plugin>
            </plugins>
        </pluginManagement>

        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-plugin-plugin</artifactId>
                <version>${version.maven-plugin-plugin}</version>
                <configuration>
                    <!-- <goalPrefix>maven-archetype-plugin</goalPrefix> -->
                    <skipErrorNoDescriptorsFound>true</skipErrorNoDescriptorsFound>
                </configuration>
                <executions>
                    <execution>
                        <id>mojo-descriptor</id>
                        <goals>
                            <goal>descriptor</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>help-goal</id>
                        <goals>
                            <goal>helpmojo</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>com.googlecode.maven-download-plugin</groupId>
                <artifactId>download-maven-plugin</artifactId>
                <version>${version.download-maven-plugin}</version>
                <executions>
                    <execution>
                        <id>download-macOS_x86_64</id>
                        <phase>generate-resources</phase>
                        <goals>
                            <goal>wget</goal>
                        </goals>
                        <configuration>
                            <url>
                                https://github.com/koalaman/shellcheck/releases/download/v${shellcheck.version}/shellcheck-v${shellcheck.version}.darwin.x86_64.tar.xz
                            </url>
                            <unpack>true</unpack>
                            <outputDirectory>${shellcheck.bins.directory}/macOS_x86_64/</outputDirectory>
                        </configuration>
                    </execution>
                    <execution>
                        <id>download-Windows_x86</id>
                        <phase>generate-resources</phase>
                        <goals>
                            <goal>wget</goal>
                        </goals>
                        <configuration>
                            <url>
                                https://github.com/koalaman/shellcheck/releases/download/v${shellcheck.version}/shellcheck-v${shellcheck.version}.zip
                            </url>
                            <unpack>true</unpack>
                            <outputDirectory>${shellcheck.bins.directory}/Windows_x86/</outputDirectory>
                        </configuration>
                    </execution>
                    <execution>
                        <id>download-Linux_x86_64</id>
                        <phase>generate-resources</phase>
                        <goals>
                            <goal>wget</goal>
                        </goals>
                        <configuration>
                            <url>
                                https://github.com/koalaman/shellcheck/releases/download/v${shellcheck.version}/shellcheck-v${shellcheck.version}.linux.x86_64.tar.xz
                            </url>
                            <unpack>true</unpack>
                            <outputDirectory>${shellcheck.bins.directory}/Linux_x86_64/</outputDirectory>
                        </configuration>
                    </execution>
                    <execution>
                        <id>download-Linux_armv6hf</id>
                        <phase>generate-resources</phase>
                        <goals>
                            <goal>wget</goal>
                        </goals>
                        <configuration>
                            <url>
                                https://github.com/koalaman/shellcheck/releases/download/v${shellcheck.version}/shellcheck-v${shellcheck.version}.linux.armv6hf.tar.xz
                            </url>
                            <unpack>true</unpack>
                            <outputDirectory>${shellcheck.bins.directory}/Linux_armv6hf/</outputDirectory>
                        </configuration>
                    </execution>
                    <execution>
                        <id>download-Linux_aarch64</id>
                        <phase>generate-resources</phase>
                        <goals>
                            <goal>wget</goal>
                        </goals>
                        <configuration>
                            <url>
                                https://github.com/koalaman/shellcheck/releases/download/v${shellcheck.version}/shellcheck-v${shellcheck.version}.linux.aarch64.tar.xz
                            </url>
                            <unpack>true</unpack>
                            <outputDirectory>${shellcheck.bins.directory}/Linux_aarch64/</outputDirectory>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>com.github.spotbugs</groupId>
                <artifactId>spotbugs-maven-plugin</artifactId>
                <version>${version.spotbugs-maven-plugin}</version>
                <executions>
                    <execution>
                        <phase>verify</phase>
                        <goals>
                            <goal>check</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-checkstyle-plugin</artifactId>
                <version>${version.maven-checkstyle-plugin}</version>

                <dependencies>
                    <dependency>
                        <groupId>com.puppycrawl.tools</groupId>
                        <artifactId>checkstyle</artifactId>
                        <version>${version.checkstyle}</version>
                    </dependency>
                </dependencies>
                <executions>
                    <execution>
                        <id>check-java</id>
                        <goals>
                            <goal>check</goal>
                        </goals>
                        <phase>process-sources</phase>
                        <configuration>
                            <configLocation>${project.basedir}/src/main/checkstyle/checkstyle-configuration.xml
                            </configLocation>
                            <!-- only check handwritten code -->
                            <sourceDirectories>
                                <sourceDirectory>${project.basedir}/src/main/java</sourceDirectory>
                                <sourceDirectory>${project.basedir}/src/test/java</sourceDirectory>
                            </sourceDirectories>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-invoker-plugin</artifactId>
                <version>${version.maven-invoker-plugin}</version>
                <configuration>
                    <debug>true</debug>
                    <cloneProjectsTo>${project.build.directory}/it</cloneProjectsTo>
                    <pomIncludes>
                        <pomInclude>*/pom.xml</pomInclude>
                    </pomIncludes>
                    <postBuildHookScript>verify</postBuildHookScript>
                    <localRepositoryPath>${project.build.directory}/local-repo</localRepositoryPath>
                    <settingsFile>src/it/settings.xml</settingsFile>
                    <goals>
                        <goal>clean</goal>
                        <goal>install</goal>
                    </goals>
                </configuration>
                <executions>
                    <execution>
                        <id>integration-test</id>
                        <goals>
                            <goal>install</goal>
                            <goal>integration-test</goal>
                            <goal>verify</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-source-plugin</artifactId>
                <version>${version.maven-source-plugin}</version>
                <executions>
                    <execution>
                        <id>attach-sources</id>
                        <phase>verify</phase>
                        <goals>
                            <goal>jar-no-fork</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-javadoc-plugin</artifactId>
                <version>${version.maven-javadoc-plugin}</version>
                <configuration>
                    <show>public</show>
                </configuration>
                <executions>
                    <execution>
                        <id>attach-javadoc</id>
                        <phase>generate-resources</phase>
                        <goals>
                            <goal>jar</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>license-maven-plugin</artifactId>
                <version>${version.license-maven-plugin}</version>
                <configuration>
                    <licenseName>gpl_v3</licenseName>
                    <roots>
                        <root>src/main/java</root>
                        <root>src/test/java</root>
                    </roots>
                </configuration>
                <executions>
                    <execution>
                        <id>add-main-license-files</id>
                        <goals>
                            <goal>update-project-license</goal>
                        </goals>
                        <phase>process-sources</phase>
                        <configuration>
                        </configuration>
                    </execution>
                    <execution>
                        <id>add-license-headers</id>
                        <goals>
                            <goal>update-file-header</goal>
                        </goals>
                        <phase>process-sources</phase>
                        <configuration>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

    <profiles>
        <profile>
            <id>release</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-gpg-plugin</artifactId>
                        <version>${version.maven-gpg-plugin}</version>
                        <executions>
                            <execution>
                                <id>sign-artifacts</id>
                                <phase>verify</phase>
                                <goals>
                                    <goal>sign</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>
</project>
