<!--
  ~ Copyright (c) 2012 The ANTLR Project. All rights reserved.
  ~ Use of this file is governed by the BSD-3-Clause license that
  ~ can be found in the LICENSE.txt file in the project root.
  -->

<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>me.sunlan</groupId>
        <artifactId>antlr4-master</artifactId>
        <version>4.13.2.7</version>
    </parent>

    <artifactId>antlr4</artifactId>

    <name>ANTLR 4 Tool</name>
    <description>The ANTLR 4 grammar compiler.</description>

    <dependencies>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.13.2</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>me.sunlan</groupId>
            <artifactId>antlr4-runtime</artifactId>
            <version>${project.version}</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>me.sunlan</groupId>
            <artifactId>antlr4-annotations</artifactId>
            <version>${project.version}</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>org.antlr</groupId>
            <artifactId>antlr-runtime</artifactId>
            <version>3.5.3</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>org.antlr</groupId>
            <artifactId>ST4</artifactId>
            <version>4.3.4</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>org.abego.treelayout</groupId>
            <artifactId>org.abego.treelayout.core</artifactId>
            <version>1.0.3</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>com.ibm.icu</groupId>
            <artifactId>icu4j</artifactId>
            <version>58.3</version>
            <scope>provided</scope>
        </dependency>
    </dependencies>

    <profiles>
        <profile>
            <id>sonatype-oss-release</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-javadoc-plugin</artifactId>
                        <configuration>
                            <includeDependencySources>true</includeDependencySources>
                            <dependencySourceIncludes>
                                <dependencySourceInclude>me.sunlan:antlr4-*</dependencySourceInclude>
                            </dependencySourceIncludes>
                        </configuration>
                    </plugin>

                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-shade-plugin</artifactId>
                        <version>2.2</version>
                        <inherited>false</inherited>
                        <executions>
                            <execution>
                                <phase>package</phase>
                                <goals>
                                    <goal>shade</goal>
                                </goals>
                                <configuration>
                                    <minimizeJar>true</minimizeJar>
                                    <createDependencyReducedPom>false</createDependencyReducedPom>
                                    <shadedArtifactAttached>true</shadedArtifactAttached>
                                    <createSourcesJar>true</createSourcesJar>
                                    <shadedClassifierName>complete</shadedClassifierName>
                                    <filters>
                                        <filter>
                                            <artifact>me.sunlan:antlr4-runtime</artifact>
                                            <includes>
                                                <include>org/antlr/v4/runtime/**</include>
                                            </includes>
                                        </filter>
                                        <filter>
                                            <artifact>me.sunlan:antlr4-annotations</artifact>
                                            <includes>
                                                <include>org/antlr/v4/runtime/**</include>
                                            </includes>
                                        </filter>
                                    </filters>
                                    <transformers>
                                        <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
                                            <mainClass>org.antlr.v4.Tool</mainClass>
                                        </transformer>
                                    </transformers>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>

        <profile>
            <id>jacoco</id>
            <activation>
                <property>
                    <name>ENABLE_JACOCO</name>
                    <value>true</value>
                </property>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.jacoco</groupId>
                        <artifactId>jacoco-maven-plugin</artifactId>
                        <version>0.8.8</version>
                        <executions>
                            <execution>
                                <goals>
                                    <goal>prepare-agent</goal>
                                </goals>
                            </execution>
                            <execution>
                                <id>report</id>
                                <phase>test</phase>
                                <goals>
                                    <goal>report</goal>
                                </goals>
                            </execution>
                            <execution>
                                <id>report-aggregate</id>
                                <phase>test</phase>
                                <goals>
                                    <goal>report-aggregate</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>

    <build>

        <sourceDirectory>src</sourceDirectory>
        <resources>
            <resource>
                <directory>resources</directory>
            </resource>
        </resources>

        <testSourceDirectory>test</testSourceDirectory>
        <testResources>
            <testResource>
                <directory>test</directory>
            </testResource>
        </testResources>

        <plugins>
            <plugin>
                <groupId>com.webguys</groupId>
                <artifactId>string-template-maven-plugin</artifactId>
                <version>1.1</version>
                <!-- this nonsense is for some reason needed to make this plugin work with maven 3 -->
                <dependencies>
                    <dependency>
                        <groupId>org.twdata.maven</groupId>
                        <artifactId>mojo-executor</artifactId>
                        <version>2.4.0</version>
                    </dependency>
                    <dependency>
                        <groupId>com.ibm.icu</groupId>
                        <artifactId>icu4j</artifactId>
                        <version>58.3</version>
                    </dependency>
                </dependencies>
                <configuration>
                    <templates>
                        <template>
                            <directory>${basedir}/resources/org/antlr/v4/tool/templates</directory>
                            <name>unicodedata</name>
                            <target>${basedir}/target/generated-sources/tool/src/org/antlr/v4/unicode/UnicodeData.java</target>
                            <controller>
                                <className>org.antlr.v4.unicode.UnicodeDataTemplateController</className>
                                <sourceVersion>1.8</sourceVersion>
                                <targetVersion>1.8</targetVersion>
                                <method>getProperties</method>
                            </controller>
                        </template>
                    </templates>
                </configuration>
                <executions>
                    <execution>
                        <phase>generate-sources</phase>
                        <goals>
                            <goal>render</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>org.antlr</groupId>
                <artifactId>antlr3-maven-plugin</artifactId>
                <version>3.5.3</version>
                <configuration>
                    <sourceDirectory>src</sourceDirectory>
                    <verbose>true</verbose>
                </configuration>
                <executions>
                    <execution>
                        <goals>
                            <goal>antlr</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>me.sunlan</groupId>
                <artifactId>antlr4-testgen-maven-plugin</artifactId>
                <version>${project.version}</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>antlr4.testgen</goal>
                        </goals>
                        <configuration>
                            <runtimeTemplates>test/org/antlr/v4/test/runtime/java/Java.test.stg</runtimeTemplates>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <executions>
                    <execution>
                        <goals>
                            <goal>test-jar</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

        </plugins>
    </build>

</project>
