<?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>
    <parent>
        <groupId>org.apache.sling</groupId>
        <artifactId>sling</artifactId>
        <version>38</version>
        <relativePath />
    </parent>

    <groupId>pl.ds.websight</groupId>
    <artifactId>websight-package-parent</artifactId>
    <version>4</version>
    <packaging>pom</packaging>

    <organization>
        <name>Dynamic Solutions sp. z o.o. sp. k.</name>
        <url>https://ds.pl</url>
    </organization>

    <name>Dynamic Solutions WebSight (Package Parent)</name>
    <description>The parent project for WebSight vault package modules</description>
    <url>https://github.com/DS-WebSight/websight-parent-reactor</url>

    <licenses>
        <license>
            <name>GNU Affero General Public License v3.0</name>
            <url>https://github.com/DS-WebSight/websight-parent-reactor/blob/master/LICENSE</url>
        </license>
    </licenses>

    <developers>
        <developer>
            <name>Michał Cukierman</name>
            <email>michal.cukierman@ds.pl</email>
            <organization>Dynamic Solutions</organization>
            <organizationUrl>https://www.ds.pl/</organizationUrl>
        </developer>
    </developers>

    <scm>
        <tag>4</tag>
        <connection>scm:git:git://github.com/DS-WebSight/websight-parent-reactor.git</connection>
        <developerConnection>scm:git:ssh://github.com:DS-WebSight/websight-parent-reactor.git</developerConnection>
        <url>https://github.com/DS-WebSight/websight-parent-reactor/tree/master</url>
    </scm>

    <properties>
        <autoReleaseAfterClose>false</autoReleaseAfterClose>
    </properties>

    <build>
        <plugins>
            <plugin>
                <groupId>org.codehaus.gmavenplus</groupId>
                <artifactId>gmavenplus-plugin</artifactId>
                <version>1.12.1</version>
                <executions>
                    <execution>
                        <id>set-skip-license-check-flag</id>
                        <phase>validate</phase>
                        <goals>
                            <goal>execute</goal>
                        </goals>
                        <configuration>
                            <scripts>
                                <script><![CDATA[
                                    boolean isArchiveArtifact = project.packaging != 'pom'
                                    log.info("Package ${isArchiveArtifact ? 'is' : 'is not'} an archive artifact, setting skipLicenseCheck=${!isArchiveArtifact}")
                                    project.properties['skipLicenseCheck'] = String.valueOf(!isArchiveArtifact)
                                ]]></script>
                            </scripts>
                        </configuration>
                    </execution>
                </executions>
                <dependencies>
                    <dependency>
                        <groupId>org.codehaus.groovy</groupId>
                        <artifactId>groovy-all</artifactId>
                        <version>2.4.19</version>
                        <scope>runtime</scope>
                    </dependency>
                </dependencies>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-resources-plugin</artifactId>
                <version>3.2.0</version>
                <executions>
                    <execution>
                        <id>copy-license-file-to-target</id>
                        <phase>generate-resources</phase>
                        <goals>
                            <goal>copy-resources</goal>
                        </goals>
                        <configuration>
                            <resources>
                                <resource>
                                    <directory>${project.basedir}</directory>
                                    <includes>
                                        <include>LICENSE</include>
                                    </includes>
                                </resource>
                            </resources>
                            <outputDirectory>${project.build.directory}/vault-work/META-INF</outputDirectory>
                            <skip>${skipLicenseCheck}</skip>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-enforcer-plugin</artifactId>
                <version>3.0.0-M3</version>
                <executions>
                    <execution>
                        <id>enforce-license-exist-in-module-root</id>
                        <phase>validate</phase>
                        <goals>
                            <goal>enforce</goal>
                        </goals>
                        <configuration>
                            <rules>
                                <requireFilesExist>
                                    <files>
                                        <file>${basedir}/LICENSE</file>
                                    </files>
                                </requireFilesExist>
                            </rules>
                            <fail>true</fail>
                        </configuration>
                    </execution>
                    <execution>
                        <id>enforce-license-exist-in-target</id>
                        <phase>prepare-package</phase>
                        <goals>
                            <goal>enforce</goal>
                        </goals>
                        <configuration>
                            <rules>
                                <requireFilesExist>
                                    <files>
                                        <file>${project.build.directory}/vault-work/META-INF/LICENSE</file>
                                    </files>
                                </requireFilesExist>
                            </rules>
                            <fail>true</fail>
                            <skip>${skipLicenseCheck}</skip>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>org.apache.rat</groupId>
                <artifactId>apache-rat-plugin</artifactId>
                <configuration>
                    <!-- present in parent, disabled here -->
                    <skip>true</skip>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>ianal-maven-plugin</artifactId>
                <configuration>
                    <!-- present in parent, disabled here -->
                    <skip>true</skip>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-remote-resources-plugin</artifactId>
                <configuration>
                    <!-- present in parent, disabled here -->
                    <skip>true</skip>
                </configuration>
            </plugin>

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

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-javadoc-plugin</artifactId>
                <version>3.2.0</version>
                <executions>
                    <execution>
                        <id>attach-javadocs</id>
                        <goals>
                            <goal>jar</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>org.simplify4u.plugins</groupId>
                <artifactId>sign-maven-plugin</artifactId>
                <version>0.3.0</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>sign</goal>
                        </goals>
                        <configuration>
                            <skipNoKey>true</skipNoKey>
                            <keyFile>${user.home}/.m2/sign-key-ds.asc</keyFile>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.apache.jackrabbit</groupId>
                    <artifactId>filevault-package-maven-plugin</artifactId>
                    <extensions>true</extensions>
                    <version>1.1.2</version>
                    <configuration>
                        <!-- By default we provide OSGi bundles and configurations -->
                        <packageType>container</packageType>
                    </configuration>
                </plugin>
            </plugins>
        </pluginManagement>
    </build>

    <profiles>
        <profile>
            <id>centralRepository</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.sonatype.plugins</groupId>
                        <artifactId>nexus-staging-maven-plugin</artifactId>
                        <version>1.6.7</version>
                        <extensions>true</extensions>
                        <configuration>
                            <serverId>ossrh</serverId>
                            <nexusUrl>https://s01.oss.sonatype.org/</nexusUrl>
                            <autoReleaseAfterClose>${autoReleaseAfterClose}</autoReleaseAfterClose>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>

        <profile>
            <id>artifactory</id>
            <distributionManagement>
                <snapshotRepository>
                    <id>ds-snapshot</id>
                    <url>https://artifactory.ds.pl/artifactory/libs-snapshot</url>
                </snapshotRepository>
                <repository>
                    <id>ds-release</id>
                    <url>https://artifactory.ds.pl/artifactory/libs-release</url>
                </repository>
            </distributionManagement>
            <repositories>
                <repository>
                    <snapshots>
                        <enabled>false</enabled>
                    </snapshots>
                    <id>ds-release</id>
                    <name>libs-release</name>
                    <url>https://artifactory.ds.pl/artifactory/libs-release</url>
                </repository>
                <repository>
                    <snapshots />
                    <id>ds-snapshot</id>
                    <name>libs-snapshot</name>
                    <url>https://artifactory.ds.pl/artifactory/libs-snapshot</url>
                </repository>
            </repositories>
            <pluginRepositories>
                <pluginRepository>
                    <snapshots>
                        <enabled>false</enabled>
                    </snapshots>
                    <id>ds-release</id>
                    <name>libs-release</name>
                    <url>https://artifactory.ds.pl/artifactory/libs-release</url>
                </pluginRepository>
                <pluginRepository>
                    <snapshots />
                    <id>ds-snapshot</id>
                    <name>libs-snapshot</name>
                    <url>https://artifactory.ds.pl/artifactory/libs-snapshot</url>
                </pluginRepository>
            </pluginRepositories>
        </profile>
    </profiles>

</project>
