<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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>

  <groupId>io.xlate</groupId>
  <artifactId>yaml-json</artifactId>
  <version>0.2.0</version>

  <name>yaml-json : JSON API for YAML</name>
  <description>Read and write YAML in Java using the Jakarta JSON API</description>
  <url>https://github.com/xlate/yaml-json</url>

  <issueManagement>
    <url>https://github.com/xlate/yaml-json/issues</url>
    <system>GitHub Issues</system>
  </issueManagement>

  <scm>
    <url>https://github.com/xlate/yaml-json</url>
    <connection>scm:git:https://github.com/xlate/yaml-json.git</connection>
    <developerConnection>scm:git:ssh://git@github.com/xlate/yaml-json.git</developerConnection>
    <tag>v0.2.0</tag>
  </scm>

  <licenses>
    <license>
      <name>Apache License, Version 2.0</name>
      <url>https://www.apache.org/licenses/LICENSE-2.0.txt</url>
      <distribution>repo</distribution>
      <comments>A business-friendly OSS license</comments>
    </license>
  </licenses>

  <developers>
    <developer>
      <name>Michael Edgar</name>
      <organizationUrl>https://www.xlate.io/</organizationUrl>
    </developer>
  </developers>

  <distributionManagement>
    <snapshotRepository>
      <id>ossrh</id>
      <url>https://oss.sonatype.org/content/repositories/snapshots</url>
    </snapshotRepository>
  </distributionManagement>

  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
    <maven.compiler.release>11</maven.compiler.release>
    <legacy.sourceDirectory>${project.build.directory}/generated-sources/legacy</legacy.sourceDirectory>
    <legacy.outputDirectory>${project.build.directory}/classes-legacy</legacy.outputDirectory>

    <!-- Sonar settings -->
    <sonar.projectKey>xlate_yaml-json</sonar.projectKey>
    <sonar.host.url>https://sonarcloud.io</sonar.host.url>
    <sonar.organization>xlate</sonar.organization>
    <sonar.issue.ignore.multicriteria>e1</sonar.issue.ignore.multicriteria>
    <sonar.issue.ignore.multicriteria.e1.ruleKey>java:S6212</sonar.issue.ignore.multicriteria.e1.ruleKey>
    <sonar.issue.ignore.multicriteria.e1.resourceKey>**/*.java</sonar.issue.ignore.multicriteria.e1.resourceKey>

    <version.jakarta.json-api>2.1.3</version.jakarta.json-api>
    <version.javax.json-api>1.1.4</version.javax.json-api>
    <version.snakeyaml>2.2</version.snakeyaml>
    <version.snakeyaml-engine>2.7</version.snakeyaml-engine>

    <version.junit-jupiter>5.10.2</version.junit-jupiter>
    <version.parsson>1.1.5</version.parsson>
  </properties>

  <build>
    <pluginManagement>
      <plugins>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-antrun-plugin</artifactId>
          <version>3.1.0</version>
        </plugin>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-dependency-plugin</artifactId>
          <version>3.6.1</version>
        </plugin>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-compiler-plugin</artifactId>
          <version>3.12.1</version>
        </plugin>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-surefire-plugin</artifactId>
          <version>3.2.5</version>
          <configuration>
            <systemPropertyVariables>
              <java.util.logging.config.file>${project.build.testOutputDirectory}/logging.properties</java.util.logging.config.file>
            </systemPropertyVariables>
            <redirectTestOutputToFile>true</redirectTestOutputToFile>
            <argLine>--add-opens io.xlate.yamljson/io.xlate.yamljson=ALL-UNNAMED --add-modules=org.snakeyaml.engine.v2,org.yaml.snakeyaml ${argLine}</argLine>
          </configuration>
        </plugin>
        <plugin>
          <groupId>org.jacoco</groupId>
          <artifactId>jacoco-maven-plugin</artifactId>
          <version>0.8.11</version>
        </plugin>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-source-plugin</artifactId>
          <version>3.3.0</version>
        </plugin>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-javadoc-plugin</artifactId>
          <version>3.6.3</version>
          <configuration>
            <additionalOptions>-html5</additionalOptions>
            <excludePackageNames>io.xlate.yamljson.internal.*</excludePackageNames>
            <links>
              <link>https://docs.oracle.com/en/java/javase/11/docs/api</link>
              <link>https://jakarta.ee/specifications/platform/9/apidocs</link>
              <link>https://javadoc.io/doc/org.snakeyaml/snakeyaml-engine/${version.snakeyaml-engine}/</link>
              <link>https://javadoc.io/doc/org.yaml/snakeyaml/${version.snakeyaml}/</link>
            </links>
          </configuration>
        </plugin>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-jar-plugin</artifactId>
          <version>3.3.0</version>
        </plugin>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-release-plugin</artifactId>
          <version>3.0.1</version>
        </plugin>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-gpg-plugin</artifactId>
          <version>3.1.0</version>
        </plugin>
        <plugin>
          <groupId>org.sonatype.plugins</groupId>
          <artifactId>nexus-staging-maven-plugin</artifactId>
          <version>1.6.13</version>
        </plugin>
      </plugins>
    </pluginManagement>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <executions>
          <execution>
            <id>yaml-1.1</id>
            <goals>
              <goal>test</goal>
            </goals>
            <configuration>
              <systemPropertyVariables>
                <io.xlate.yamljson.YAML_VERSION>v1.1</io.xlate.yamljson.YAML_VERSION>
              </systemPropertyVariables>
              <classpathDependencyExcludes>
                <classpathDependencyExclude>org.snakeyaml:snakeyaml-engine</classpathDependencyExclude>
              </classpathDependencyExcludes>
              <argLine>--add-opens io.xlate.yamljson/io.xlate.yamljson=ALL-UNNAMED --add-modules=org.yaml.snakeyaml ${argLine}</argLine>
            </configuration>
          </execution>
          <execution>
            <id>yaml-1.2</id>
            <goals>
              <goal>test</goal>
            </goals>
            <configuration>
              <systemPropertyVariables>
                <io.xlate.yamljson.YAML_VERSION>v1.2</io.xlate.yamljson.YAML_VERSION>
              </systemPropertyVariables>
              <classpathDependencyExcludes>
                <classpathDependencyExclude>org.yaml:snakeyaml</classpathDependencyExclude>
              </classpathDependencyExcludes>
              <argLine>--add-opens io.xlate.yamljson/io.xlate.yamljson=ALL-UNNAMED --add-modules=org.snakeyaml.engine.v2 ${argLine}</argLine>
            </configuration>
          </execution>
          <execution>
            <id>yaml-missing</id>
            <goals>
              <goal>test</goal>
            </goals>
            <configuration>
              <systemPropertyVariables>
                <io.xlate.yamljson.YAML_VERSION>NONE</io.xlate.yamljson.YAML_VERSION>
              </systemPropertyVariables>
              <classpathDependencyExcludes>
                <classpathDependencyExclude>org.yaml:snakeyaml</classpathDependencyExclude>
                <classpathDependencyExclude>org.snakeyaml:snakeyaml-engine</classpathDependencyExclude>
              </classpathDependencyExcludes>
              <argLine>--add-opens io.xlate.yamljson/io.xlate.yamljson=ALL-UNNAMED ${argLine}</argLine>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.jacoco</groupId>
        <artifactId>jacoco-maven-plugin</artifactId>
        <executions>
          <execution>
            <goals>
              <goal>prepare-agent</goal>
            </goals>
          </execution>
          <execution>
            <id>report</id>
            <phase>test</phase>
            <goals>
              <goal>report</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-release-plugin</artifactId>
        <configuration>
          <autoVersionSubmodules>true</autoVersionSubmodules>
          <useReleaseProfile>false</useReleaseProfile>
          <releaseProfiles>release,legacy</releaseProfiles>
          <goals>deploy</goals>
          <tagNameFormat>v@{project.version}</tagNameFormat>
          <pushChanges>false</pushChanges>
          <localCheckout>true</localCheckout>
        </configuration>
      </plugin>
    </plugins>
  </build>

  <dependencyManagement>
    <dependencies>
      <dependency>
        <groupId>jakarta.json</groupId>
        <artifactId>jakarta.json-api</artifactId>
        <version>${version.jakarta.json-api}</version>
      </dependency>
      <dependency>
        <groupId>javax.json</groupId>
        <artifactId>javax.json-api</artifactId>
        <version>${version.javax.json-api}</version>
      </dependency>
      <dependency>
        <groupId>org.yaml</groupId>
        <artifactId>snakeyaml</artifactId>
        <version>${version.snakeyaml}</version>
      </dependency>
      <dependency>
        <groupId>org.snakeyaml</groupId>
        <artifactId>snakeyaml-engine</artifactId>
        <version>${version.snakeyaml-engine}</version>
      </dependency>

      <!-- Testing -->
      <dependency>
        <groupId>org.junit.jupiter</groupId>
        <artifactId>junit-jupiter</artifactId>
        <version>${version.junit-jupiter}</version>
      </dependency>
      <dependency>
        <groupId>org.mockito</groupId>
        <artifactId>mockito-core</artifactId>
        <version>5.10.0</version>
      </dependency>
      <dependency>
        <groupId>org.eclipse.parsson</groupId>
        <artifactId>parsson</artifactId>
        <version>${version.parsson}</version>
      </dependency>
    </dependencies>
  </dependencyManagement>

  <dependencies>
    <dependency>
      <groupId>jakarta.json</groupId>
      <artifactId>jakarta.json-api</artifactId>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>org.yaml</groupId>
      <artifactId>snakeyaml</artifactId>
      <optional>true</optional>
    </dependency>
    <dependency>
      <groupId>org.snakeyaml</groupId>
      <artifactId>snakeyaml-engine</artifactId>
      <optional>true</optional>
    </dependency>

    <!-- Testing -->
    <dependency>
      <groupId>org.junit.jupiter</groupId>
      <artifactId>junit-jupiter</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.mockito</groupId>
      <artifactId>mockito-core</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.eclipse.parsson</groupId>
      <artifactId>parsson</artifactId>
      <scope>test</scope>
    </dependency>
  </dependencies>

  <profiles>
    <profile>
      <id>legacy</id>
      <dependencies>
        <dependency>
          <groupId>javax.json</groupId>
          <artifactId>javax.json-api</artifactId>
          <scope>provided</scope>
        </dependency>
      </dependencies>
      <build>
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-antrun-plugin</artifactId>
            <executions>
              <execution>
                <id>generate-legacy-sources</id>
                <phase>generate-sources</phase>
                <goals>
                  <goal>run</goal>
                </goals>
                <configuration>
                  <target>
                    <mkdir dir="${legacy.sourceDirectory}" />

                    <copy todir="${legacy.sourceDirectory}">
                      <fileset dir="src/main/java" />
                    </copy>

                    <replace token="jakarta.json." value="javax.json." dir="${legacy.sourceDirectory}">
                      <include name="**/*.java" />
                    </replace>

                    <replace token="jakarta.json" value="java.json" dir="${legacy.sourceDirectory}">
                      <include name="**/module-info.java" />
                    </replace>

                    <mkdir dir="${legacy.outputDirectory}" />
                  </target>
                </configuration>
              </execution>
              <execution>
                <id>legacy-compile</id>
                <phase>compile</phase>
                <goals>
                  <goal>run</goal>
                </goals>
                <configuration>
                  <target>
                    <mkdir dir="${legacy.outputDirectory}" />
                    <javac srcdir="${legacy.sourceDirectory}" destdir="${legacy.outputDirectory}" modulepath="${javax.json:javax.json-api:jar}:${org.yaml:snakeyaml:jar}:${org.snakeyaml:snakeyaml-engine:jar}" includeantruntime="build.sysclasspath=last" />
                  </target>
                </configuration>
              </execution>
            </executions>
          </plugin>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-jar-plugin</artifactId>
            <executions>
              <execution>
                <id>legacy-jar</id>
                <goals>
                  <goal>jar</goal>
                </goals>
                <configuration>
                  <classesDirectory>${legacy.outputDirectory}</classesDirectory>
                  <classifier>legacy</classifier>
                </configuration>
              </execution>
              <execution>
                <id>legacy-sources-jar</id>
                <phase>package</phase>
                <goals>
                  <goal>jar</goal>
                </goals>
                <configuration>
                  <classesDirectory>${legacy.sourceDirectory}</classesDirectory>
                  <classifier>legacy-sources</classifier>
                </configuration>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>

    <profile>
      <id>release</id>
      <build>
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-source-plugin</artifactId>
            <executions>
              <execution>
                <id>attach-sources</id>
                <goals>
                  <goal>jar-no-fork</goal>
                </goals>
              </execution>
            </executions>
          </plugin>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-javadoc-plugin</artifactId>
            <executions>
              <execution>
                <id>attach-javadocs</id>
                <goals>
                  <goal>jar</goal>
                </goals>
              </execution>
            </executions>
          </plugin>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-gpg-plugin</artifactId>
            <executions>
              <execution>
                <id>sign-artifacts</id>
                <phase>verify</phase>
                <goals>
                  <goal>sign</goal>
                </goals>
              </execution>
            </executions>
          </plugin>
          <plugin>
            <groupId>org.sonatype.plugins</groupId>
            <artifactId>nexus-staging-maven-plugin</artifactId>
            <extensions>true</extensions>
            <configuration>
              <serverId>ossrh</serverId>
              <nexusUrl>https://oss.sonatype.org/</nexusUrl>
              <autoReleaseAfterClose>true</autoReleaseAfterClose>
            </configuration>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>
</project>
