<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>io.apicurio</groupId>
    <artifactId>apicurio-data-models</artifactId>
    <packaging>bundle</packaging>
    <version>1.1.27</version>
    <name>apicurio-data-models</name>

    <url>https://www.apicur.io/</url>
    <description>Open Source API Design Studio</description>

    <organization>
        <name>Red Hat</name>
        <url>https://www.redhat.com</url>
    </organization>

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

    <issueManagement>
        <system>GitHub</system>
        <url>https://github.com/apicurio/apicurio-data-models/issues</url>
    </issueManagement>

    <scm>
        <connection>scm:git:git@github.com:apicurio/apicurio-data-models.git</connection>
        <developerConnection>scm:git:git@github.com:apicurio/apicurio-data-models.git</developerConnection>
        <url>scm:git:git@github.com:apicurio/apicurio-data-models.git</url>
    </scm>

    <developers>
        <developer>
            <name>Eric Wittmann</name>
            <id>EricWittmann</id>
            <email>eric.wittmann@redhat.com</email>
            <organization>Red Hat</organization>
            <roles>
                <role>Project Lead</role>
                <role>Developer</role>
            </roles>
            <timezone>-5</timezone>
        </developer>
    </developers>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <maven.build.timestamp.format>yyyy-MM-dd HH:mm:ss</maven.build.timestamp.format>
        <timestamp>${maven.build.timestamp}</timestamp>

        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>

        <!-- Node Versions -->
        <version.node-js>16.16.0</version.node-js>

        <!-- Dependency Versions -->
        <version.com.fasterxml.jackson>2.12.5</version.com.fasterxml.jackson>
        <version.com.fasterxml.jackson.dataformat>2.10.0.pr1</version.com.fasterxml.jackson.dataformat>
        <version.commons-io>2.11.0</version.commons-io>
        <version.junit>4.13.2</version.junit>
        <version.org.jsweet>2.3.5</version.org.jsweet>
        <version.org.jsweet-core>6.3.0</version.org.jsweet-core>
        <version.org.jsweet-transpiler>2.3.7</version.org.jsweet-transpiler>
        <version.org.skyscreamer>1.5.1</version.org.skyscreamer>
        
        <!-- Plugin Versions -->
        <version.org.eclipse.m2e.lifecycle-mapping>1.0.0</version.org.eclipse.m2e.lifecycle-mapping>
        <version.org.apache.felix.maven-bundle-plugin>5.1.8</version.org.apache.felix.maven-bundle-plugin>
        <version.maven-compiler-plugin>3.10.1</version.maven-compiler-plugin>
        <version.maven-source-plugin>3.2.1</version.maven-source-plugin>
        <version.maven-javadoc-plugin>3.4.1</version.maven-javadoc-plugin>
        <version.maven-resources-plugin>3.3.0</version.maven-resources-plugin>
        <version.maven-gpg-plugin>3.0.1</version.maven-gpg-plugin>
        <version.org.codehaus.mojo.exec-maven-plugin>3.1.0</version.org.codehaus.mojo.exec-maven-plugin>
        <version.com.github.eirslett.frontend-maven-plugin>1.12.1</version.com.github.eirslett.frontend-maven-plugin>
        <version.org.sonatype.plugins.nexus-staging-maven-plugin>1.6.13</version.org.sonatype.plugins.nexus-staging-maven-plugin>
    </properties>

    <dependencies>
        <!-- Third Party Deps -->
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-core</artifactId>
            <version>${version.com.fasterxml.jackson}</version>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-databind</artifactId>
            <version>${version.com.fasterxml.jackson}</version>
        </dependency>

        <!-- https://mvnrepository.com/artifact/org.jsweet/jsweet-core -->
        <dependency>
            <groupId>org.jsweet</groupId>
            <artifactId>jsweet-core</artifactId>
            <version>${version.org.jsweet-core}</version>
            <scope>provided</scope>
        </dependency>

        <!-- https://mvnrepository.com/artifact/org.jsweet/jsweet-transpiler -->
        <dependency>
            <groupId>org.jsweet</groupId>
            <artifactId>jsweet-transpiler</artifactId>
            <version>${version.org.jsweet-transpiler}</version>
            <scope>provided</scope>
        </dependency>

        <!-- Test Only Deps -->
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>${version.junit}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>commons-io</groupId>
            <artifactId>commons-io</artifactId>
            <version>${version.commons-io}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.skyscreamer</groupId>
            <artifactId>jsonassert</artifactId>
            <version>${version.org.skyscreamer}</version>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.eclipse.m2e</groupId>
                    <artifactId>lifecycle-mapping</artifactId>
                    <version>${version.org.eclipse.m2e.lifecycle-mapping}</version>
                    <configuration>
                        <lifecycleMappingMetadata>
                            <pluginExecutions>
                                <pluginExecution>
                                    <pluginExecutionFilter>
                                        <groupId>
                                            org.jsweet
                                        </groupId>
                                        <artifactId>
                                            jsweet-maven-plugin
                                        </artifactId>
                                        <versionRange>
                                            [1.0.0,)
                                        </versionRange>
                                        <goals>
                                            <goal>jsweet</goal>
                                        </goals>
                                    </pluginExecutionFilter>
                                    <action>
                                        <ignore></ignore>
                                    </action>
                                </pluginExecution>
                            </pluginExecutions>
                        </lifecycleMappingMetadata>
                    </configuration>
                </plugin>
            </plugins>
        </pluginManagement>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>${version.maven-compiler-plugin}</version>
                <configuration>
                    <source>${maven.compiler.source}</source>
                    <target>${maven.compiler.target}</target>
                    <fork>true</fork>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-source-plugin</artifactId>
                <version>${version.maven-source-plugin}</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-javadoc-plugin</artifactId>
                <version>${version.maven-javadoc-plugin}</version>
                <executions>
                    <execution>
                        <id>attach-javadocs</id>
                        <goals>
                            <goal>jar</goal>
                        </goals>
                        <configuration>
                            <source>8</source>
                            <doclint>none</doclint>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.felix</groupId>
                <artifactId>maven-bundle-plugin</artifactId>
                <version>${version.org.apache.felix.maven-bundle-plugin}</version>
                <extensions>true</extensions>
                <executions>
                    <execution>
                        <id>versions</id>
                        <phase>validate</phase>
                        <goals>
                            <goal>cleanVersions</goal>
                        </goals>
                        <configuration>
                            <versions>
                                <apicurio.osgi.version.clean>${project.version}</apicurio.osgi.version.clean>
                            </versions>
                        </configuration>
                    </execution>
                </executions>
                <configuration>
                    <instructions>
                        <Bundle-SymbolicName>${project.groupId}.${project.artifactId}</Bundle-SymbolicName>
                        <Import-Package>
                            com.fasterxml.jackson*;resolution:=optional;version="[2.9,3)"
                        </Import-Package>
                        <Export-Package>
                            io.apicurio.datamodels*
                        </Export-Package>
                    </instructions>
                    <niceManifest>true</niceManifest>
                </configuration>
            </plugin>
        </plugins>
    </build>

    <distributionManagement>
        <snapshotRepository>
            <id>ossrh</id>
            <url>https://oss.sonatype.org/content/repositories/snapshots</url>
        </snapshotRepository>
    </distributionManagement>

    <profiles>
        <profile>
            <id>transpilation</id>

            <pluginRepositories>
                <pluginRepository>
                    <id>jsweet-plugins-release</id>
                    <name>plugins-release</name>
                    <url>https://repository.jsweet.org/artifactory/plugins-release-local</url>
                </pluginRepository>
            </pluginRepositories>

            <repositories>
                <repository>
                    <id>jsweet-central</id>
                    <name>libs-release</name>
                    <url>https://repository.jsweet.org/artifactory/libs-release-local</url>
                </repository>
            </repositories>

            <build>
                <plugins>
                    <!-- Generate TS from Java -->
                    <plugin>
                        <groupId>org.jsweet</groupId>
                        <artifactId>jsweet-maven-plugin</artifactId>
                        <version>${version.org.jsweet}</version>
                        <configuration>
                            <verbose>true</verbose>
                            <tsOut>target/ts/src</tsOut>
                            <targetVersion>ES6</targetVersion>
                            <module>umd</module>
                            <moduleResolution>classic</moduleResolution>
                            <tsOnly>true</tsOnly>
                            <excludes>
                                <exclude>**/_*/**</exclude>
                            </excludes>
                        </configuration>
                        <executions>
                            <execution>
                                <id>generate-js</id>
                                <phase>generate-sources</phase>
                                <goals>
                                    <goal>jsweet</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-resources-plugin</artifactId>
                        <version>${version.maven-resources-plugin}</version>
                        <executions>
                            <!-- Copy TS env from src into target -->
                            <execution>
                                <id>copy-ts</id>
                                <phase>generate-sources</phase>
                                <goals>
                                    <goal>copy-resources</goal>
                                </goals>
                                <configuration>
                                    <outputDirectory>${basedir}/target/ts</outputDirectory>
                                    <overwrite>true</overwrite>
                                    <resources>
                                        <resource>
                                            <directory>${basedir}/src/main/ts</directory>
                                            <filtering>true</filtering>
                                        </resource>
                                    </resources>
                                </configuration>
                            </execution>
                            <!-- Copy test fixtures into ts env -->
                            <execution>
                                <id>copy-fixtures</id>
                                <phase>generate-sources</phase>
                                <goals>
                                    <goal>copy-resources</goal>
                                </goals>
                                <configuration>
                                    <outputDirectory>${basedir}/target/ts/tests/fixtures</outputDirectory>
                                    <overwrite>true</overwrite>
                                    <resources>
                                        <resource>
                                            <directory>${basedir}/src/test/resources/fixtures</directory>
                                            <filtering>false</filtering>
                                        </resource>
                                    </resources>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                    <!-- Generate the core.ts file -->
                    <plugin>
                        <groupId>org.codehaus.mojo</groupId>
                        <artifactId>exec-maven-plugin</artifactId>
                        <version>${version.org.codehaus.mojo.exec-maven-plugin}</version>
                        <executions>
                            <execution>
                                <id>generate-corets</id>
                                <phase>package</phase>
                                <goals>
                                    <goal>java</goal>
                                </goals>
                            </execution>
                        </executions>
                        <configuration>
                            <mainClass>io.apicurio.datamodels._build.GenerateCoreTs</mainClass>
                            <arguments>
                                <argument>${basedir}/target/ts/src</argument>
                            </arguments>
                        </configuration>
                    </plugin>
                    <!-- Build the TS into a library bundle -->
                    <plugin>
                        <groupId>com.github.eirslett</groupId>
                        <artifactId>frontend-maven-plugin</artifactId>
                        <version>${version.com.github.eirslett.frontend-maven-plugin}</version>
                        <executions>
                            <!-- Install Node -->
                            <execution>
                                <id>install node</id>
                                <goals>
                                    <goal>install-node-and-npm</goal>
                                </goals>
                                <phase>generate-sources</phase>
                                <configuration>
                                    <workingDirectory>${basedir}/target/ts</workingDirectory>
                                    <nodeVersion>v${version.node-js}</nodeVersion>
                                </configuration>
                            </execution>
                            <!-- Install npm dependencies -->
                            <execution>
                                <id>npm install</id>
                                <goals>
                                    <goal>npm</goal>
                                </goals>
                                <phase>generate-sources</phase>
                                <configuration>
                                    <workingDirectory>${basedir}/target/ts</workingDirectory>
                                    <arguments>install</arguments>
                                </configuration>
                            </execution>
                            <!-- Test the library -->
                            <execution>
                                <id>ng test</id>
                                <goals>
                                    <goal>npm</goal>
                                </goals>
                                <phase>test</phase>
                                <configuration>
                                    <workingDirectory>${basedir}/target/ts</workingDirectory>
                                    <arguments>test</arguments>
                                </configuration>
                            </execution>
                            <!-- Build+package the library -->
                            <execution>
                                <id>ng build</id>
                                <goals>
                                    <goal>npm</goal>
                                </goals>
                                <phase>package</phase>
                                <configuration>
                                    <workingDirectory>${basedir}/target/ts</workingDirectory>
                                    <arguments>run package</arguments>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>


            </build>
        </profile>
        <profile>
            <id>release</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.sonatype.plugins</groupId>
                        <artifactId>nexus-staging-maven-plugin</artifactId>
                        <version>${version.org.sonatype.plugins.nexus-staging-maven-plugin}</version>
                        <extensions>true</extensions>
                        <configuration>
                            <serverId>ossrh</serverId>
                            <nexusUrl>https://oss.sonatype.org/</nexusUrl>
                            <autoReleaseAfterClose>true</autoReleaseAfterClose>
                        </configuration>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-gpg-plugin</artifactId>
                        <version>${version.maven-gpg-plugin}</version>
                        <executions>
                            <execution>
                                <id>sign-artifacts</id>
                                <phase>verify</phase>
                                <goals>
                                    <goal>sign</goal>
                                </goals>
                                <configuration>
                                    <!-- Prevent `gpg` from using pinentry programs -->
                                    <gpgArguments>
                                        <arg>--pinentry-mode</arg>
                                        <arg>loopback</arg>
                                    </gpgArguments>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>
</project>
