<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <modelVersion>4.0.0</modelVersion>
  <groupId>org.eclipse.elk</groupId>
  <artifactId>parent</artifactId>
  <name>Eclipse Layout Kernel</name>
  <version>0.0.1-SNAPSHOT</version>
  <packaging>pom</packaging>


  <!-- Define a few properties used throughout all build profiles. -->
  <properties>
    <targetJdk>1.8</targetJdk>
    <tycho-version>0.21.0</tycho-version>
    <xtext-version>2.7.2</xtext-version>

    <!-- chsch: copied from https://eclipse.googlesource.com/recommenders/org.eclipse.recommenders/+/3dae4575d3370da2da25a1cbce3dfcff198f0611/features/pom.xml -->
    <!-- Non-breakable space, as normal spaces are trimmed. -->
    <sourceFeatureLabelSuffix>&#xA0;(Sources)</sourceFeatureLabelSuffix>

    <!-- guarantee that we use utf8 for compilation, this is especially required
         due to xtend's template symbols («) when running maven on windows. -->
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <project.build.resourceEncoding>UTF-8</project.build.resourceEncoding>
    <maven.compiler.encoding>UTF-8</maven.compiler.encoding>
  </properties>

  <!-- Define one profile for each output target we have.
       Granted, for the moment this is just one. But that may change, and when it
       does, the one who wants to add new profiles will be thankful that we
       already thought of him from the beginning. Mark my words! -->
  <profiles>

    <!-- The ELK Update Site. -->
    <profile>
      <id>elk-update-site</id>

      <activation>
        <activeByDefault>true</activeByDefault>
      </activation>

      <modules>
        <module>../plugins</module>
        <module>../features</module>
        <module>org.eclipse.elk.repository</module>
      </modules>
    </profile>

    <!-- The Meta Data Language compiler. -->
    <profile>
      <id>elk-meta</id>

      <modules>
        <module>org.eclipse.elk.targetplatform</module>
        <module>../plugins/org.eclipse.elk.graph</module>
        <module>../plugins/org.eclipse.elk.core.meta</module>
      </modules>

      <!-- The meta data language compiler gets pushed to a Maven repository. -->
      <distributionManagement>
        <repository>
          <id>elk-meta-repository</id>
          <name>ELK Meta Data Language Compiler Repository</name>
          <url>${elkMeta.publishUrl}</url>
          <layout>default</layout>
          <uniqueVersion>false</uniqueVersion>
        </repository>

        <downloadUrl>${elkMeta.repositoryUrl}</downloadUrl>
      </distributionManagement>
    </profile>

    <!-- Activate to have the generated artifacts signed by Eclipse. -->
    <!-- Only works if the build is run on the Eclipse infrastructure. -->
    <profile>
        <id>sign</id>

        <build>
          <plugins>
            <plugin>
              <groupId>org.eclipse.cbi.maven.plugins</groupId>
              <artifactId>eclipse-jarsigner-plugin</artifactId>
              <version>1.1.3</version>
              <executions>
                <execution>
                  <id>sign</id>
                  <phase>verify</phase>
                  <goals>
                    <goal>sign</goal>
                  </goals>
                </execution>
              </executions>
            </plugin>
          </plugins>
        </build>
      </profile>

  </profiles>


  <!-- Maven plugin repositories -->
  <pluginRepositories>
    <pluginRepository>
      <id>jboss-releases</id>
      <name>JBoss Releases Maven Repository</name>
      <url>https://repository.jboss.org/nexus/content/repositories/releases/</url>
    </pluginRepository>

    <pluginRepository>
      <id>eclipse-cbi</id>
      <name>Eclipse Common Build Infrastructure Maven Repository</name>
      <url>https://repo.eclipse.org/content/repositories/cbi-releases/</url>
    </pluginRepository>

    <pluginRepository>
      <id>eclipse-elk-meta</id>
      <name>ELK Meta Data Language Compiler Maven Repository</name>
      <url>${elkMeta.repositoryUrl}</url>
    </pluginRepository>
  </pluginRepositories>


  <!-- Modify the build process to add Tycho and configure some utility plug-ins. -->
  <build>
    <plugins>
      <!-- We need tycho plugin to build eclipse plugins -->
      <plugin>
        <groupId>org.eclipse.tycho</groupId>
        <artifactId>tycho-maven-plugin</artifactId>
        <version>${tycho-version}</version>
        <extensions>true</extensions>
      </plugin>

      <!-- Setup our target platform definition file. -->
      <plugin>
        <groupId>org.eclipse.tycho</groupId>
        <artifactId>target-platform-configuration</artifactId>
        <version>${tycho-version}</version>
        <configuration>
          <target>
            <artifact>
              <groupId>org.eclipse.elk</groupId>
              <artifactId>org.eclipse.elk.targetplatform</artifactId>
              <version>0.1.0-SNAPSHOT</version>
            </artifact>
          </target>
        </configuration>
      </plugin>

      <!-- Build source plugin bundles. -->
      <plugin>
        <groupId>org.eclipse.tycho</groupId>
        <artifactId>tycho-source-plugin</artifactId>
        <version>${tycho-version}</version>
        <executions>
          <execution>
            <id>plugin-source</id>
            <goals>
              <goal>plugin-source</goal>
            </goals>
          </execution>
        </executions>
      </plugin>

      <!-- Enable java assertions during junit test runs. -->
      <!-- The "enableAssertions" property is only available in the maven-surefire plugin. -->
      <plugin>
        <groupId>org.eclipse.tycho</groupId>
        <artifactId>tycho-surefire-plugin</artifactId>
        <version>${tycho-version}</version>
        <configuration>
          <argLine>-ea</argLine>
        </configuration>
      </plugin>

    </plugins>

    <pluginManagement>
      <plugins>

        <plugin>
          <groupId>org.eclipse.xtext</groupId>
          <artifactId>xtext-maven-plugin</artifactId>
          <version>${xtext-version}</version>
          <executions>
            <execution>
              <goals>
                <goal>generate</goal>
              </goals>
            </execution>
          </executions>
          <configuration>
            <languages>
              <language>
                <setup>org.eclipse.elk.core.meta.MetaDataStandaloneSetup</setup>
                <outputConfigurations>
                  <outputConfiguration>
                    <outputDirectory>${basedir}/src-gen/</outputDirectory>
                  </outputConfiguration>
                </outputConfigurations>
              </language>
            </languages>
          </configuration>
          <dependencies>
            <dependency>
              <groupId>org.eclipse.elk</groupId>
              <artifactId>org.eclipse.elk.graph</artifactId>
              <version>0.1.0-SNAPSHOT</version>
            </dependency>
            <dependency>
              <groupId>org.eclipse.elk</groupId>
              <artifactId>org.eclipse.elk.core.meta</artifactId>
              <version>0.1.0-SNAPSHOT</version>
            </dependency>
          </dependencies>
        </plugin>

        <!-- maven xtend plugin to tell maven how to compile xtend code -->
        <plugin>
          <groupId>org.eclipse.xtend</groupId>
          <artifactId>xtend-maven-plugin</artifactId>
          <version>${xtext-version}</version>
          <configuration>
            <outputDirectory>${basedir}/xtend-gen</outputDirectory>
          </configuration>
          <executions>
            <execution>
              <goals>
                <goal>compile</goal>
              </goals>
            </execution>
          </executions>
        </plugin>

        <!-- add src-gen and xtend-gen to source-directories -->
        <plugin>
          <groupId>org.codehaus.mojo</groupId>
          <artifactId>build-helper-maven-plugin</artifactId>
          <version>1.3</version>
          <executions>
            <execution>
              <id>add-source</id>
              <phase>generate-sources</phase>
              <goals>
                <goal>add-source</goal>
              </goals>
              <configuration>
                <sources>
                  <source>src-gen</source>
                  <source>${project.build.directory}/xtend-gen</source>
                </sources>
              </configuration>
            </execution>
          </executions>
        </plugin>

        <!-- generated code needs cleanup too -->
        <plugin>
          <artifactId>maven-clean-plugin</artifactId>
          <version>3.0.0</version>
          <configuration>
            <filesets>
              <fileset>
                <directory>xtend-gen</directory>
                <includes>
                  <include>**</include>
                </includes>
              </fileset>
            </filesets>
          </configuration>
        </plugin>

        <!-- child projects may use this to be excempted from inclusion in the Maven repository -->
        <plugin>
           <groupId>org.apache.maven.plugins</groupId>
           <artifactId>maven-deploy-plugin</artifactId>
           <version>2.8.2</version>
       </plugin>

      </plugins>
    </pluginManagement>
  </build>
</project>
