<?xml version='1.0' encoding='UTF-8'?>
<!--
  ~ Copyright (c) jGuru Europe AB.
  ~ All rights reserved.
  -->

<!--suppress MavenRedundantGroupId -->
<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>

    <!--
    ################################################
    # Section 1:  Project information
    ################################################
    -->
    <parent>
        <groupId>se.jguru.codestyle.poms.kotlin</groupId>
        <artifactId>jguru-codestyle-kotlin-internal-parent</artifactId>
        <version>0.11.0</version>
        <relativePath>../kotlin-internal-parent</relativePath>
    </parent>

    <groupId>se.jguru.codestyle.poms.kotlin</groupId>
    <artifactId>jguru-codestyle-kotlin-parent</artifactId>
    <packaging>pom</packaging>
    <name>${project.artifactId}</name>
    <url>${site.top.url}/${path.in.reactor}</url>
    <description>jGuru Codestyle: Kotlin Parent (${project.packaging}, version ${project.version})</description>

    <properties>
        <!--
            Define the URL prefixes for Site Deployment and DistributionManagement.
            These can be overridden in sub-reactors to tailor releases to other locations.
        -->
        <path.in.reactor>poms/kotlin/kotlin-parent</path.in.reactor>

        <!-- Dependency properties -->
        <nazgul-tools.version>6.0.3</nazgul-tools.version>
        <nazgul-core.version>3.0.0</nazgul-core.version>

        <enforcer.version>3.0.0-M3</enforcer.version>
        <enforcer.includedGroupIdPatterns>^se\.jguru\..*</enforcer.includedGroupIdPatterns>
        <enforcer.excludedGroupIdPatterns>^se\.jguru\..*\.generated\..*,^se\.jguru\.codestyle\..*</enforcer.excludedGroupIdPatterns>
        <breakOnFailure.enforcer>true</breakOnFailure.enforcer>
        
        <!-- License plugin configuration parameters. -->
        <license.id>jguru_apl_v2</license.id>
        <license.licenseResolver>classpath://codestyle/license</license.licenseResolver>
        <breakOnFailure.license>true</breakOnFailure.license>
    </properties>

    <!--
    ################################################
    # Section 2:  Dependency (management) settings
    ################################################
    -->

    <!--
    ################################################
    # Section 3:  Build settings
    ################################################
    -->
    <build>
        <pluginManagement>
            <plugins>

                <!--
                    The license plugin is quite inflexible about the format for the injected/detected file header
                    in terms of license structure. Use it as intended, but provide a variable to handle the
                    desired license and license resolver.

                    Why:  Ensures that all files contain a license header.
                    Used: Standard lifecycle, mvn package.
                -->
                <plugin>
                    <groupId>org.codehaus.mojo</groupId>
                    <artifactId>license-maven-plugin</artifactId>
                    <version>2.0.0</version>
                    <configuration>
                        <encoding>${project.build.sourceEncoding}</encoding>
                        <descriptionTemplate>/codestyle/license/${license.id}/licenseDescriptionTemplate.ftl
                        </descriptionTemplate>
                        <failOnMissingHeader>${breakOnFailure.license}</failOnMissingHeader>
                        <licenseName>${license.id}</licenseName>
                        <licenseResolver>${license.licenseResolver}</licenseResolver>
                        <canUpdateDescription>true</canUpdateDescription>
                        <addJavaLicenseAfterPackage>false</addJavaLicenseAfterPackage>
                        <licenseFile>${project.build.directory}/LICENSE.TXT</licenseFile>
                        <roots>
                            <root>${project.basedir}/src/main</root>
                            <root>${project.basedir}/src/site</root>
                        </roots>
                        <excludes>
                            <!-- Custom excludes -->
                            <param>**/*.json</param>
                            <!-- Modelling filetypes -->
                            <param>**/*.zargo</param>
                            <param>**/*.uml</param>
                            <param>**/*.umldi</param>
                            <param>**/*.umldi</param>
                            <param>**/*.xmi</param>
                            <!-- Image filetypes -->
                            <param>**/*.img</param>
                            <param>**/*.png</param>
                            <param>**/*.jpg</param>
                            <param>**/*.jpeg</param>
                            <param>**/*.gif</param>
                            <!-- Archives -->
                            <param>**/*.zip</param>
                            <param>**/*.jar</param>
                            <param>**/*.war</param>
                            <param>**/*.ear</param>
                            <param>**/*.tgz</param>
                            <param>**/*.gz</param>
                        </excludes>
                    </configuration>
                    <dependencies>
                        <dependency>
                            <groupId>se.jguru.codestyle</groupId>
                            <artifactId>jguru-codestyle</artifactId>
                            <version>0.11.0</version>
                        </dependency>
                    </dependencies>
                </plugin>

                <!--
                    Configure JAR plugin.

                    Why:  Assigns some manifest data within JARs. Reads bundle-generated manifest.
                    Used: Standard lifecycle, mvn package.
                -->
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-jar-plugin</artifactId>
                    <version>3.1.1</version>
                    <configuration>
                        <archive>
                            <manifest>
                                <addDefaultSpecificationEntries>true</addDefaultSpecificationEntries>
                            </manifest>
                            <manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
                            <manifestEntries>
                                <name>${project.name}</name>
                                <description>${project.description}</description>
                                <groupId>${project.groupId}</groupId>
                                <artifactId>${project.artifactId}</artifactId>
                            </manifestEntries>
                        </archive>
                    </configuration>
                </plugin>


                <!-- Enforce not importing incorrect projects. -->
                <plugin>
                    <artifactId>maven-enforcer-plugin</artifactId>
                    <version>${enforcer.version}</version>
                    <configuration combine.self="override">
                        <fail>${breakOnFailure.enforcer}</fail>
                        <rules>
                            <requireMavenVersion>
                                <version>[3.0.5,)</version>
                            </requireMavenVersion>
                            <requireJavaVersion>
                                <version>${jdk.version}</version>
                            </requireJavaVersion>

                            <!--
                                Enforce the ProjectType structure, implying that all projects
                                must comply with the project template definitions.
                            -->
                            <validateProjectTypes implementation="se.jguru.codestyle.projects.enforcer.PermittedProjectTypeRule" />

                            <!--
                                Enforce the implementation rules for dependencies, to enforce that
                                the level of dependency tanglement is not increased. This implies that
                                implementation projects cannot import other implementation projects (but
                                instead should import APIs).

                                While the configuration below reflect the default settings, it is
                                reproduced her to serve as an example of how to configure this enforcement rule
                                in child reactors - where needs are likely different than here.
                            -->
                            <restrictImplDependencies implementation="se.jguru.codestyle.projects.enforcer.CorrectDependenciesRule">
                                <evaluateGroupIds>${enforcer.includedGroupIdPatterns}</evaluateGroupIds>
                                <dontEvaluateGroupIds>${enforcer.excludedGroupIdPatterns}</dontEvaluateGroupIds>
                            </restrictImplDependencies>

                            <!--
                                Enforce using correct packages for classes within a NSC project.
                                The root package of any project should be identical to its groupId.
                                Any package below the root package can safely be used - so ...

                                if the groupId of a project is "com.acme.foobar",
                                then all code within that project must reside within the "com.acme.foobar" package,
                                or in any subpackage thereof.
                            -->
                            <correctPackaging implementation="se.jguru.codestyle.projects.enforcer.CorrectPackagingRule" />
                        </rules>
                    </configuration>
                    <dependencies>
                        <dependency>
                            <groupId>se.jguru.codestyle</groupId>
                            <artifactId>jguru-codestyle</artifactId>
                            <version>0.11.0</version>
                        </dependency>
                        <dependency>
                            <groupId>org.apache.maven.enforcer</groupId>
                            <artifactId>enforcer-api</artifactId>
                            <version>${enforcer.version}</version>
                        </dependency>
                    </dependencies>
                </plugin>
            </plugins>
        </pluginManagement>

        <plugins>
            <!--
                The license plugin is quite inflexible about the format for the injected/detected file header
                in terms of license structure. Use it as intended, but provide a variable to handle the
                desired license and license resolver.

                Why:  Ensures that all files contain a license header.
                Used: Standard lifecycle, mvn package.
            -->
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>license-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <id>check-file-header</id>
                        <phase>process-sources</phase>
                        <goals>
                            <goal>check-file-header</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>add-license</id>
                        <phase>generate-sources</phase>
                        <goals>
                            <goal>update-project-license</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

            <!--
                Enforce that projects 
            -->
            <plugin>
                <artifactId>maven-enforcer-plugin</artifactId>
                <version>${enforcer.version}</version>
                <executions>
                    <execution>
                        <id>enforce-imports</id>
                        <goals>
                            <goal>enforce</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

            <!-- Generate dependency graph -->
            <plugin>
                <groupId>com.github.ferstl</groupId>
                <artifactId>depgraph-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <id>generate-dependency-graph-image</id>
                        <phase>pre-site</phase>
                        <goals>
                            <goal>graph</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

    <!--
    ################################################
    # Section 4:  External systems
    ################################################
    -->

    <!--
        Compensate for Maven standard variable extrapolation.
        Git requires steady URLs (... but Subversion requires path extrapolation, hence the problem).
     -->
    <distributionManagement>
        <site>
            <id>github_site</id>
            <name>GitHub Site for jGuru Codestyle</name>
            <url>${site.top.url}/${path.in.reactor}</url>
        </site>
    </distributionManagement>

    <!--
        Define connections for Maven's VCS integration.
    -->
    <scm>
        <connection>${scm.connection.url}</connection>
        <developerConnection>${scm.devConnection.url}</developerConnection>
        <url>${scm.url}</url>
        <tag>jguru-codestyle-0.11.1</tag>
    </scm>

    <!--
    ################################################
    # Section 5:  Profiles
    ################################################
    -->
    <profiles>
        <!--
            Includes static AspectJ Weaving into bytecode, wherever Validatable classes are encountered.
            Defines the property of the
        -->
        <profile>
            <id>use-aspectj-validation</id>
            <activation>
                <property>
                    <name>validation</name>
                    <value>aspectj</value>
                </property>
            </activation>

            <properties>

                <!-- AspectJ Properties -->
                <aspectj.runtime.version>1.9.6</aspectj.runtime.version>
                <aspectj-maven-plugin.version>1.11</aspectj-maven-plugin.version>
            </properties>

            <!--
            ################################################
            # Section 2:  Dependency (management) settings
            ################################################
            -->
            <dependencyManagement>
                <dependencies>
                    <dependency>
                        <groupId>se.jguru.nazgul.tools.validation.aspect</groupId>
                        <artifactId>nazgul-tools-validation-aspect</artifactId>
                        <version>${nazgul-tools.version}</version>
                    </dependency>

                    <!--
                        The AspectJ Runtime is only required in compile scope for projects actually compiling Aspects.
                        For normal project just using the validation-aspect (implying that classes in them implement
                        or extend Validatable), the default scope for AspectJ should be runtime.
                    -->
                    <dependency>
                        <groupId>org.aspectj</groupId>
                        <artifactId>aspectjrt</artifactId>
                        <version>${aspectj.runtime.version}</version>
                        <scope>runtime</scope>
                    </dependency>
                </dependencies>
            </dependencyManagement>

            <dependencies>
                <!--
                    These dependencies contain globally available Aspects and their required runtime libraries.
                    No other dependencies must be included here.
                -->
                <dependency>
                    <groupId>se.jguru.nazgul.tools.validation.aspect</groupId>
                    <artifactId>nazgul-tools-validation-aspect</artifactId>
                </dependency>
                <dependency>
                    <groupId>org.aspectj</groupId>
                    <artifactId>aspectjrt</artifactId>
                </dependency>
            </dependencies>

            <!--
            ################################################
            # Section 3:  Build settings
            ################################################
            -->
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.codehaus.mojo</groupId>
                        <artifactId>aspectj-maven-plugin</artifactId>
                        <version>${aspectj-maven-plugin.version}</version>
                        <configuration>
                            <complianceLevel>${jdk.version}</complianceLevel>
                            <includes>
                                <include>**/*.java</include>
                                <include>**/*.aj</include>
                            </includes>
                            <aspectDirectory>src/main/aspect</aspectDirectory>
                            <testAspectDirectory>src/test/aspect</testAspectDirectory>
                            <!--
                               This option causes the JoinPoint.getStaticPart() to
                               sometimes return null - which crashes all Aspects relying
                               on JoinPoint static information.... such as the ValidationAspect.

                               Yes - it is a bug in AspectJ.
                               // Lennart, 2011-07-23
                            -->
                            <XaddSerialVersionUID>true</XaddSerialVersionUID>
                            <showWeaveInfo>true</showWeaveInfo>
                            <aspectLibraries>
                                <aspectLibrary>
                                    <groupId>se.jguru.nazgul.tools.validation.aspect</groupId>
                                    <artifactId>nazgul-tools-validation-aspect</artifactId>
                                </aspectLibrary>
                            </aspectLibraries>
                        </configuration>
                        <executions>
                            <execution>
                                <id>compile_with_aspectj</id>
                                <goals>
                                    <goal>compile</goal>
                                </goals>
                            </execution>
                            <execution>
                                <id>test-compile_with_aspectj</id>
                                <goals>
                                    <goal>test-compile</goal>
                                </goals>
                            </execution>
                        </executions>
                        <dependencies>
                            <dependency>
                                <groupId>org.aspectj</groupId>
                                <artifactId>aspectjtools</artifactId>
                                <version>${aspectj.runtime.version}</version>
                            </dependency>
                            <dependency>
                                <groupId>se.jguru.nazgul.tools.validation.aspect</groupId>
                                <artifactId>nazgul-tools-validation-aspect</artifactId>
                                <version>${nazgul-tools.version}</version>
                            </dependency>
                        </dependencies>
                    </plugin>
                </plugins>
            </build>

            <reporting>
                <plugins>
                    <plugin>
                        <groupId>org.codehaus.mojo</groupId>
                        <artifactId>aspectj-maven-plugin</artifactId>
                        <version>${aspectj-maven-plugin.version}</version>
                        <configuration>
                            <verbose>true</verbose>
                            <privateScope>true</privateScope>
                            <complianceLevel>${jdk.version}</complianceLevel>
                            <doctitle>AspectJ Weaving Report</doctitle>
                        </configuration>
                        <reportSets>
                            <reportSet>
                                <reports>
                                    <report>aspectj-report</report>
                                </reports>
                            </reportSet>
                        </reportSets>
                    </plugin>
                </plugins>
            </reporting>
        </profile>

        <profile>
            <id>jdk9</id>
            <activation>
                <jdk>9</jdk>
            </activation>

            <dependencies>
                <dependency>
                    <groupId>org.jetbrains.kotlin</groupId>
                    <artifactId>kotlin-stdlib-jdk8</artifactId>
                    <version>${kotlin.version}</version>
                </dependency>
                <dependency>
                    <groupId>org.jetbrains.kotlin</groupId>
                    <artifactId>kotlin-test-junit</artifactId>
                    <version>${kotlin.version}</version>
                    <scope>test</scope>
                </dependency>
            </dependencies>

            <build>
                <plugins>
                    <plugin>
                        <artifactId>maven-compiler-plugin</artifactId>
                        <configuration>
                            <compilerArgs>
                                <arg>--add-modules=java.xml.bind</arg>
                            </compilerArgs>
                            <!-- without forking compilation happens in the
                                same process, so no arguments are applied -->
                            <fork>true</fork>
                        </configuration>
                    </plugin>
                    <plugin>
                        <artifactId>maven-surefire-plugin</artifactId>
                        <configuration>
                            <argLine>
                                --add-modules java.xml.bind
                                --illegal-access=deny
                            </argLine>
                        </configuration>
                    </plugin>
                    <plugin>
                        <artifactId>maven-failsafe-plugin</artifactId>
                        <configuration>
                            <argLine>
                                --add-modules java.xml.bind
                                --illegal-access=deny
                            </argLine>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>

        <profile>
            <id>jdk8</id>
            <activation>
                <jdk>8</jdk>
            </activation>

            <dependencies>
                <dependency>
                    <groupId>org.jetbrains.kotlin</groupId>
                    <artifactId>kotlin-stdlib-jdk8</artifactId>
                    <version>${kotlin.version}</version>
                </dependency>
                <dependency>
                    <groupId>org.jetbrains.kotlin</groupId>
                    <artifactId>kotlin-test-junit</artifactId>
                    <version>${kotlin.version}</version>
                    <scope>test</scope>
                </dependency>
            </dependencies>
        </profile>
    </profiles>
</project>
