<?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>org.no-hope</groupId>
    <artifactId>env-java</artifactId>
    <version>11</version>

    <packaging>pom</packaging>
    <name>env-java</name>

    <description>
        Slightly improved version of default maven superpom:
        - Defines java version for source, target and compiler (or, alternatively aspectj compiler)
        - Enables useful warnings and messages from compiler
        - Adds 3rdparty implementation of jsr305 (@nullable annotations)
        - Turns on source jar generation
    </description>

    <url>https://github.com/no-hope/java-superpoms</url>

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

    <scm>
        <url>git@github.com:no-hope/java-superpoms.git</url>
        <connection>scm:git:git@github.com:no-hope/java-superpoms.git</connection>
        <developerConnection>scm:git:git@github.com:no-hope/java-superpoms.git</developerConnection>
    </scm>

    <developers>
        <developer>
            <id>ketoth.xupack</id>
            <name>Ketoth Xupack</name>
            <email>ketoth.xupack@gmail.com</email>
        </developer>
        <developer>
            <name>Fei Wong Reed</name>
            <email>feiwreed@gmail.com</email>
        </developer>
    </developers>

    <prerequisites>
        <maven>3.0</maven>
    </prerequisites>

    <parent>
        <groupId>org.sonatype.oss</groupId>
        <artifactId>oss-parent</artifactId>
        <version>7</version>
    </parent>

    <properties>
        <!-- System -->
        <aspectj.showWeaveInfo>false</aspectj.showWeaveInfo>

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

        <java.major.version>7</java.major.version>
        <java.lang.level>1.${java.major.version}</java.lang.level>

        <java.source.level>${java.lang.level}</java.source.level>
        <java.target.level>${java.lang.level}</java.target.level>
        <java.compiler.version>${java.lang.level}</java.compiler.version>

        <!-- Maven plugins -->
        <maven.aspectj-plugin.version>1.5</maven.aspectj-plugin.version>
        <maven.compiler-plugin.version>3.1</maven.compiler-plugin.version>
        <maven.jar-plugin.version>2.4</maven.jar-plugin.version>
        <maven-resources-plugin.version>2.6</maven-resources-plugin.version>
        <maven.source-plugin.version>2.2.1</maven.source-plugin.version>

        <!-- libs -->
        <aspectjrt.version>1.7.3</aspectjrt.version>
        <findbugs-annotations.version>2.0.1</findbugs-annotations.version>
        <jsr305.version>2.0.1</jsr305.version>
        <junit.version>4.11</junit.version>
    </properties>

    <profiles>
        <!-- production profile -->
        <profile>
            <id>global-production</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-compiler-plugin</artifactId>
                        <version>${maven.compiler-plugin.version}</version>
                        <configuration>
                            <debug>false</debug>
                            <optimize>true</optimize>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
            <activation>
                <property>
                    <name>production</name>
                </property>
            </activation>
        </profile>
    </profiles>

    <build>
        <finalName>PRJ: ${project.artifactId}</finalName>

        <pluginManagement>
            <!-- aspectj plugin -->
            <plugins>
                <plugin>
                    <groupId>org.codehaus.mojo</groupId>
                    <artifactId>aspectj-maven-plugin</artifactId>
                    <version>${maven.aspectj-plugin.version}</version>

                    <configuration>
                        <source>${java.lang.level}</source>
                        <target>${java.lang.level}</target>
                        <complianceLevel>${java.lang.level}</complianceLevel>
                        <showWeaveInfo>${aspectj.showWeaveInfo}</showWeaveInfo>
                    </configuration>

                    <dependencies>
                        <dependency>
                            <groupId>org.aspectj</groupId>
                            <artifactId>aspectjrt</artifactId>
                            <version>${aspectjrt.version}</version>
                        </dependency>
                        <dependency>
                            <groupId>org.aspectj</groupId>
                            <artifactId>aspectjtools</artifactId>
                            <version>${aspectjrt.version}</version>
                        </dependency>
                    </dependencies>

                    <executions>
                        <execution>
                            <goals>
                                <goal>compile</goal>
                                <goal>test-compile</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>

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

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

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>${maven.compiler-plugin.version}</version>
                <configuration>
                    <source>${java.source.level}</source>
                    <target>${java.target.level}</target>
                    <compilerVersion>${java.compiler.version}</compilerVersion>
                    <showDeprecation>true</showDeprecation>
                    <showWarnings>true</showWarnings>

                    <compilerArgument>-Xlint:unchecked</compilerArgument>

                    <debug>true</debug>
                    <optimize>false</optimize>
                    <debuglevel>vars,lines,source</debuglevel>
                </configuration>
            </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>
                    </execution>
                </executions>
            </plugin>

        </plugins>
    </build>

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>com.google.code.findbugs</groupId>
                <artifactId>jsr305</artifactId>
                <version>${jsr305.version}</version>
            </dependency>

            <dependency>
                <groupId>org.aspectj</groupId>
                <artifactId>aspectjrt</artifactId>
                <version>${aspectjrt.version}</version>
            </dependency>

            <dependency>
                <groupId>com.google.code.findbugs</groupId>
                <artifactId>annotations</artifactId>
                <version>${findbugs-annotations.version}</version>
            </dependency>

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