<?xml version="1.0" encoding="UTF-8"?>
<!--
  ~ Copyright 2022 The graph-support project
  ~
  ~ Licensed under the Apache License, Version 2.0 (the "License");
  ~ you may not use this file except in compliance with the License.
  ~ You may obtain a copy of the License at
  ~
  ~  http://www.apache.org/licenses/LICENSE-2.0
  ~
  ~ Unless required by applicable law or agreed to in writing, software
  ~ distributed under the License is distributed on an "AS IS" BASIS,
  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  ~ See the License for the specific language governing permissions and
  ~ limitations under the License.
  -->

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

  <groupId>org.graphper</groupId>
  <artifactId>graph-support</artifactId>
  <version>1.5.5</version>
  <packaging>pom</packaging>

  <name>${project.artifactId}</name>
  <description>Java re-implementation of tiny graphviz</description>
  <url>https://github.com/jamisonjiang/graph-support</url>

  <modules>
    <module>core</module>
    <module>dot</module>
    <module>ui</module>
    <module>test</module>
    <module>cli</module>
  </modules>

  <licenses>
    <license>
      <name>Apache License, Version 2.0</name>
      <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
      <distribution>repo</distribution>
    </license>
  </licenses>

  <developers>
    <developer>
      <name>Jamison Jiang</name>
      <email>jamisongo01.jiang@gmail.com</email>
      <organization>Jamison Jiang</organization>
      <organizationUrl>https://github.com/jamisonjiang</organizationUrl>
    </developer>
  </developers>

  <scm>
    <connection>scm:git:https://github.com/jamisonjiang/graph-support</connection>
    <developerConnection>scm:git:https://github.com/jamisonjiang/graph-support</developerConnection>
    <url>https://github.com/jamisonjiang/graph-support</url>
    <tag>v1.5.5</tag>
  </scm>


  <distributionManagement>
    <snapshotRepository>
      <id>central-publishing</id>
      <url>https://central.sonatype.com/repository/maven-snapshots/</url>
    </snapshotRepository>
    <repository>
      <id>central-publishing</id>
      <url>https://central.sonatype.com/repository/maven-releases/</url>
    </repository>
  </distributionManagement>

  <issueManagement>
    <system>GitHub</system>
    <url>https://github.com/jamisonjiang/graph-support/issues</url>
  </issueManagement>

  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <java-version>1.8</java-version>
    <mvn-command-version>3.6.0</mvn-command-version>
    <encoder-type>UTF-8</encoder-type>
    <javadoc-version>3.2.0</javadoc-version>
    <source-version>2.2.1</source-version>
    <batik-version>1.19</batik-version>
    <fop-version>2.11</fop-version>
    <slf4j-version>1.7.32</slf4j-version>
    <junit-version>4.13.2</junit-version>
    <junit-param-version>5.8.2</junit-param-version>
    <assembly-version>2.4.1</assembly-version>
    <gpg-version>3.2.8</gpg-version>
    <sonatype-version>0.11.0</sonatype-version>
    <log4j-version>1.8.0-alpha2</log4j-version>
    <org.antlr-version>4.13.2</org.antlr-version>
    <checkstyle-version>9.3</checkstyle-version>
    <maven-checkstyle-version>3.3.1</maven-checkstyle-version>
    <!-- Only core enforces the optional-platform boundary; UI intentionally uses Swing/AWT. -->
    <checkstyle.core>false()</checkstyle.core>
  </properties>

  <dependencyManagement>
    <dependencies>
      <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-api</artifactId>
        <version>${slf4j-version}</version>
      </dependency>
      <!-- test dependencies -->
      <dependency>
        <groupId>org.apache.xmlgraphics</groupId>
        <artifactId>batik-codec</artifactId>
        <version>${batik-version}</version>
      </dependency>
      <dependency>
        <groupId>org.apache.xmlgraphics</groupId>
        <artifactId>batik-transcoder</artifactId>
        <version>${batik-version}</version>
      </dependency>
      <dependency>
        <groupId>org.apache.xmlgraphics</groupId>
        <artifactId>fop</artifactId>
        <version>${fop-version}</version>
        <exclusions>
          <exclusion>
            <groupId>com.sun.media</groupId>
            <artifactId>jai-codec</artifactId>
          </exclusion>
          <exclusion>
            <groupId>javax.media</groupId>
            <artifactId>jai-core</artifactId>
          </exclusion>
        </exclusions>
      </dependency>
      <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-log4j12</artifactId>
        <version>${log4j-version}</version>
      </dependency>
      <dependency>
        <groupId>org.junit.jupiter</groupId>
        <artifactId>junit-jupiter-params</artifactId>
        <version>${junit-param-version}</version>
      </dependency>
      <dependency>
        <groupId>org.junit.jupiter</groupId>
        <artifactId>junit-jupiter-engine</artifactId>
        <version>${junit-param-version}</version>
      </dependency>
      <dependency>
        <groupId>org.antlr</groupId>
        <artifactId>antlr4-runtime</artifactId>
        <version>${org.antlr-version}</version>
      </dependency>
    </dependencies>

  </dependencyManagement>

  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-checkstyle-plugin</artifactId>
        <version>${maven-checkstyle-version}</version>
        <dependencies>
          <dependency>
            <groupId>com.puppycrawl.tools</groupId>
            <artifactId>checkstyle</artifactId>
            <version>${checkstyle-version}</version>
          </dependency>
        </dependencies>
        <configuration>
          <configLocation>${maven.multiModuleProjectDirectory}/config/checkstyle/checkstyle.xml</configLocation>
          <suppressionsLocation>${maven.multiModuleProjectDirectory}/config/checkstyle/suppressions.xml</suppressionsLocation>
          <propertyExpansion>checkstyle.core=${checkstyle.core}</propertyExpansion>
          <!-- Check owned production sources, not tests or generated build output. -->
          <sourceDirectories>
            <sourceDirectory>${project.build.sourceDirectory}</sourceDirectory>
          </sourceDirectories>
          <excludes>org/apache_gs/**</excludes>
          <includeTestSourceDirectory>false</includeTestSourceDirectory>
          <includeResources>false</includeResources>
          <includeTestResources>false</includeTestResources>
          <consoleOutput>true</consoleOutput>
          <failOnViolation>true</failOnViolation>
        </configuration>
        <executions>
          <execution>
            <id>static-checks</id>
            <phase>validate</phase>
            <goals>
              <goal>check</goal>
            </goals>
          </execution>
          <execution>
            <id>google-style</id>
            <phase>validate</phase>
            <goals>
              <goal>check</goal>
            </goals>
            <configuration>
              <configLocation>${maven.multiModuleProjectDirectory}/config/checkstyle/google-style.xml</configLocation>
              <suppressionsFileExpression>checkstyle.suppressions.file</suppressionsFileExpression>
              <!-- The selected Google rules emit warnings; these must fail the build too. -->
              <violationSeverity>warning</violationSeverity>
              <outputFile>${project.build.directory}/checkstyle-google-result.xml</outputFile>
              <cacheFile>${project.build.directory}/checkstyle-google-cachefile</cacheFile>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>${mvn-command-version}</version>
        <configuration>
          <source>${java-version}</source>
          <target>${java-version}</target>
          <encoding>${encoder-type}</encoding>
        </configuration>
      </plugin>

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-resources-plugin</artifactId>
        <version>2.6</version>
        <configuration>
          <encoding>${encoder-type}</encoding>
        </configuration>
      </plugin>

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-javadoc-plugin</artifactId>
        <version>${javadoc-version}</version>
        <configuration>
          <charset>${encoder-type}</charset>
          <encoding>${encoder-type}</encoding>
          <docencoding>${encoder-type}</docencoding>
          <additionalOptions>
            <additionalOption>-Xdoclint:none</additionalOption>
            <additionalOption>-quiet</additionalOption> <!-- Optional: Suppress other warnings -->
          </additionalOptions>
        </configuration>
        <executions>
          <execution>
            <id>attach-javadocs</id>
            <goals>
              <goal>jar</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-source-plugin</artifactId>
        <version>${source-version}</version>
        <executions>
          <execution>
            <id>attach-sources</id>
            <goals>
              <goal>jar</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <version>3.0.0-M4</version>
        <configuration>
          <!--
            The renderer draws through java.awt (DefaultImgConverter, AWTMeasureText) and the ui
            module builds real Swing components, so without this the forked test JVM registers as a
            GUI application and steals window focus on macOS. Passed on the JVM command line rather
            than through systemPropertyVariables so it is in place before GraphicsEnvironment is
            first touched.
          -->
          <argLine>-Djava.awt.headless=true</argLine>
        </configuration>
        <dependencies>
          <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-engine</artifactId>
            <version>${junit-param-version}</version>
          </dependency>
        </dependencies>
      </plugin>
    </plugins>
  </build>

  <profiles>
    <profile>
      <id>central-release</id>
      <properties>
        <central.skipPublishing>true</central.skipPublishing>
      </properties>
      <build>
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-gpg-plugin</artifactId>
            <version>${gpg-version}</version>
            <executions>
              <execution>
                <id>sign-artifacts</id>
                <phase>verify</phase>
                <goals><goal>sign</goal></goals>
              </execution>
            </executions>
            <configuration>
              <keyname>E1B15C2FC719DF70C695BBCF3CA534AC4E848D5C</keyname>
              <useAgent>true</useAgent>
            </configuration>
          </plugin>
          <plugin>
            <groupId>org.sonatype.central</groupId>
            <artifactId>central-publishing-maven-plugin</artifactId>
            <version>${sonatype-version}</version>
            <extensions>true</extensions>
            <configuration>
              <publishingServerId>central-publishing</publishingServerId>
              <autoPublish>false</autoPublish>
              <waitUntil>validated</waitUntil>
              <skipPublishing>${central.skipPublishing}</skipPublishing>
              <excludeArtifacts>
                <excludeArtifact>graph-support-test</excludeArtifact>
              </excludeArtifacts>
            </configuration>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>
</project>
