<?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.harctoolbox</groupId>
    <artifactId>Jirc</artifactId>
    <packaging>jar</packaging>
    <version>2.2.13</version>
    <name>${project.artifactId}</name>
    <licenses>
        <license>
            <name>GPL 2+</name>
            <url>https://www.gnu.org/licenses/gpl2.html</url>
        </license>
    </licenses>
    <description>A Java translation of substantial parts of Lirc 0.9.0.</description>
    <url>http://www.harctoolbox.org</url>
    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
        <project.nameLowercase>jirc</project.nameLowercase>
    </properties>

    <developers>
        <developer>
            <name>Bengt Martensson</name>
            <email>barf@bengt-martensson.de</email>
            <url>http://www.bengt-martensson.de</url>
            <roles>
                <role>Project leader and architect</role>
                <role>Developer</role>
            </roles>
        </developer>
    </developers>

    <scm>
        <connection>scm:git:git://github.com:bengtmartensson/${project.artifactId}.git</connection>
        <developerConnection>scm:git:ssh://github.com:bengtmartensson/${project.artifactId}.git</developerConnection>
        <url>https://github.com/bengtmartensson/${project.artifactId}/tree/master</url>
    </scm>

    <issueManagement>
        <system>GitHub Issues</system>
        <url>https://github.com/bengtmartensson/${project.artifactId}/issues</url>
    </issueManagement>

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

    <build>
        <plugins>
            <!-- Generate Version.java from Version.xml using mkVersion.xsl. -->
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>xml-maven-plugin</artifactId>
                <version>1.1.0</version>
                <executions>
                    <execution>
                        <phase>generate-sources</phase>
                        <goals>
                            <goal>transform</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <basedir>common/schemas</basedir>
                    <catalogHandling>strict</catalogHandling>
                    <catalogs>
                        <catalog>catalog.xml</catalog>
                    </catalogs>
                    <transformationSets>
                        <transformationSet>
                            <!-- Generate Version.java from Version.xml using mkVersion.xsl. -->
                            <dir>src/main/xml</dir>
                            <outputDir>${project.build.directory}/generated-sources/xml/org/harctoolbox/${project.nameLowercase}</outputDir>
                            <includes>
                                <include>Version.xml</include>
                            </includes>
                            <stylesheet>${project.basedir}/common/xslt/mkVersion.xsl</stylesheet>
                            <parameters>
                                <parameter>
                                    <name>version</name>
                                    <value>${project.version}</value>
                                </parameter>
                                <parameter>
                                    <name>url</name>
                                    <value>${project.url}</value>
                                </parameter>
                                <parameter>
                                    <name>appName</name>
                                    <value>${project.artifactId}</value>
                                </parameter>
                                <parameter>
                                    <name>commitId</name>
                                    <value>${git.commit.id}</value>
                                </parameter>
                            </parameters>
                            <fileMappers>
                                <fileMapper implementation="org.codehaus.plexus.components.io.filemappers.FileExtensionMapper">
                                    <targetExtension>.java</targetExtension>
                                </fileMapper>
                            </fileMappers>
                        </transformationSet>
                    </transformationSets>
                </configuration>

                <dependencies>
                    <dependency>
                        <groupId>xalan</groupId>
                        <artifactId>xalan</artifactId>
                        <version>2.7.2</version>
                    </dependency>
                </dependencies>
            </plugin>

            <!-- Binary tarballs from src/assembly*/ files. -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-assembly-plugin</artifactId>
                <version>3.6.0</version>
                <configuration>
                    <archive>
                        <manifest>
                            <mainClass>org.harctoolbox.jirc.ConfigFile</mainClass>
                        </manifest>
                    </archive>
                    <descriptorRefs>
                        <descriptorRef>jar-with-dependencies</descriptorRef>
                    </descriptorRefs>
                    <descriptors>
                        <descriptor>src/assembly/target.xml</descriptor>
                    </descriptors>
                </configuration>
                <executions>
                    <execution>
                        <id>exec-bin</id>
                        <phase>package</phase>
                        <goals>
                            <goal>single</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.11.0</version>
                <configuration>
                    <showDeprecation>true</showDeprecation>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>build-helper-maven-plugin</artifactId>
                <version>3.5.0</version>
                <executions>
                    <execution>
                        <phase>generate-sources</phase>
                        <goals>
                            <goal>add-source</goal>
                        </goals>
                        <configuration>
                            <sources>
                                <source>${project.build.directory}/generated-sources/xml</source>
                            </sources>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-javadoc-plugin</artifactId>
                <version>3.6.2</version>
                <configuration>
                    <outputDirectory>${project.build.directory}/apidocs</outputDirectory>
                    <show>package</show> <!-- Document also package private classes -->
                    <aggregate>true</aggregate>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>exec-maven-plugin</artifactId>
                <version>3.1.1</version>
                <executions>
                    <!-- compute checksums -->
                    <!-- I know the checksum-maven-plugin, but it does not do what I want) -->
                    <execution>
                        <id>mk-checksums</id>
                        <phase>install</phase>
                        <goals>
                            <goal>exec</goal>
                        </goals>
                        <configuration>
                            <executable>${basedir}/common/scripts/mkchecksums.sh</executable>
                            <workingDirectory>${project.build.directory}</workingDirectory>
                            <arguments>
                                <argument>${project.artifactId}-${project.version}-bin.zip</argument>
                            </arguments>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>pl.project13.maven</groupId>
                <artifactId>git-commit-id-plugin</artifactId>
                <version>4.9.10</version>
                <executions>
                    <execution>
                        <phase>validate</phase>
                        <goals>
                            <goal>revision</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <dateFormat>yyyyMMdd</dateFormat><!--  human-readable part of the version number -->
                    <dotGitDirectory>${project.basedir}/.git</dotGitDirectory>
                    <generateGitPropertiesFile>false</generateGitPropertiesFile><!-- somehow necessary. otherwise the variables are not available in the pom -->
                </configuration>
            </plugin>
        </plugins>
    </build>

    <profiles>
        <profile>
            <id>release</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-javadoc-plugin</artifactId>
                        <version>3.6.2</version>
                        <configuration>
                            <outputDirectory>${project.build.directory}/apidocs</outputDirectory>
                            <show>package</show> <!-- Document also package private classes -->
                            <aggregate>true</aggregate>
                        </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>3.3.0</version>
                        <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>
                        <version>3.1.0</version>
                        <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>
                        <version>1.6.13</version>
                        <extensions>true</extensions>
                        <configuration>
                            <serverId>ossrh</serverId>
                            <nexusUrl>https://oss.sonatype.org/</nexusUrl>
                            <autoReleaseAfterClose>true</autoReleaseAfterClose>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>

    <dependencies>
        <dependency>
            <groupId>org.harctoolbox</groupId>
            <artifactId>Girr</artifactId> <!-- Invokes IrpTransmgrifier transitively -->
            <version>${project.version}</version>
        </dependency>
    </dependencies>
</project>
