<?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</groupId>
  <artifactId>pragmatics</artifactId>
  <version>0.50.0.v20230607</version>
  <packaging>pom</packaging>


  <!-- Define a few properties used throughout all build profiles. -->
  <properties>
    <elk-version>0.8.1</elk-version>
    <gson-version>2.9.0</gson-version>
    <guice-version>5.1.0</guice-version>
    <klighd-version>2.3.0.v20230606</klighd-version>
    <lsp4j-version>0.15.0</lsp4j-version>
    <tycho-version>2.7.3</tycho-version>
    <xtend-version>2.28.0</xtend-version>
    <xtext-version>2.28.0</xtext-version>

    <targetJdk>11</targetJdk>
    <maven.compiler.source>11</maven.compiler.source>
    <maven.compiler.target>11</maven.compiler.target>

    <!-- 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>

    <!-- 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>

    <!-- definitions of our repositories -->
    <kieler.pragmatics.nightly>
      http://rtsys.informatik.uni-kiel.de/~kieler/updatesite/nightly/pragmatics/
    </kieler.pragmatics.nightly>
  </properties>

  <!-- Further required information for publishing on OSSRH, see https://central.sonatype.org/publish/requirements/ -->
  <name>KIELER Pragmatics - Parent</name>
  <description>The parent configuration for pragmatics components of the KIELER project.</description>
  <url>https://github.com/kieler/pragmatics/</url>

  <licenses>
    <license>
      <name>EPL-1.0</name>
      <url>http://www.eclipse.org/legal/epl-v10.html</url>
    </license>
  </licenses>

  <developers>
    <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/pragmatics.git</connection>
    <developerConnection>scm:git:ssh://github.com:kieler/pragmatics.git</developerConnection>
    <url>https://github.com/kieler/pragmatics/</url>
  </scm>

  <!-- Define one profile for each output target we have.
       Formerly, we had the <repository> definitions repeated below in each profile
       globally defined, i.e. profile independent. This, however, prevents the
       Stuttgart/India guys from relying on our build infrastructure as it is
       (they don't want and cannot rely on our target platform repos) and would
       require customization, which may lead to merge conflicts due updates in our
       config and further hassles... -->
  <profiles>

    <!-- The Pragmatics update site. -->
    <profile>
      <id>pragmatics</id>

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

      <modules>
        <module>../plugins</module>
        <module>../features</module>
        <module>de.cau.cs.kieler.pragmatics.repository</module>
      </modules>
    </profile>

    <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>


  <!-- Maven plugin repositories -->
  <pluginRepositories>
    <pluginRepository>
      <id>central</id>
      <name>Maven Plugin Repository</name>
      <url>https://repo1.maven.org/maven2</url>
    </pluginRepository>

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

  <!-- while deploying, put the compiled artifact into the following (local) repository -->
  <!-- <distributionManagement>
    <repository>
     <id>internal-repo-for-downstream-usage</id>
     <url>file://pragmatics</url>
    </repository>
  </distributionManagement> -->
  <!-- Use this for deploying 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>
    <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>

      <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>


      <!-- as we have platform specific fragments we need to tell tycho about target platforms -->
      <plugin>
        <groupId>org.eclipse.tycho</groupId>
        <artifactId>target-platform-configuration</artifactId>
        <version>${tycho-version}</version>
        <configuration>

          <target>
            <artifact>
              <groupId>de.cau.cs.kieler</groupId>
              <artifactId>de.cau.cs.kieler.pragmatics.targetplatform</artifactId>
              <version>0.50.0.v20230607</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>
          </environments>
        </configuration>
      </plugin>

      <!-- Build Javadoc jars -->
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-javadoc-plugin</artifactId>
        <version>3.5.0</version>
        <configuration>
          <!-- Pin Java Source level to Java 8 for JavaDoc to avoid it getting confused with duplicate packages from P2 dependencies.-->
          <source>8</source>
          <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>
          </tags>
        </configuration>
        <executions>
          <execution>
            <id>attach-javadocs</id>
            <goals>
              <goal>jar</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
    </plugins>

    <pluginManagement>
      <plugins>

        <!-- 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>
          <executions>
            <execution>
              <goals>
                <goal>compile</goal>
              </goals>
            </execution>
          </executions>
          <configuration>
            <outputDirectory>${basedir}/xtend-gen</outputDirectory>
          </configuration>
        </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}</version>
            </dependency>
            <dependency>
              <groupId>org.eclipse.elk</groupId>
              <artifactId>org.eclipse.elk.core.meta</artifactId>
              <version>${elk-version}</version>
            </dependency>
          </dependencies>
        </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>
                </sources>
                <sources>
                  <source>${project.build.directory}/xtend-gen</source>
                </sources>
              </configuration>
            </execution>
          </executions>
        </plugin>

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