<!--
  ~ Licensed under the EUPL, Version 1.2 or - as soon they will be approved by
  ~ the European Commission - subsequent versions of the EUPL (the "Licence");
  ~ You may not use this work except in compliance with the Licence.
  ~ You may obtain a copy of the Licence at:
  ~
  ~   https://joinup.ec.europa.eu/software/page/eupl
  ~
  ~ Unless required by applicable law or agreed to in writing, software
  ~ distributed under the Licence is distributed on an "AS IS" basis,
  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  ~ See the Licence for the specific language governing permissions and
  ~ limitations under the Licence.
  -->

<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.opentripplanner</groupId>
  <artifactId>ojp-java-model</artifactId>
  <version>2.0.7</version>

  <name>ojp-java-model</name>
  <description>Generates Java model from OJP xsds using jaxb.</description>
  <url>https://github.com/opentripplanner/ojp-java-model</url>
  <organization>
    <name>OpenTripPlanner</name>
    <url>https://www.opentripplanner.org/</url>
  </organization>
  <licenses>
    <license>
      <name>EUPL-1.2 with modifications</name>
      <url>https://joinup.ec.europa.eu/software/page/eupl</url>
      <distribution>repo</distribution>
    </license>
  </licenses>
  <developers>
    <developer>
      <name>Leonard Ehrenfried</name>
      <email>mail@leonard.io</email>
    </developer>
  </developers>
  <scm>
    <connection>scm:git:ssh://git@github.com/opentripplanner/ojp-java-model.git</connection>
    <developerConnection>scm:git:ssh://git@github.com/opentripplanner/ojp-java-model.git</developerConnection>
    <url>https://github.com/opentripplanner/ojp-java-model/</url>
    <tag>2.0.7</tag>
  </scm>

  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <jdk.version>17</jdk.version>

    <ojpRepoName>OJP</ojpRepoName>
    <ojpBranch>master</ojpBranch>
    <ojpGithubUrl>https://github.com/vdvde/${ojpRepoName}</ojpGithubUrl>
    <ojpVersion>2.0</ojpVersion>

    <!-- JAXB components versions -->
    <jakarta-xml-bind.version>4.0.4</jakarta-xml-bind.version>
    <glassfish-jaxb.version>4.0.5</glassfish-jaxb.version>
    <jaxb.fluent.api.version>2.1.8</jaxb.fluent.api.version>
    <jaxb.java.time.adapters.version>1.1.3</jaxb.java.time.adapters.version>

    <cxf.xjc.plugin.version>4.1.1</cxf.xjc.plugin.version>
    <cxf-xjc.version>4.1.0</cxf-xjc.version>
    <xjc.guava.plugin.version>0.3.1</xjc.guava.plugin.version>

    <!-- Other dependencies versions -->
    <commons-lang3.version>3.12.0</commons-lang3.version>

    <!-- Unit test frameworks versions -->
    <junit.version>5.11.1</junit.version>

    <!-- Maven plugin versions  -->
    <maven-exec-plugin.version>1.6.0</maven-exec-plugin.version>
    <maven-surefire-plugin.version>2.22.2</maven-surefire-plugin.version>
    <maven-source-plugin.version>3.2.1</maven-source-plugin.version>
    <maven-javadoc-plugin.version>3.3.1</maven-javadoc-plugin.version>
    <maven-release-plugin.version>3.3.1</maven-release-plugin.version>
    <maven-gpg-plugin.version>1.6</maven-gpg-plugin.version>
    <maven-dependency-plugin.version>3.1.2</maven-dependency-plugin.version>
    <maven-compiler-plugin.version>3.13.0</maven-compiler-plugin.version>

    <maven-jar-plugin.version>3.2.0</maven-jar-plugin.version>
    <maven-clean-plugin.version>3.1.0</maven-clean-plugin.version>
    <maven-install-plugin.version>2.5.2</maven-install-plugin.version>
    <maven-resources-plugin.version>3.2.0</maven-resources-plugin.version>
    <maven-deploy-plugin.version>2.8.2</maven-deploy-plugin.version>

    <!-- empty argLine property, the value is set up by Jacoco during unit tests execution -->
    <argLine />

  </properties>

  <dependencies>

    <!-- JAXB -->
    <dependency>
      <groupId>jakarta.xml.bind</groupId>
      <artifactId>jakarta.xml.bind-api</artifactId>
      <version>${jakarta-xml-bind.version}</version>
    </dependency>
    <dependency>
      <groupId>com.sun.xml.bind</groupId>
      <artifactId>jaxb-impl</artifactId>
      <version>4.0.0</version>
      <scope>runtime</scope>
    </dependency>
    <dependency>
      <groupId>org.glassfish.jaxb</groupId>
      <artifactId>jaxb-runtime</artifactId>
      <version>${glassfish-jaxb.version}</version>
      <scope>runtime</scope>
    </dependency>
    <dependency>
      <groupId>org.apache.cxf.xjc-utils</groupId>
      <artifactId>cxf-xjc-runtime</artifactId>
      <version>${cxf-xjc.version}</version>
      <scope>runtime</scope>
    </dependency>

    <!-- Other dependencies -->
    <dependency>
      <groupId>org.apache.commons</groupId>
      <artifactId>commons-lang3</artifactId>
      <version>${commons-lang3.version}</version>
    </dependency>

    <!-- Test dependencies -->
    <dependency>
      <groupId>org.junit.jupiter</groupId>
      <artifactId>junit-jupiter-api</artifactId>
      <version>${junit.version}</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.junit.jupiter</groupId>
      <artifactId>junit-jupiter-engine</artifactId>
      <version>${junit.version}</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.junit.jupiter</groupId>
      <artifactId>junit-jupiter</artifactId>
      <version>5.11.1</version>
      <scope>test</scope>
    </dependency>

  </dependencies>

  <build>
    <pluginManagement>
      <plugins>
        <plugin>
          <artifactId>maven-jar-plugin</artifactId>
          <version>${maven-jar-plugin.version}</version>
        </plugin>
        <plugin>
          <artifactId>maven-clean-plugin</artifactId>
          <version>${maven-clean-plugin.version}</version>
        </plugin>
        <plugin>
          <artifactId>maven-install-plugin</artifactId>
          <version>${maven-install-plugin.version}</version>
        </plugin>
        <plugin>
          <artifactId>maven-resources-plugin</artifactId>
          <version>${maven-resources-plugin.version}</version>
        </plugin>
        <plugin>
          <artifactId>maven-deploy-plugin</artifactId>
          <version>${maven-deploy-plugin.version}</version>
        </plugin>
      </plugins>
    </pluginManagement>
    <plugins>
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>exec-maven-plugin</artifactId>
        <version>${maven-exec-plugin.version}</version>
        <executions>
          <execution>
            <id>download-extract-current-version</id>
            <phase>generate-sources</phase>
            <goals>
              <goal>exec</goal>
            </goals>
            <configuration>
              <environmentVariables>
                <VDVDE_REPO>${ojpRepoName}</VDVDE_REPO>
                <GIT_BRANCH>${ojpVersion}</GIT_BRANCH>
                <GITHUB_URL>${ojpGithubUrl}</GITHUB_URL>
                <DESTINATION_PATH>src/main/resources/xsd/${ojpVersion}</DESTINATION_PATH>
              </environmentVariables>
              <executable>./bin/download-extract.sh</executable>
            </configuration>
          </execution>
          <execution>
            <id>replace-hard-coded-id-in-bindings-file</id>
            <phase>generate-sources</phase>
            <goals>
              <goal>exec</goal>
            </goals>
            <configuration>
              <arguments>
                <argument>${ojpVersion}</argument>
              </arguments>
              <executable>
                ./bin/version_updater.sh
              </executable>
            </configuration>
          </execution>
          <execution>
            <id>annotation-removal</id>
            <phase>generate-sources</phase>
            <goals>
              <goal>exec</goal>
            </goals>
            <configuration>
              <arguments>
                <argument>${ojpVersion}</argument>
              </arguments>
              <executable>./bin/annotation-replacer.sh</executable>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.apache.cxf</groupId>
        <artifactId>cxf-xjc-plugin</artifactId>
        <version>${cxf.xjc.plugin.version}</version>
        <configuration>
          <extensions>
            <extension>net.java.dev.jaxb2-commons:jaxb-fluent-api:${jaxb.fluent.api.version}</extension>
            <extension>org.apache.cxf.xjcplugins:cxf-xjc-ts:${cxf-xjc.version}</extension>
          </extensions>
        </configuration>
        <executions>
          <execution>
            <id>generate-sources-for-ojp</id>
            <phase>generate-sources</phase>
            <goals>
              <goal>xsdtojava</goal>
            </goals>
            <configuration>
              <!--
              The cxf-xjc-plugin default source root is not following the standard Maven convention:
              "target/generated-sources/<tool-name>". So we override the default to follow the Maven
              convention. This makes it easier for other tools like Intellij and Eclipse to auto
              detect the generated source.
               -->
              <sourceRoot>${project.build.directory}/generated-sources/xjc</sourceRoot>
              <xsdOptions>
                <xsdOption>
                  <xsd>
                    ${basedir}/src/main/resources/xsd/${ojpVersion}/OJP.xsd
                  </xsd>
                  <extension>true</extension>
                  <bindingFile>bindings.xjb</bindingFile>
                  <extensionArgs>
                    <extensionArg>-Xbug986</extensionArg>
                    <extensionArg>-Xfluent-api</extensionArg>
                    <extensionArg>-Xts:style:org.opentripplanner.ojp.netex.OmitNullsToStringStyle.INSTANCE
                    </extensionArg>
                  </extensionArgs>
                </xsdOption>
              </xsdOptions>
            </configuration>
          </execution>
        </executions>
        <dependencies>
          <dependency>
            <groupId>org.apache.cxf.xjcplugins</groupId>
            <artifactId>cxf-xjc-bug986</artifactId>
            <version>${cxf.xjc.plugin.version}</version>
          </dependency>
          <dependency>
            <groupId>javax.activation</groupId>
            <artifactId>javax.activation-api</artifactId>
            <version>1.2.0</version>
          </dependency>
        </dependencies>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-antrun-plugin</artifactId>
        <version>3.0.0</version>
        <executions>
          <execution>
            <id>copy-package-info</id>
            <phase>generate-sources</phase>
            <goals>
              <goal>run</goal>
            </goals>
            <configuration>
              <target>
                <copy file="${project.basedir}/package-info.java" todir="${project.build.directory}/generated-sources/xjc/de/vdv/ojp20" overwrite="true" />
              </target>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>${maven-compiler-plugin.version}</version>
        <configuration>
          <source>${jdk.version}</source>
          <target>${jdk.version}</target>
          <encoding>UTF-8</encoding>
          <compilerArgs>
            <!--arg>-Werror</arg-->
            <arg>-Xlint:all</arg>
          </compilerArgs>
        </configuration>
        <dependencies>
          <dependency>
            <groupId>org.codehaus.plexus</groupId>
            <artifactId>plexus-compiler-javac</artifactId>
            <version>2.7</version>
          </dependency>
        </dependencies>
      </plugin>

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-release-plugin</artifactId>
        <version>${maven-release-plugin.version}</version>
        <configuration>
          <autoVersionSubmodules>true</autoVersionSubmodules>
          <releaseProfiles>sign</releaseProfiles>
          <goals>deploy</goals>
          <tagNameFormat>@{project.version}</tagNameFormat>
        </configuration>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <version>${maven-surefire-plugin.version}</version>
        <configuration>
          <argLine>@{argLine} -Xms500m -Xmx500m -Xss512k</argLine>
        </configuration>
      </plugin>
    </plugins>
  </build>

  <profiles>

    <profile>
      <id>sign</id>
      <activation>
        <activeByDefault>false</activeByDefault>
      </activation>

      <build>
        <pluginManagement>
          <plugins>
            <plugin>
              <groupId>org.apache.maven.plugins</groupId>
              <artifactId>maven-surefire-plugin</artifactId>
              <version>${maven-surefire-plugin.version}</version>
              <configuration>
                <useSystemClassLoader>false</useSystemClassLoader>
              </configuration>
            </plugin>
          </plugins>
        </pluginManagement>
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>${maven-surefire-plugin.version}</version>
          </plugin>

          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-gpg-plugin</artifactId>
            <version>${maven-gpg-plugin.version}</version>
            <executions>
              <execution>
                <id>sign-artifacts</id>
                <phase>verify</phase>
                <goals>
                  <goal>sign</goal>
                </goals>
              </execution>
            </executions>
          </plugin>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-source-plugin</artifactId>
            <version>${maven-source-plugin.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-javadoc-plugin</artifactId>
            <version>${maven-javadoc-plugin.version}</version>
            <configuration>
              <doclint>none</doclint>
            </configuration>
            <executions>
              <execution>
                <id>attach-javadocs</id>
                <goals>
                  <goal>jar</goal>
                </goals>
              </execution>
            </executions>
          </plugin>
          <plugin>
            <groupId>org.sonatype.central</groupId>
            <artifactId>central-publishing-maven-plugin</artifactId>
            <version>0.9.0</version>
            <extensions>true</extensions>
            <configuration>
              <publishingServerId>central</publishingServerId>
              <autoPublish>true</autoPublish>
            </configuration>
          </plugin>
        </plugins>


      </build>
    </profile>

  </profiles>

</project>
