<?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>de.cau.cs.kieler.klighd</groupId>
  <artifactId>parent</artifactId>
  <version>2.3.0.v20230606</version>
  <packaging>pom</packaging>

  <modules>
    <module>build/de.cau.cs.kieler.klighd.targetplatform</module>

    <!-- the following 3 entries exist just for the tycho-versions:setVersion task to work properly -->
    <module>plugins</module>
    <module>test</module>
    <module>features</module>

    <module>plugins/de.cau.cs.kieler.klighd</module>
    <module>plugins/de.cau.cs.kieler.klighd.ide</module>
    <module>plugins/de.cau.cs.kieler.klighd.incremental</module>
    <module>plugins/de.cau.cs.kieler.klighd.kgraph</module>
    <module>plugins/de.cau.cs.kieler.klighd.krendering</module>
    <module>plugins/de.cau.cs.kieler.klighd.krendering.extensions</module>
    <module>plugins/de.cau.cs.kieler.klighd.lsp</module>
    <module>plugins/de.cau.cs.kieler.klighd.piccolo</module>
    <module>plugins/de.cau.cs.kieler.klighd.standalone</module>
    <module>test/de.cau.cs.kieler.klighd.test</module>
    <module>test/de.cau.cs.kieler.klighd.piccolo.test</module>
    <!-- <module>plugins/de.cau.cs.kieler.klighd.piccolo.batik</module> -->
    <module>plugins/de.cau.cs.kieler.klighd.piccolo.draw2d</module>
    <module>plugins/de.cau.cs.kieler.klighd.piccolo.freehep</module>
    <module>plugins/de.cau.cs.kieler.klighd.ui</module>
    <module>plugins/de.cau.cs.kieler.klighd.ui.contrib3x</module>
    <module>plugins/de.cau.cs.kieler.klighd.ui.emf</module>
    <module>plugins/de.cau.cs.kieler.klighd.ui.view</module>
    <module>plugins/de.cau.cs.kieler.klighd.ui.wizard</module>
    <module>plugins/de.cau.cs.kieler.kgraph.text</module>
    <module>plugins/de.cau.cs.kieler.kgraph.text.ide</module>
    <module>plugins/de.cau.cs.kieler.kgraph.text.ui</module>

    <module>features/de.cau.cs.kieler.klighd.feature</module>
    <!-- <module>features/de.cau.cs.kieler.klighd.batik.feature</module> -->
    <module>features/de.cau.cs.kieler.klighd.draw2d.feature</module>
    <module>features/de.cau.cs.kieler.klighd.freehep.feature</module>
    <module>features/de.cau.cs.kieler.klighd.ide.feature</module>
    <module>features/de.cau.cs.kieler.klighd.view.feature</module>
    <module>features/de.cau.cs.kieler.klighd.sdk.feature</module>

    <module>build/de.cau.cs.kieler.klighd.repository</module>
  </modules>

  <!-- Define a few properties used throughout all build profiles. -->
  <properties>
    <core-resources-version>3.18.0</core-resources-version>
    <core-runtime-version>3.26.0</core-runtime-version>
    <elk-version>0.8.1</elk-version>
    <emf-common-version>2.26.0</emf-common-version>
    <emf-ecore-version>2.28.0</emf-ecore-version>
    <emf-edit-version>2.17.0</emf-edit-version>
    <gson-version>2.9.0</gson-version>
    <guava-version>31.1-jre</guava-version>
    <guice-version>5.1.0</guice-version>
    <jface-version>3.27.0</jface-version>
    <lsp4j-version>0.15.0</lsp4j-version>
    <sprotty-version>0.9.0</sprotty-version>
    <swt-mock-version>0.1.0</swt-mock-version>
    <swt-version>3.121.0</swt-version>
    <tycho-version>2.7.3</tycho-version>
    <ui-workbench-version>3.126.0</ui-workbench-version>
    <xtend-version>2.28.0</xtend-version>
    <xtext-version>2.28.0</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>

	<!-- pin the source code compatibility to 1.8 for the sake of backward compatibility -->
    <maven.compiler.source>1.8</maven.compiler.source>

    <!-- don't pin the class file compatibility here, as this will overwrite the 'Bundle-RequiredExecutionEnvironment:' settings in the plug-ins' manifest files!
         chsch: at the time of writing this all BREEs are pinned to 1.8 except for 'klighd.piccolo.test' that I switched to JavaSE-11 for convenience -->
    <!-- maven.compiler.target>1.8</maven.compiler.target -->

    <!-- Enable java assertions during junit test runs. -->
    <!-- The "enableAssertions" property is only available in the maven-surefire plugin. -->
    <tycho.surefire.vmargs>-ea</tycho.surefire.vmargs>
    <!-- chsch: this property is overridden for osx in a profile below. -->
    <tycho.surefire.extra.vmargs></tycho.surefire.extra.vmargs>
  </properties>

  <!-- Further required information for publishing on OSSRH -->
  <name>KLighD</name>
  <description>KIELER Lightweight Diagams</description>
  <url>https://github.com/kieler/KLighD</url>

  <licenses>
    <license>
      <name>EPL-2.0</name>
      <url>https://www.eclipse.org/legal/epl-2.0/</url>
    </license>
  </licenses>

  <developers>
    <developer>
      <name>Christian Schneider</name>
      <email>christian.schneider@typefox.io</email>
      <organization>TypeFox</organization>
      <organizationUrl>https://www.typefox.io/</organizationUrl>
    </developer>
    <developer>
      <name>Niklas Rentz</name>
      <email>nre@informatik.uni-kiel.de</email>
      <organization>Kiel University</organization>
      <organizationUrl>https://www.rtsys.informatik.uni-kiel.de/</organizationUrl>
    </developer>
  </developers>

  <scm>
    <connection>scm:git:git://github.com:kieler/KLighD.git</connection>
    <developerConnection>scm:git:ssh://github.com:kieler/KLighD.git</developerConnection>
    <url>https://github.com/kieler/KLighD</url>
  </scm>

  <profiles>
    <profile>
      <id>os-macosx</id>
      <activation>
        <os>
          <family>mac</family>
        </os>
      </activation>
      <properties>
        <tycho.surefire.extra.vmargs>-XstartOnFirstThread</tycho.surefire.extra.vmargs>
      </properties>
    </profile>

    <profile>
      <id>release</id>
      <build>
        <plugins>
          <!-- Configure the nexus server to deploy to. -->
          <plugin>
            <groupId>org.sonatype.plugins</groupId>
            <artifactId>nexus-staging-maven-plugin</artifactId>
            <version>1.6.13</version>
            <extensions>true</extensions>
            <configuration>
              <serverId>ossrh</serverId>
              <nexusUrl>https://s01.oss.sonatype.org/</nexusUrl>
              <autoReleaseAfterClose>false</autoReleaseAfterClose> <!-- this allows to manually inspect the staging repository: https://central.sonatype.org/publish/release/
              trigger a release later with `mvn nexus-staging:release` or set to true if no inspection is wanted.-->
            </configuration>
          </plugin>

          <!-- Sign all artifacts with GPG. -->
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-gpg-plugin</artifactId>
            <version>3.1.0</version>
            <executions>
              <execution>
                <id>sign-artifacts</id>
                <phase>verify</phase>
                <goals>
                  <goal>sign</goal>
                </goals>
                <!-- This is the ID of the KIELER GPG key. -->
                <configuration>
                  <keyname>0x22228C2E</keyname>
                </configuration>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>

  <dependencyManagement>
    <dependencies>
  <!-- This dependency management are only here to resolve the broken Maven dependencies of Eclipse artifacts. Should be removed
  once this ticket is resolved: https://bugs.eclipse.org/bugs/show_bug.cgi?id=567244 -->
      <dependency>
        <groupId>org.eclipse.platform</groupId>
        <artifactId>org.eclipse.ui.workbench</artifactId>
        <version>3.110.0</version>
        <exclusions>
          <exclusion>
            <groupId>org.eclipse.platform</groupId>
            <artifactId>org.eclipse.swt</artifactId>
          </exclusion>
          <exclusion>
            <groupId>org.eclipse.platform</groupId>
            <artifactId>org.eclipse.urischeme</artifactId>
          </exclusion>
          <!-- This exclusion is temporarily added to fix another missing Maven artifact of Eclipse's dependencies, see https://github.com/kieler/KLighD/issues/82 and https://bugs.eclipse.org/bugs/show_bug.cgi?id=569770 -->
          <exclusion>
            <groupId>javax.annotation</groupId>
            <artifactId>javax.annotation-api</artifactId>
          </exclusion>
        </exclusions>
        <!-- transitively pulls 'org.eclipse.jface', too,
               defining e.g. 'org.eclipse.jface.preference.IPreferenceStore' -->
      </dependency>
      <!-- Manages versions of transitively pulled dependencies of ELK which cause problems with the local dependencies. -->
      <dependency>
        <groupId>org.eclipse.emf</groupId>
        <artifactId>org.eclipse.emf.ecore</artifactId>
        <version>${emf-ecore-version}</version>
      </dependency>
      <dependency>
        <groupId>org.eclipse.platform</groupId>
        <artifactId>org.eclipse.e4.ui.workbench.renderers.swt</artifactId>
        <version>0.15.600</version>
      </dependency>
      <dependency>
        <groupId>org.eclipse.emf</groupId>
        <artifactId>org.eclipse.emf.ecore.change</artifactId>
        <version>2.14.0</version>
      </dependency>
    </dependencies>
  </dependencyManagement>

  <!-- <distributionManagement>
    <snapshotRepository>
      <id>localSnapshot</id>
      <url>file://klighd-snapshots</url>
    </snapshotRepository>
    <repository>
      <id>localSnapshot</id>
      <url>file://klighd</url>
    </repository>
  </distributionManagement> -->
  <!-- replace above with this for locally deploying the artifacts to OSSRH -->
  <distributionManagement>
    <snapshotRepository>
      <id>ossrh</id>
      <url>https://s01.oss.sonatype.org/content/repositories/snapshots</url>
    </snapshotRepository>
    <repository>
      <id>ossrh</id>
      <url>https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/</url>
    </repository>
  </distributionManagement>

  <!-- Modify the build process to add Tycho and configure some utility plug-ins. -->
  <build>
    <sourceDirectory>src</sourceDirectory>
    <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>

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

      <!-- tell tycho about our target platforms -->
      <plugin>
        <groupId>org.eclipse.tycho</groupId>
        <artifactId>target-platform-configuration</artifactId>
        <version>${tycho-version}</version>
        <configuration>
          <pomDependencies>consider</pomDependencies>
          <target>
            <artifact>
              <groupId>de.cau.cs.kieler.klighd</groupId>
              <artifactId>de.cau.cs.kieler.klighd.targetplatform</artifactId>
              <version>2.3.0.v20230606</version>
            </artifact>
          </target>

          <environments>
            <environment>
              <os>linux</os>
              <ws>gtk</ws>
              <arch>x86_64</arch>
            </environment>
            <environment>
              <os>win32</os>
              <ws>win32</ws>
              <arch>x86_64</arch>
            </environment>
            <environment>
              <os>macosx</os>
              <ws>cocoa</ws>
              <arch>x86_64</arch>
            </environment>
            <environment>
              <os>macosx</os>
              <ws>cocoa</ws>
              <arch>aarch64</arch>
            </environment>
          </environments>
        </configuration>
      </plugin>

      <!-- skip generating poms for P2 dependencies managed by tycho. Avoids this issue: https://www.eclipse.org/forums/index.php?t=msg&th=1111563&goto=1854788&  --> 
      <plugin>
        <groupId>org.eclipse.tycho</groupId>
        <artifactId>tycho-packaging-plugin</artifactId>
        <version>${tycho-version}</version>
        <configuration>
          <skipPomGeneration>true</skipPomGeneration>
        </configuration>
      </plugin>

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

      <!-- do prepare source bundle jars for each (eclipse) plug-in -->
      <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>

      <plugin>
        <groupId>org.eclipse.tycho</groupId>
        <artifactId>tycho-surefire-plugin</artifactId>
        <version>${tycho-version}</version>
        <configuration>
          <argLine>${tycho.surefire.extra.vmargs} ${tycho.surefire.vmargs}</argLine>
          <appArgLine>-consoleLog</appArgLine>
        </configuration>
      </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>xtend-gen</source>
              </sources>
            </configuration>
          </execution>
        </executions>
      </plugin>

      <!-- Build Javadoc jars -->
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-javadoc-plugin</artifactId>
        <version>3.5.0</version>
        <configuration>
          <tags>
          <!-- Let JavaDoc know about tags from Xtext -->
            <tag>
              <name>generated</name>
              <placement>a</placement>
              <head>EMF generated code</head>
            </tag>
            <tag>
              <name>model</name>
              <placement>a</placement>
              <head>EMF model element</head>
            </tag>
            <tag>
              <name>ordered</name>
              <placement>a</placement>
              <head>EMF ordered element</head>
            </tag>
            <!-- And some official tags that the maven-javdoc-plugin does somehow not recognize yet: -->
            <tag>
              <name>implSpec</name>
              <placement>a</placement>
              <head>Implementation Specification:</head>
            </tag>
            <!-- Tags used for Xtend's extension methods. -->
            <tag>
              <name>containsExtensions</name>
              <placement>a</placement>
              <head>This class contains Xtend extension methods.</head>
            </tag>
            <tag>
              <name>extensionCategory</name>
              <placement>a</placement>
              <head>Extension Category:</head>
            </tag>
            <tag>
              <name>example</name>
              <placement>a</placement>
              <head>Code Example:</head>
            </tag>
          </tags>
        </configuration>
        <executions>
          <execution>
            <id>attach-javadocs</id>
            <goals>
              <goal>jar</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
    </plugins>

    <!-- the following definitions just register setups of plug-ins, their execution is enable elsewhere -->
    <pluginManagement>
     <plugins>
       <plugin>
        <!-- configuration of the source feature generation, is activated in features/pom -->
        <groupId>org.eclipse.tycho.extras</groupId>
        <artifactId>tycho-source-feature-plugin</artifactId>
        <version>${tycho-version}</version>
        <executions>
          <execution>
            <id>source-feature</id>
            <phase>package</phase>
            <goals>
              <goal>source-feature</goal>
            </goals>
            <configuration>
              <labelSuffix>${sourceFeatureLabelSuffix}</labelSuffix>
              <excludes>
                <!-- the following bundles are excluded in the source feature generation process
                      as they don't contribute any classes and, thus,
                      no related source bundles exist -->
                <plugin id="de.cau.cs.kieler.klighd.ui.contrib3x" />
                <plugin id="org.eclipse.emf" />
                <plugin id="org.eclipse.swt" />

                <!-- the following bundles are excluded as
                      there are no sources offered via the eclipse update sites -->
                <plugin id="edu.umd.cs.piccolo" />
              </excludes>
            </configuration>
          </execution>
        </executions>
      </plugin>

      <plugin>
        <groupId>org.eclipse.tycho</groupId>
        <artifactId>tycho-p2-plugin</artifactId>
        <version>${tycho-version}</version>
        <executions>
          <execution>
            <id>attached-p2-metadata</id>
            <phase>package</phase>
            <goals>
              <goal>p2-metadata</goal>
            </goals>
          </execution>
        </executions>
      </plugin>

        <!-- generate code from melk files -->
        <!-- 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>${elk-version}-SNAPSHOT</version>
            </dependency>
            <dependency>
              <groupId>org.eclipse.elk</groupId>
              <artifactId>org.eclipse.elk.core.meta</artifactId>
              <version>${elk-version}-SNAPSHOT</version>
            </dependency>
          </dependencies>
        </plugin -->
      </plugins>
    </pluginManagement>
  </build>
</project>
