<!--
  Copyright(c) 2006 to 2018 ADLINK Technology Limited and others

  This program and the accompanying materials are made available under the
  terms of the Eclipse Public License v. 2.0 which is available at
  http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License
  v. 1.0 which is available at
  http://www.eclipse.org/org/documents/edl-v10.php.

  SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
-->
<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.eclipse.cyclonedds</groupId>
    <artifactId>idlc</artifactId>
    <version>@PROJECT_VERSION@</version>
    <packaging>jar</packaging>
    <name>IDL Compiler</name>

    <dependencies>
        <dependency>
            <groupId>org.antlr</groupId>
            <artifactId>antlr-complete</artifactId>
            <version>3.5.2</version>
        </dependency>
        <dependency>
            <groupId>org.antlr</groupId>
            <artifactId>antlr4-runtime</artifactId>
            <version>4.5</version>
        </dependency>
        <dependency>
            <groupId>org.antlr</groupId>
            <artifactId>ST4</artifactId>
            <version>4.0.8</version>
        </dependency> 
    </dependencies>

    <build>
        <finalName>idlc</finalName>
        <sourceDirectory>${basedir}</sourceDirectory>
        <resources>
            <resource>
                <directory>${basedir}</directory>
                <includes>
                    <include>org/eclipse/cyclonedds/templates/**</include>
                </includes>
            </resource>
        </resources>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-resources-plugin</artifactId>
                <version>3.0.2</version>
                <configuration>
                    <encoding>UTF-8</encoding>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.antlr</groupId>
                <artifactId>antlr4-maven-plugin</artifactId>
                <version>4.5</version>
                <configuration>
                    <sourceDirectory>${basedir}/org/eclipse/cyclonedds/parser/grammar</sourceDirectory>
                    <visitor>true</visitor>
                    <listener>false</listener>
                </configuration>
                <executions>
                    <execution>
                        <id>antlr</id>
                        <phase>generate-sources</phase>
                        <goals>
                            <goal>antlr4</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <!-- FIXME: Support for licensing is currently not included.
                        Obviously this should be fixed before the product is
                        released. Using different profiles for development and
                        release build is probably a good idea. -->
            <plugin>
                <groupId>com.coderplus.maven.plugins</groupId>
                <artifactId>copy-rename-maven-plugin</artifactId>
                <version>1.0</version>
                <executions>
                    <execution>
                        <id>copy-Version</id>
                        <phase>generate-sources</phase>
                        <goals>
                            <goal>copy</goal>
                        </goals>
                        <configuration>
                            <sourceFile>${CMAKE_CURRENT_BINARY_DIR}/org/eclipse/cyclonedds/Project.java</sourceFile>
                            <destinationFile>target/generated-sources/idlc/org/eclipse/cyclonedds/Project.java</destinationFile>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>build-helper-maven-plugin</artifactId>
                <version>3.0.0</version>
                <executions>
                    <execution>
                        <phase>generate-sources</phase>
                        <goals>
                            <goal>add-source</goal>
                        </goals>
                        <configuration>
                            <sources>
                                <source>target/generated-sources/idlc</source>
                            </sources>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <artifactId>maven-assembly-plugin</artifactId>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>single</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <descriptorRefs>
                        <descriptorRef>jar-with-dependencies</descriptorRef>
                    </descriptorRefs>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-antrun-plugin</artifactId>
                <version>1.8</version>
                <dependencies>
                    <dependency>
                        <groupId>antlr</groupId>
                        <artifactId>antlr</artifactId>
                        <version>2.7.7</version>
                    </dependency>
                    <dependency>
                        <groupId>org.apache.ant</groupId>
                        <artifactId>ant-antlr</artifactId>
                        <version>1.9.4</version>
                    </dependency>
                </dependencies>
                <executions>
                    <execution>
                        <id>compile</id>
                        <phase>generate-sources</phase>
                        <configuration>
                            <target>
                                <mkdir dir="target/generated-sources/idlc/org/eclipse/cyclonedds/idt/imports/idl/internal/preprocessor"/>
                                <antlr target="${basedir}/org/eclipse/cyclonedds/idt/imports/idl/internal/preprocessor/CppLexer.g" outputdirectory="target/generated-sources/idlc/org/eclipse/cyclonedds/idt/imports/idl/internal/preprocessor"/>
                                <antlr target="${basedir}/org/eclipse/cyclonedds/idt/imports/idl/internal/preprocessor/ExpLexer.g" outputdirectory="target/generated-sources/idlc/org/eclipse/cyclonedds/idt/imports/idl/internal/preprocessor"/>
                            </target>
                        </configuration>
                        <goals>
                            <goal>run</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>

