<?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/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>org.asciidoctor</groupId>
    <artifactId>asciidoclet</artifactId>
    <version>2.0.0</version>
    <packaging>jar</packaging>

    <name>AsciiDoc Javadoc Doclet</name>
    <url>https://asciidoctor.org</url>
    <description>Asciidoclet is a Javadoc Doclet that allows you to write Javadoc using the AsciiDoc format</description>

    <organization>
        <name>Asciidoctor</name>
        <url>https://asciidoctor.org/</url>
    </organization>

    <developers>
        <developer>
            <id>johncarl81</id>
            <name>John Ericksen</name>
            <email>johncarl81@gmail.com</email>
            <url>https://johncarl81.github.io/</url>
            <roles>
                <role>Project Lead</role>
            </roles>
            <timezone>UTC-6</timezone>
        </developer>
    </developers>

    <licenses>
        <license>
            <name>Apache License, Version 2.0</name>
            <url>https://www.apache.org/licenses/LICENSE-2.0</url>
        </license>
    </licenses>

    <scm>
        <!-- For local tests use "scm:git:git@github.com:<repo_org>/<repo_name>.git" -->
        <url>scm:git:https://github.com/asciidoctor/asciidoclet.git</url>
        <connection>scm:git:https://github.com/asciidoctor/asciidoclet.git</connection>
        <developerConnection>scm:git:https://github.com/asciidoctor/asciidoclet.git</developerConnection>
      <tag>asciidoclet-2.0.0</tag>
  </scm>

    <properties>
        <currentYear>${maven.build.timestamp}</currentYear>
        <maven.build.timestamp.format>yyyy</maven.build.timestamp.format>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <integration-tests.path>src/it/java-11</integration-tests.path>
        <expected.java>11</expected.java>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.asciidoctor</groupId>
            <artifactId>asciidoctorj</artifactId>
            <version>2.5.12</version>
        </dependency>
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-engine</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-params</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.assertj</groupId>
            <artifactId>assertj-core</artifactId>
            <version>3.25.3</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.mockito</groupId>
            <artifactId>mockito-core</artifactId>
            <version>5.11.0</version>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.junit</groupId>
                <artifactId>junit-bom</artifactId>
                <version>5.10.2</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <build>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <version>3.13.0</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-deploy-plugin</artifactId>
                    <version>3.1.1</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-release-plugin</artifactId>
                    <version>3.0.1</version>
                    <configuration>
                        <mavenExecutorId>forked-path</mavenExecutorId>
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-resources-plugin</artifactId>
                    <version>3.3.1</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-source-plugin</artifactId>
                    <version>3.3.1</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-javadoc-plugin</artifactId>
                    <version>3.6.3</version>
                </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-surefire-plugin</artifactId>
                    <version>3.2.5</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-gpg-plugin</artifactId>
                    <version>3.2.2</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-invoker-plugin</artifactId>
                    <version>3.6.1</version>
                </plugin>
            </plugins>
        </pluginManagement>

        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>11</source>
                    <target>11</target>
                    <compilerArgs>
                        <arg>--add-exports</arg>
                        <arg>jdk.compiler/com.sun.tools.javac.model=asciidoclet</arg>
                        <arg>--add-exports</arg>
                        <arg>jdk.compiler/com.sun.tools.javac.parser=asciidoclet</arg>
                        <arg>--add-exports</arg>
                        <arg>jdk.compiler/com.sun.tools.javac.tree=asciidoclet</arg>
                        <arg>--add-exports</arg>
                        <arg>jdk.javadoc/jdk.javadoc.internal.tool=asciidoclet</arg>
                        <arg>--add-exports</arg>
                        <arg>jdk.compiler/com.sun.tools.javac.util=asciidoclet</arg>
                    </compilerArgs>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <configuration>
                    <argLine>
                        --add-exports jdk.compiler/com.sun.tools.javac.parser=asciidoclet
                        --add-exports jdk.compiler/com.sun.tools.javac.util=asciidoclet
                        --add-opens jdk.compiler/com.sun.tools.javac.parser=asciidoclet
                    </argLine>
                </configuration>
            </plugin>
            <!-- tag::pom_include[] -->
            <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>
                <configuration>
                    <source>11</source>
                    <additionalJOptions>
                        <additionalJOption>--add-exports=jdk.javadoc/jdk.javadoc.internal.api=asciidoclet</additionalJOption>
                        <additionalJOption>--add-exports=jdk.javadoc/jdk.javadoc.internal.tool=asciidoclet</additionalJOption>
                        <additionalJOption>--add-exports=jdk.compiler/com.sun.tools.javac.api=asciidoclet</additionalJOption>
                        <additionalJOption>--add-exports=jdk.compiler/com.sun.tools.javac.parser=asciidoclet</additionalJOption>
                        <additionalJOption>--add-exports=jdk.compiler/com.sun.tools.javac.tree=asciidoclet</additionalJOption>
                        <additionalJOption>--add-exports=jdk.compiler/com.sun.tools.javac.model=asciidoclet</additionalJOption>
                        <additionalJOption>--add-opens=jdk.compiler/com.sun.tools.javac.api=asciidoclet</additionalJOption>
                        <additionalJOption>--add-opens=jdk.compiler/com.sun.tools.javac.parser=asciidoclet</additionalJOption>
                        <additionalJOption>-J--add-opens=jdk.javadoc/jdk.javadoc.internal.api=ALL-UNNAMED</additionalJOption>
                        <additionalJOption>-J--add-opens=jdk.javadoc/jdk.javadoc.internal.tool=ALL-UNNAMED</additionalJOption>
                        <additionalJOption>-J--add-opens=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED</additionalJOption>
                        <additionalJOption>-J--add-opens=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED</additionalJOption>
                        <additionalJOption>-J--add-opens=jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED</additionalJOption>
                        <additionalJOption>-Xdoclint:all,-html,-accessibility</additionalJOption>
                    </additionalJOptions>
                    <doclet>org.asciidoctor.asciidoclet.Asciidoclet</doclet>
                    <docletArtifact>
                        <groupId>${project.groupId}</groupId>
                        <artifactId>${project.artifactId}</artifactId>
                        <version>${project.version}</version>
                    </docletArtifact>
                    <additionalOptions>  <!--1-->
                        --base-dir ${project.basedir}
                        --attribute "project_name=${project.name}"
                        --attribute "project_version=${project.version}"
                        --attribute "project_desc=${project.description}"
                    </additionalOptions>
                    <linksource>true</linksource>
                    <overview>src/main/java/overview.adoc</overview> <!--2-->
                </configuration>
            </plugin>
            <!-- end::pom_include[] -->
            <plugin>
                <groupId>com.mycila</groupId>
                <artifactId>license-maven-plugin</artifactId>
                <version>4.3</version>
                <configuration>
                    <header>NOTICE</header>
                    <includes>
                        <include>src/**/*.java</include>
                    </includes>
                    <excludes>
                        <exclude>${integration-tests.path}/**/*.*</exclude>
                    </excludes>
                    <properties>
                        <startYear>2013</startYear>
                        <currentYear>${currentYear}</currentYear>
                        <name>John Ericksen</name>
                    </properties>
                    <useDefaultExcludes>true</useDefaultExcludes>
                    <strictCheck>true</strictCheck>
                </configuration>
            </plugin>
        </plugins>
    </build>

    <profiles>
        <!-- Both use the same java-17 folder -->
        <profile>
            <id>java-17</id>
            <activation>
                <jdk>17</jdk>
            </activation>
            <properties>
                <integration-tests.path>src/it/java-17</integration-tests.path>
                <expected.java>17</expected.java>
            </properties>
        </profile>
        <profile>
            <id>java-21</id>
            <activation>
                <jdk>21</jdk>
            </activation>
            <properties>
                <integration-tests.path>src/it/java-17</integration-tests.path>
                <expected.java>21</expected.java>
            </properties>
        </profile>
        <profile>
            <!--
              To release, define environment variables:
                export GPG_KEYNAME=""
                export GPG_PASSPHRASE=""
              Then, run
               $ mvn deploy
            -->
            <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-gpg-plugin</artifactId>
                        <configuration>
                            <executable>gpg2</executable>
                            <keyname>${env.GPG_KEYNAME}</keyname>
                            <passphrase>${env.GPG_PASSPHRASE}</passphrase>
                            <gpgArguments>
                                <arg>--pinentry-mode</arg>
                                <arg>loopback</arg>
                            </gpgArguments>
                        </configuration>
                        <executions>
                            <execution>
                                <id>sign-artifacts</id>
                                <phase>verify</phase>
                                <goals>
                                    <goal>sign</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <id>run-its</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-invoker-plugin</artifactId>
                        <configuration>
                            <projectsDirectory>${integration-tests.path}</projectsDirectory>
                            <cloneProjectsTo>${project.build.directory}/it</cloneProjectsTo>
                            <pomIncludes>
                                <pomInclude>*/pom.xml</pomInclude>
                            </pomIncludes>
                            <preBuildHookScript>setup</preBuildHookScript>
                            <postBuildHookScript>validate</postBuildHookScript>
                            <showErrors>true</showErrors>
                            <debug>true</debug>
                            <!-- <localRepositoryPath>${project.build.directory}/local-repo</localRepositoryPath>-->
                            <!-- <settingsFile>src/it/settings.xml</settingsFile>-->
                            <goals>
                                <goal>clean</goal>
                                <goal>process-sources</goal>
                            </goals>
                            <scriptVariables>
                                <expected_java>${expected.java}</expected_java>
                            </scriptVariables>
                        </configuration>
                        <executions>
                            <execution>
                                <id>integration-test</id>
                                <goals>
                                    <goal>install</goal>
                                    <goal>run</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>

    <distributionManagement>
        <snapshotRepository>
            <id>ossrh</id>
            <url>https://oss.sonatype.org/content/repositories/snapshots</url>
        </snapshotRepository>
        <repository>
            <id>ossrh</id>
            <url>https://oss.sonatype.org/service/local/staging/deploy/maven2</url>
        </repository>
    </distributionManagement>

</project>
