<?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>

    <groupId>org.audiveris</groupId>
    <artifactId>proxymusic</artifactId>
    <packaging>jar</packaging>
    <version>4.0.2</version>

    <name>ProxyMusic</name>
    <url>https://github.com/Audiveris/proxymusic</url>
    <description>ProxyMusic provides a binding between Java objects in memory and data formatted according to MusicXML 4.0</description>

    <licenses>
        <license>
            <name>GNU General Lesser Public License (LGPL) version 3.0</name>
            <url>http://www.gnu.org/licenses/lgpl-3.0.txt</url>
        </license>
    </licenses>

    <organization>
        <name>Audiveris Ltd</name>
        <url>http://www.audiveris.org</url>
    </organization>

    <developers>
        <developer>
            <id>hbitteur</id>
            <name>Hervé Bitteur</name>
            <email>herve.bitteur@audiveris.org</email>
            <organization>Audiveris Ltd</organization>
            <organizationUrl>http://www.audiveris.org</organizationUrl>
            <roles>
                <role>administrator</role>
                <role>developer</role>
            </roles>
            <timezone>+1</timezone>
            <properties>
                <picUrl>images/Herve-64x64.png</picUrl>
            </properties>
        </developer>
    </developers>

    <!-- Source Code Management -->
    <scm>
        <connection>scm:git:git://github.com/Audiveris/proxymusic.git</connection>
        <developerConnection>scm:git:ssh://git@github.com/Audiveris/proxymusic.git</developerConnection>
        <url>https://github.com/Audiveris/proxymusic</url>
    </scm>

    <!-- Issue management -->
    <issueManagement>
        <system>GitHub Issues</system>
        <url>https://github.com/Audiveris/proxymusic/issues</url>
    </issueManagement>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <maven.compiler.encoding>UTF-8</maven.compiler.encoding>        
    </properties>

    <!-- Location where site is deployed - username/password for site.deployments are in server.xml 
    <distributionManagement>
        <site>
            <id>proxymusic-repo</id>
            <name>Site deployments</name>
            <url>scp://kenai.com/proxymusic/website/</url>
        </site>
    </distributionManagement>
    -->

    <profiles>
        <profile>
            <id>java8-disable-strict-javadoc</id>
            <activation>
                <jdk>[1.8,)</jdk>
            </activation>
            <properties>
                <javadoc.doclint.none>-Xdoclint:none</javadoc.doclint.none>
            </properties>
        </profile>
    </profiles>

    <dependencies>
        <!-- Unitary tests framework -->
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.13.2</version>
            <scope>test</scope>
        </dependency>

        <!-- Logging facade API (with no imposed binding) -->
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
            <version>1.7.32</version>
        </dependency>

        <!-- Logging bindings, just for tests -->
        <dependency>
            <scope>test</scope>
            <groupId>ch.qos.logback</groupId>
            <artifactId>logback-classic</artifactId>
            <version>1.2.10</version>
        </dependency>

        <!-- JAXB API needed here for compilation of classes generated by jaxb2-maven-plugin. -->
        <dependency>
            <groupId>javax.xml.bind</groupId>
            <artifactId>jaxb-api</artifactId>
            <version>2.3.1</version>
        </dependency>

        <!-- JAXB runtime needed here for running tests -->
        <dependency>
            <groupId>org.glassfish.jaxb</groupId>
            <artifactId>jaxb-runtime</artifactId>
            <version>2.3.3</version>
            <scope>runtime</scope>
        </dependency>
    </dependencies>
    
    <build>
        <defaultGoal>install</defaultGoal>

        <extensions>
            <!-- For deploying using webdav -->
            <extension>
                <groupId>org.apache.maven.wagon</groupId>
                <artifactId>wagon-ssh</artifactId>
                <version>3.5.1</version>
            </extension>
        </extensions>

        <pluginManagement>
            <plugins>
                <!-- Enforce JDK 17 -->
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-enforcer-plugin</artifactId>
                    <version>3.0.0</version>
                    <executions>
                        <execution>
                            <id>enforce-java</id>
                            <goals>
                                <goal>enforce</goal>
                            </goals>
                            <configuration>
                                <rules>
                                    <requireJavaVersion>
                                        <version>17</version>
                                    </requireJavaVersion>
                                </rules>
                            </configuration>
                        </execution>
                        
                    </executions>
                </plugin>
                
                <!-- configure Maven to use JDK 17 for compilation -->
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <version>3.9.0</version>
                    <configuration>
                        <useIncrementalCompilation>false</useIncrementalCompilation>
                        <source>17</source>
                        <target>17</target>
                        <testSource>17</testSource>
                        <testTarget>17</testTarget>
                    </configuration>
                </plugin>                
                
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-dependency-plugin</artifactId>
                    <version>3.2.0</version>
                </plugin>
            </plugins>
        </pluginManagement>

        <plugins>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>properties-maven-plugin</artifactId>
                <version>1.0.0</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>set-system-properties</goal>
                        </goals>
                        <configuration>
                            <properties>
                                <!-- Allow JAXB access to external schema -->
                                <property>
                                    <name>javax.xml.accessExternalSchema</name>
                                    <value>all</value>
                                </property>
                                
                                <!-- 
                                    Workaround for deploy phase.
                                    Setting property is useless, but is kept here so that you can
                                    by yourself issue the following command:
                                    export MAVEN_OPTS="..."
                                    Where ... is replaced verbatim by the property value
                                    Including the double dashes that cannot be put in this comment!
                                -->                                                              
                                <property>
                                    <name>MAVEN_OPTS</name>
                                    <value>--add-opens java.base/java.util=ALL-UNNAMED --add-opens java.base/java.lang.reflect=ALL-UNNAMED --add-opens java.base/java.text=ALL-UNNAMED --add-opens java.desktop/java.awt.font=ALL-UNNAMED</value>
                                </property>
                            </properties>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <!-- Generating Java sources from schemas -->
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>jaxb2-maven-plugin</artifactId>
                <version>2.4</version>
                
                <configuration>
                    <!-- Copy source XSD files into resulting jar -->
                    <xsdPathWithinArtifact>META-INF/jaxb/xsd</xsdPathWithinArtifact>
                </configuration>   
                             
                <executions>
                    <!-- for Opus -->
                    <execution>
                        <id>xjc-opus</id>
                        <goals>
                            <goal>xjc</goal>
                        </goals>
                        <configuration>
                            <sources>
                                <source>src/main/xsd/opus.xsd</source>
                            </sources>
                            <packageName>org.audiveris.proxymusic.opus</packageName>
                            <xjbSources>
                                <!-- no binding customization -->
                                <xjbSource>src/main/xjb/void.xjb</xjbSource>
                            </xjbSources>
                        </configuration>
                    </execution>
                    
                    <!-- for MusicXML -->
                    <execution>
                        <id>xjc-musicxml</id>
                        <goals>
                            <goal>xjc</goal>
                        </goals>
                        <configuration>
                            <sources>
                                <source>src/main/xsd/musicxml.xsd</source>
                            </sources>
                            <packageName>org.audiveris.proxymusic</packageName>
                            <xjbSources>
                                <xjbSource>src/main/xjb/musicxml.xjb</xjbSource>
                            </xjbSources>
                            <clearOutputDir>false</clearOutputDir>
                        </configuration>
                    </execution>
                </executions> 
                             
                <dependencies>
                    <dependency>
                      <groupId>com.sun.activation</groupId>
                      <artifactId>javax.activation</artifactId>
                      <version>1.2.0</version>
                    </dependency>

                    <dependency>
                      <groupId>org.glassfish.jaxb</groupId>
                      <artifactId>jaxb-xjc</artifactId>
                      <version>2.3.3</version>
                    </dependency>

                    <dependency>
                      <groupId>org.glassfish.jaxb</groupId>
                      <artifactId>jaxb-core</artifactId>
                      <version>2.3.0.1</version>
                    </dependency>

<!-- CALL FOR HELP:

    1/ Even though the following dependency on 'jaxb-runtime' is already declared at project level,
    it is included here at plugin level, otherwise the plugin execution fails with this message:
        Execution xjc-opus of goal org.codehaus.mojo:jaxb2-maven-plugin:2.4:xjc failed:
        A required class was missing while executing org.codehaus.mojo:jaxb2-maven-plugin:2.4:xjc:
        com/sun/xml/bind/Utils
                            
    2/ If it is included here only, then compiling the test programs fails with this message:
        javax.xml.bind.JAXBException: Implementation of JAXB-API has not been found on module path or classpath.
                            
    Go figure!
-->
                    <dependency>
                      <groupId>org.glassfish.jaxb</groupId>
                      <artifactId>jaxb-runtime</artifactId>
                      <version>2.3.3</version>
                    </dependency>
                </dependencies>
            </plugin>
            
            <!-- Ant tasks -->
            <plugin>
                <artifactId>maven-antrun-plugin</artifactId>
                <version>3.0.0</version>
                <executions>
                    <execution>
                        <!-- Generate class ProgramId.java -->
                        <id>generate-program-id</id>
                        <phase>process-sources</phase>
                        <goals>
                            <goal>run</goal>
                        </goals>
                        <configuration>
                            <exportAntProperties>true</exportAntProperties>
                            <target>
                                <property name="program.name" value="${project.name}" />
                                <property name="program.version" value="${project.version}" />
                                <ant antfile="ant-tasks.xml"
                                     dir="${basedir}"
                                     target="generate-program-id"
                                     inheritRefs="true" />
                            </target>
                        </configuration>
                    </execution>
                    
                    <execution>
                        <!-- Fix javadoc tags in generated JAXB sources -->
                        <id>fix-tags</id>
                        <phase>process-sources</phase>
                        <goals>
                            <goal>run</goal>
                        </goals>
                        <configuration>
                            <exportAntProperties>true</exportAntProperties>
                            <target>
                                <ant antfile="ant-tasks.xml"
                                     dir="${basedir}"
                                     target="fix-tags"
                                     inheritRefs="true" />
                            </target>
                        </configuration>
                    </execution>
                    
                </executions>
            </plugin>
            
            <!-- Building a Jar of class binaries -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <version>3.2.2</version>
                <configuration>
                    <archive>
                        <manifest>
                            <addDefaultImplementationEntries>true</addDefaultImplementationEntries>
                        </manifest>
                        <manifestEntries>
                            <Implementation-Revision>${program.revision}</Implementation-Revision>
                        </manifestEntries>
                    </archive>
                    <excludes>
                        <!-- Otherwise, we get both .java and .class files in jar ??? -->
                        <exclude>**/*.java</exclude>
                    </excludes>
                </configuration>
            </plugin>

            <!-- Building a Jar of class sources -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-source-plugin</artifactId>
                <version>3.2.1</version>
                <executions>
                    <execution>
                        <id>attach-sources</id>
                        <goals>
                            <goal>jar</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

            <!-- Building a Jar of JavaDoc -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-javadoc-plugin</artifactId>
                <configuration>
                    <!-- To avoid too many 'errors' with JDK8 doclint -->
                    <additionalparam>${javadoc.doclint.none}</additionalparam>
                </configuration>
                <version>3.3.1</version>
                <executions>
                    <execution>
                        <id>attach-javadocs</id>
                        <goals>
                            <goal>jar</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

            <!-- Building web site (?) -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-site-plugin</artifactId>
                <version>3.10.0</version>
                <executions>
                    <execution>
                        <id>attach-descriptor</id>
                        <goals>
                            <goal>attach-descriptor</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            
            <!-- Signing artifacts (mandatory for upload) -->            
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-gpg-plugin</artifactId>
                <version>3.0.1</version>
                <executions>
                    <execution>
                        <id>sign-artifacts</id>
                        <phase>verify</phase>
                        <goals>
                            <goal>sign</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

            <!-- Upload artifacts to Nexus staging repository to be synced into Maven Central Repository -->
            <plugin>
                <groupId>org.sonatype.plugins</groupId>
                <artifactId>nexus-staging-maven-plugin</artifactId>
                <version>1.6.8</version>
                <extensions>true</extensions>
                <configuration>
                    <serverId>ossrh</serverId>
<!--                    <nexusUrl>https://s01.oss.sonatype.org/</nexusUrl>-->
                    <nexusUrl>https://oss.sonatype.org</nexusUrl>
                    <!-- <stagingProfileId>???</stagingProfileId> -->
                    <autoReleaseAfterClose>true</autoReleaseAfterClose>
                </configuration>
            </plugin>
            
        </plugins>
    </build>
    
     <!-- For a web site (not really used) -->
    <reporting>
        <plugins>
            <!-- Standard maven reports -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-project-info-reports-plugin</artifactId>
                <version>3.1.2</version>
            </plugin>

            <!-- JavaDoc -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-javadoc-plugin</artifactId>
                <configuration>
                    <!-- To avoid too many 'errors' with JDK8 doclint -->
                    <additionalparam>${javadoc.doclint.none}</additionalparam>
                </configuration>
                <version>3.3.1</version>
            </plugin>

            <!-- Java cross references -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jxr-plugin</artifactId>
                <version>3.1.1</version>
            </plugin>

            <!-- Unitary tests report -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-report-plugin</artifactId>
                <version>3.0.0-M5</version>
            </plugin>

            <!-- Unitary tests coverage -->
<!--            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>cobertura-maven-plugin</artifactId>
                <version>2.7</version>
            </plugin>-->
        </plugins>
    </reporting>
</project>
