<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/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>org.opensplice.dds.examples.Tutorial.java5.Messageboard</groupId>
    <artifactId>java5-Messageboard</artifactId>
    <name>org.opensplice.dds.examples.Tutorial.java5.Messageboard</name>
    <version>1.0</version>
    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <gen-idl-dir>${project.build.directory}/generated-sources/idl/</gen-idl-dir>
        <example-idl>-l java -S "../../../../../idl/Chat.idl"</example-idl>
        <idlpp_exec>idlpp</idlpp_exec>
        <src-dir>src</src-dir>
        <jar-name>java5_Messageboard</jar-name>
        <mainclassname>chatroom.MessageBoard</mainclassname>
    </properties>
    <parent>
        <groupId>org.opensplice.dds.examples.Tutorial.java5</groupId>
        <artifactId>examples.Tutorial.java5</artifactId>
        <version>1.0</version>
    </parent>
    <profiles>
        <!-- Profile selection based on the java5 jar location -->
        <profile>
            <id>installer-tree</id>
            <activation>
                <file>
                    <exists>${env.OSPL_HOME}/jar/dcpssaj5.jar</exists>
                </file>
            </activation>
            <properties>
                <dcpssaj5-loc>
                    ${env.OSPL_HOME}/jar/dcpssaj5.jar
                </dcpssaj5-loc>
            </properties>
            <dependencies>
                <dependency>
                    <groupId>dcpssaj5-location</groupId>
                    <artifactId>dcpssaj5-jar</artifactId>
                    <version>1.0.0</version>
                    <scope>system</scope>
                    <systemPath>${dcpssaj5-loc}</systemPath>
                </dependency>
            </dependencies>
        </profile>
        <profile>
            <id>development-tree</id>
            <activation>
                <file>
                    <exists>${env.OSPL_HOME_NORMALIZED}/jar/${env.SPLICE_TARGET}/dcpssaj5.jar</exists>
                </file>
            </activation>
            <properties>
                <dcpssaj5-loc>
                    ${env.OSPL_HOME_NORMALIZED}/jar/${env.SPLICE_TARGET}/dcpssaj5.jar
                </dcpssaj5-loc>
            </properties>
            <dependencies>
                <dependency>
                    <groupId>dcpssaj5-location</groupId>
                    <artifactId>dcpssaj5-jar</artifactId>
                    <version>1.0.0</version>
                    <scope>system</scope>
                    <systemPath>${dcpssaj5-loc}</systemPath>
                </dependency>
            </dependencies>
        </profile>
    </profiles>
    <build>
        <sourceDirectory>${src-dir}</sourceDirectory>
        <plugins>
            <!-- run idlpp -->
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>exec-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <id>generate-sources</id>
                        <phase>generate-sources</phase>
                        <goals>
                            <goal>exec</goal>
                        </goals>
                        <configuration>
                            <executable>${idlpp_exec}</executable>
                            <workingDirectory>${gen-idl-dir}</workingDirectory>
                            <commandlineArgs>${example-idl}</commandlineArgs>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-antrun-plugin</artifactId>
                <version>1.8</version>
                <executions>
                    <execution>
                        <phase>validate</phase>
                        <goals>
                            <goal>run</goal>
                        </goals>
                        <configuration>
                            <target>
                                <property name="dcpssaj5-loc-rel" location="${dcpssaj5-loc}" relative="true" />
                            </target>
                            <exportAntProperties>true</exportAntProperties>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <artifactId>maven-clean-plugin</artifactId>
                <version>2.5</version>
                <configuration>
                    <filesets>
                        <fileset>
                            <directory>${basedir}</directory>
                            <followSymlinks>false</followSymlinks>
                            <includes>
                                <include>${jar-name}.jar</include>
                            </includes>
                        </fileset>
                    </filesets>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>build-helper-maven-plugin</artifactId>
                <version>1.7</version>
                <executions>
                    <execution>
                        <id>add-generated-sources</id>
                        <phase>generate-sources</phase>
                        <goals>
                            <goal>add-source</goal>
                        </goals>
                        <configuration>
                            <sources>
                                <source>${gen-idl-dir}</source>
                                <source>${src-dir}</source>
                            </sources>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <!-- set minimum java version to 1.6 -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.1</version>
                <configuration>
                    <source>1.6</source>
                    <target>1.6</target>
                    <verbose>false</verbose>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <version>2.3.2</version>
                <configuration>
                    <finalName>${jar-name}</finalName>
                    <outputDirectory>${basedir}</outputDirectory>
                    <archive>
                        <manifest>
                            <mainClass>${mainclassname}</mainClass>
                        </manifest>
                        <manifestEntries>
                            <Class-Path>${dcpssaj5-loc-rel}</Class-Path>
                        </manifestEntries>
                    </archive>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-enforcer-plugin</artifactId>
                <version>1.3.1</version>
                <executions>
                    <execution>
                        <id>default-cli</id>
                        <goals>
                            <goal>enforce</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <rules>
                        <requireEnvironmentVariable>
                            <variableName>OSPL_HOME</variableName>
                            <message>OSPL_HOME system variable must be set! please run release.(bat|com)</message>
                        </requireEnvironmentVariable>
                    </rules>
                    <fail>true</fail>
                    <failfast>true</failfast>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>
