<?xml version="1.0" encoding="UTF-8"?>
<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>
  <parent>
    <groupId>io.github.lorenzobettini.edelta</groupId>
    <artifactId>edelta.bom</artifactId>
    <version>2.9.0</version>
    <relativePath>edelta.bom</relativePath>
  </parent>
  <artifactId>edelta.parent</artifactId>
  <packaging>pom</packaging>

  <name>Edelta</name>
  <url>https://github.com/LorenzoBettini/edelta</url>
  <description>An Xtext DSL for EMF metamodels refactoring and migration.</description>

  <properties>
    <eclipse-version>2021-12</eclipse-version>
    <assertj-version>3.22.0</assertj-version>
    <mockito-version>3.12.4</mockito-version>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <maven.compiler.source>11</maven.compiler.source>
    <maven.compiler.target>11</maven.compiler.target>

    <mwe2.skip>false</mwe2.skip>
    <xtend.skip>false</xtend.skip>

    <jacoco-aggregate-report>edelta.tests.report/target/site/jacoco-aggregate/jacoco.xml</jacoco-aggregate-report>

    <sonar.coverage.jacoco.xmlReportPaths>
      ../${jacoco-aggregate-report}
    </sonar.coverage.jacoco.xmlReportPaths>

    <sonar.exclusions>
      **/example/**,
      **/mwe2/**,
      **/Messages.java,
      **/*ProjectTemplateProvider.java,
      **/*ProjectTemplate.java,
      **/src-gen/**,
      **/emf-gen/**,
      **/edelta-gen/**,
      **/impl/*ImplCustom.java,
      **/*RuntimeModule.java,
      **/*UiModule.java,
      **/*StandaloneSetup*.java,
      **/ide/**,
      **/internal/**,
      **/serializer/**,
    </sonar.exclusions>

    <!-- Exclude Xtend generated files from code coverage:
      we cover the original Xtend files, using xtendAsPrimaryDebugSource
      inherited from the xtext-build-utils parent -->
    <sonar.coverage.exclusions>
      **/EdeltaMaven*.java,
      **/xtend-gen/**/*.java,
    </sonar.coverage.exclusions>

    <!-- To make SonarQube detect JUnit tests in generated Java code from Xtend -->
    <sonar.scm.exclusions.disabled>true</sonar.scm.exclusions.disabled>

    <!-- in the model inferrer we have a few lines of duplicated code that
      makes it more readable -->
    <sonar.cpd.exclusions>
      **/xtend-gen/**/*JvmModelInferrer.java,
    </sonar.cpd.exclusions>

    <!-- see http://sonarqube.15.x6.nabble.com/sonar-issue-ignore-multicriteria-td5021722.html 
      and http://stackoverflow.com/questions/21825469/configure-sonar-sonar-issue-ignore-multicriteria-through-maven 
      for the multicriteria property -->
    <sonar.issue.ignore.multicriteria>e6</sonar.issue.ignore.multicriteria>

    <!-- since we use a framework, it's normal to have a deep inheritance -->
    <sonar.issue.ignore.multicriteria.e6.ruleKey>java:S110</sonar.issue.ignore.multicriteria.e6.ruleKey>
    <sonar.issue.ignore.multicriteria.e6.resourceKey>**/*.java</sonar.issue.ignore.multicriteria.e6.resourceKey>

    <!-- These are generated by Xtend -->
    <!-- NOT NEEDED ANYMORE
    <sonar.issue.ignore.multicriteria.e12.ruleKey>squid:UselessImportCheck</sonar.issue.ignore.multicriteria.e12.ruleKey>
    <sonar.issue.ignore.multicriteria.e12.resourceKey>**/xtend-gen/**/*.java</sonar.issue.ignore.multicriteria.e12.resourceKey>
    -->

    <!-- Unnecessary imports should be removed
      generated by the Xbase compiler -->
    <!-- NOT NEEDED ANYMORE
    <sonar.issue.ignore.multicriteria.e14.ruleKey>java:S1128</sonar.issue.ignore.multicriteria.e14.ruleKey>
    <sonar.issue.ignore.multicriteria.e14.resourceKey>**/edelta-lib-src-gen/**/*.java</sonar.issue.ignore.multicriteria.e14.resourceKey>
    -->

    <!-- since this could be used in the pluginManagement section, we need 
      to make sure the path always points to this pom's directory; project.basedir 
      will always point to the directory of the pom where the pluginManagement's 
      plugins are used -->
    <ant-files-path>${project.basedir}/../releng/releasing</ant-files-path>

    <!-- You can use the create_local_target.ant in the target platform project
      to create a local.target pointing to a local mirror (which must
      be created in advance, see, e.g.,
      https://github.com/LorenzoBettini/tycho-mirror-example
      Then, pass -Dtarget-file-name=local.target
      to resolve the target platform using the local mirrro -->
    <target-file-name>edelta.target.target</target-file-name>

    <!-- pass "-n" to perform a trial run with no changes made -->
    <dryrun/>

    <!-- properties for deploying the composite update site
      on GitHub Pages -->
    <github-update-repo>git@github.com:LorenzoBettini/edelta-releases.git</github-update-repo>
    <github-local-clone>${project.build.directory}/checkout</github-local-clone>
    <releases-directory>${github-local-clone}/releases</releases-directory>
    <current-release-directory>${releases-directory}/${qualifiedVersion}</current-release-directory>
    <!-- The label for the Composite sites -->
    <site.label>Edelta Site</site.label>

    <!-- for deployment of Eclipse products on Sourceforge -->
    <remote.dir>lbettini@frs.sourceforge.net:/home/frs/project/edelta</remote.dir>
  </properties>

  <!-- The modules common to all profiles. These also correspond
    to the Maven artifacts to be deployed on Maven Central -->
  <modules>
    <module>edelta.bom</module>
    <module>edelta.target</module>
    <module>edelta.lib</module>
    <module>edelta</module>
    <module>edelta.refactorings.lib</module>
    <module>edelta.maven.plugin</module>
  </modules>

  <profiles>
    <profile>
      <!-- Standard development profile, including Eclipse specific
        bundles and tests -->
      <id>development</id>
      <activation>
        <activeByDefault>true</activeByDefault>
        <!-- Passing the property from an Eclipse m2e launch
          does not seem to work: the profile must be deactivated
          explicitly with !development -->
        <property>
          <name>!activate-maven-profile</name>
        </property>
      </activation>
      <modules>
        <module>edelta.dependency.analyzer.model</module>
        <module>edelta.dependency.analyzer.model.edit</module>
        <module>edelta.dependency.analyzer</module>
        <module>edelta.dependency.analyzer.tests</module>
        <module>edelta.dependency.analyzer.picto</module>
        <module>edelta.dependency.analyzer.ui</module>
        <module>edelta.dependency.analyzer.feature</module>
        <module>edelta.testutils</module>
        <module>edelta.testing.libraries</module>
        <module>edelta.lib.tests</module>
        <module>edelta.ide</module>
        <module>edelta.ui</module>
        <module>edelta.refactorings.lib.tests</module>
        <module>edelta.feature</module>
        <module>edelta.repository</module>
        <module>edelta.product.ui.feature</module>
        <module>edelta.tests</module>
        <module>edelta.ui.tests</module>
        <module>edelta.examples</module>
        <module>edelta.maven.example</module>
        <module>edelta.tests.parent</module>
        <module>edelta.tests.report</module>
      </modules>
    </profile>
    <profile>
      <id>release-composite</id> <!-- release composite update site on GitHub Pages -->
      <activation>
        <activeByDefault>false</activeByDefault>
      </activation>
      <properties>
        <skipTests>true</skipTests>
      </properties>
    </profile>
    <profile>
      <id>release-ide</id> <!-- release IDE products on Sourceforge -->
      <activation>
        <activeByDefault>false</activeByDefault>
      </activation>
      <properties>
        <skipTests>true</skipTests>
      </properties>
      <build>
        <pluginManagement>
          <plugins>
            <plugin>
              <artifactId>maven-install-plugin</artifactId>
              <executions>
                <execution>
                  <id>default-install</id>
                  <phase>none</phase>
                </execution>
              </executions>
            </plugin>
            <plugin>
              <artifactId>maven-deploy-plugin</artifactId>
              <configuration>
                <skip>true</skip>
              </configuration>
            </plugin>
          </plugins>
        </pluginManagement>
      </build>
    </profile>
    <profile>
      <!-- This assumes that release-composite is enabled as well -->
      <id>release-snapshots</id>
      <activation>
        <activeByDefault>false</activeByDefault>
      </activation>
      <properties>
        <github-update-repo>git@github.com:LorenzoBettini/edelta-snapshots.git</github-update-repo>
        <site.label>Edelta Snapshot Site</site.label>
        <remote.dir>lbettini@frs.sourceforge.net:/home/frs/project/edelta/snapshots</remote.dir>
      </properties>
    </profile>
    <profile>
      <!-- Builds products and test with SWTBot -->
      <id>test-ide</id>
      <activation>
        <activeByDefault>false</activeByDefault>
      </activation>
      <modules>
        <module>edelta.swtbot.tests</module>
      </modules>
    </profile>
    <profile>
      <id>sonatype-oss-release</id>
      <activation>
        <activeByDefault>false</activeByDefault>
      </activation>
      <build>
        <plugins>
          <plugin>
            <groupId>org.sonatype.plugins</groupId>
            <artifactId>nexus-staging-maven-plugin</artifactId>
          </plugin>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-javadoc-plugin</artifactId>
          </plugin>
          <plugin>
            <groupId>org.eclipse.tycho</groupId>
            <artifactId>tycho-p2-plugin</artifactId>
            <executions>
              <execution>
                <id>attach-p2-metadata</id>
              </execution>
            </executions>
            <configuration>
              <defaultP2Metadata>false</defaultP2Metadata>
              <attachP2Metadata>false</attachP2Metadata>
            </configuration>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>

  <build>
    <plugins>
      <plugin>
        <groupId>org.eclipse.tycho</groupId>
        <artifactId>target-platform-configuration</artifactId>
        <configuration>
          <target>
            <file>
              ${project.basedir}/../edelta.target/${target-file-name}
            </file>
          </target>
          <environments combine.children="append">
            <environment>
              <os>macosx</os>
              <ws>cocoa</ws>
              <arch>aarch64</arch>
            </environment>
            <environment>
              <os>linux</os>
              <ws>gtk</ws>
              <arch>aarch64</arch>
            </environment>
          </environments>
        </configuration>
      </plugin>
    </plugins>
    <pluginManagement>
      <plugins>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-javadoc-plugin</artifactId>
          <configuration>
            <detectOfflineLinks>false</detectOfflineLinks>
            <!-- https://issues.apache.org/jira/browse/MJAVADOC-620
             [ERROR] RuntimeException: Error while generating Javadoc:
             Unable to derive module descriptor for
             .m2/repository/p2/osgi/bundle/org.eclipse.equinox.launcher.cocoa.macosx.x86_64/1.2.400.v20211117-0650/org.eclipse.equinox.launcher.cocoa.macosx.x86_64-1.2.400.v20211117-0650.jar
             Caused by: java.lang.IllegalArgumentException: org.eclipse.equinox.launcher.cocoa.macosx.x86.64: Invalid module name: '64' is not a Java identifier
             -->
            <source>8</source>
          </configuration>
        </plugin>
        <plugin>
          <groupId>org.eclipse.xtend</groupId>
          <artifactId>xtend-maven-plugin</artifactId>
          <configuration>
            <!-- That is not required with maven.compiler.source/target set to 11
              but it's required if we switch to a newer version of Java
              that is not yet handled by Xtend -->
            <javaSourceVersion>11</javaSourceVersion>
          </configuration>
        </plugin>
        <plugin>
          <!-- We don't use it, since we have edelta-maven-plugin, we leave it here
            just for historical reasons ;) -->
          <groupId>org.eclipse.xtext</groupId>
          <artifactId>xtext-maven-plugin</artifactId>
          <version>${xtextVersion}</version>
          <executions>
            <execution>
              <goals>
                <goal>generate</goal>
              </goals>
            </execution>
          </executions>
          <configuration>
            <failOnValidationError>true</failOnValidationError>
            <languages>
              <language>
                <setup>org.eclipse.xtext.ecore.EcoreSupport</setup>
              </language>
              <language>
                <setup>edelta.EdeltaStandaloneSetup</setup>
                <outputConfigurations>
                  <outputConfiguration>
                    <outputDirectory>${basedir}/edelta-gen</outputDirectory>
                    <installDslAsPrimarySource>true</installDslAsPrimarySource>
                  </outputConfiguration>
                </outputConfigurations>
              </language>
            </languages>
          </configuration>
          <dependencies>
            <dependency>
              <groupId>io.github.lorenzobettini.edelta</groupId>
              <artifactId>edelta</artifactId>
              <version>${project.version}</version>
            </dependency>
          </dependencies>
        </plugin>
        <plugin>
          <groupId>io.github.lorenzobettini.edelta</groupId>
          <artifactId>edelta-maven-plugin</artifactId>
          <version>${project.version}</version>
          <executions>
            <execution>
              <goals>
                <goal>generate</goal>
              </goals>
            </execution>
          </executions>
          <configuration>
            <!-- That is not required with maven.compiler.source/target set to 11
              but it's required if we switch to a newer version of Java
              that is not yet handled by Xbase -->
            <compilerSourceLevel>11</compilerSourceLevel>
            <compilerTargetLevel>11</compilerTargetLevel>
          </configuration>
        </plugin>
        <!--This plugin's configuration is used to store Eclipse m2e settings only. 
          It has no influence on the Maven build itself. -->
        <plugin>
          <groupId>org.eclipse.m2e</groupId>
          <artifactId>lifecycle-mapping</artifactId>
          <version>1.0.0</version>
          <configuration>
            <lifecycleMappingMetadata>
              <pluginExecutions>
                <pluginExecution>
                  <pluginExecutionFilter>
                    <groupId>io.github.lorenzobettini.edelta</groupId>
                    <artifactId>edelta-maven-plugin</artifactId>
                    <versionRange>[0.8.0-SNAPSHOT,)</versionRange>
                    <goals>
                      <goal>generate</goal>
                    </goals>
                  </pluginExecutionFilter>
                  <action>
                    <ignore></ignore>
                  </action>
                </pluginExecution>
              </pluginExecutions>
            </lifecycleMappingMetadata>
          </configuration>
        </plugin>
       </plugins>
    </pluginManagement>
  </build>

</project>