<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.gcube.resources.discovery</groupId>
    <artifactId>ic-client</artifactId>
    <version>3.0.1-SNAPSHOT</version>
    <name>Information Collector Client</name>
    <description>Client API for the Information Collector service</description>

    <parent>
        <groupId>org.gcube.tools</groupId>
        <artifactId>maven-parent</artifactId>
        <version>1.3.0-SNAPSHOT</version>
    </parent>

    <scm>
        <connection>
			scm:git:https://code-repo.d4science.org/gCubeSystem/${project.artifactId}.git</connection>
        <developerConnection>
			scm:git:https://code-repo.d4science.org/gCubeSystem/${project.artifactId}.git</developerConnection>
        <url>https://code-repo.d4science.org/gCubeSystem/${project.artifactId}</url>
    </scm>

    <properties>
        <java.version>17</java.version>
        <maven.compiler.source>${java.version}</maven.compiler.source>
        <maven.compiler.target>${java.version}</maven.compiler.target>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.gcube.distribution</groupId>
                <artifactId>gcube-bom</artifactId>
                <version>4.0.1-SNAPSHOT</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>org.gcube.common</groupId>
            <artifactId>common-security</artifactId>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
        </dependency>

        <dependency>
            <groupId>org.gcube.core</groupId>
            <artifactId>common-scope-maps</artifactId>
            <scope>compile</scope>
        </dependency>

        <!-- Jakarta XML Binding moved to profile -->

        <!--
        
        <dependency>
            <groupId>jakarta.xml.bind</groupId>
            <artifactId>jakarta.xml.bind-api</artifactId>
        </dependency>

        <dependency>
            <groupId>jakarta.xml.ws</groupId>
            <artifactId>jakarta.xml.ws-api</artifactId>
        </dependency>

        <dependency>
            <groupId>com.sun.xml.ws</groupId>
            <artifactId>jaxws-rt</artifactId>
            <scope>runtime</scope>
        </dependency>

        <dependency>
            <groupId>org.glassfish.jaxb</groupId>
            <artifactId>jaxb-runtime</artifactId>
        </dependency> -->

        <!-- Test Dependencies -->
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-simple</artifactId>
            <version>1.6.4</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.gcube.common</groupId>
            <artifactId>d4science-iam-client</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.gcube.common.security</groupId>
            <artifactId>gcube-secrets</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.13.2</version>
            <scope>test</scope>
        </dependency>
    </dependencies>
    <profiles>
        <!-- Default profile for Jakarta EE (without classifier) -->
        <profile>
            <id>jakarta</id>
            <activation>
                <activeByDefault>true</activeByDefault>
            </activation>
            <dependencies>
                <dependency>
                    <groupId>org.gcube.core</groupId>
                    <artifactId>common-gcore-stubs</artifactId>
                </dependency>
                <dependency>
                    <groupId>org.gcube.resources</groupId>
                    <artifactId>common-gcore-resources</artifactId>
                </dependency>
                <dependency>
                    <groupId>org.gcube.core</groupId>
                    <artifactId>common-scope</artifactId>
                </dependency>
                <dependency>
                    <groupId>org.gcube.resources.discovery</groupId>
                    <artifactId>discovery-client</artifactId>
                </dependency>
                <dependency>
                    <groupId>jakarta.xml.bind</groupId>
                    <artifactId>jakarta.xml.bind-api</artifactId>
                </dependency>

                <dependency>
                    <groupId>jakarta.xml.ws</groupId>
                    <artifactId>jakarta.xml.ws-api</artifactId>
                </dependency>

                <dependency>
                    <groupId>com.sun.xml.ws</groupId>
                    <artifactId>jaxws-rt</artifactId>
                    <scope>runtime</scope>
                </dependency>

                <dependency>
                    <groupId>org.glassfish.jaxb</groupId>
                    <artifactId>jaxb-runtime</artifactId>
                </dependency>
            </dependencies>
        </profile>
        <!-- Profile for Legacy Javax version with classifier -->
        <profile>
            <id>javax</id>
            <dependencies>
        <dependency>
            <groupId>org.gcube.core</groupId>
            <artifactId>common-gcore-stubs</artifactId>
            <classifier>javax</classifier>
            <version>3.0.1-SNAPSHOT</version>
        </dependency>

                <dependency>
                    <groupId>org.gcube.resources</groupId>
                    <artifactId>common-gcore-resources</artifactId>
                    <classifier>javax</classifier>
                    <version>3.0.1-SNAPSHOT</version>
                </dependency>

                <dependency>
                    <groupId>org.gcube.core</groupId>
                    <artifactId>common-scope</artifactId>
                    <classifier>javax</classifier>
                    <version>3.0.0-SNAPSHOT</version>
                </dependency>

                <dependency>
                    <groupId>org.gcube.resources.discovery</groupId>
                    <artifactId>discovery-client</artifactId>
                    <classifier>javax</classifier>
                    <version>3.0.0-SNAPSHOT</version>
                </dependency>

                <!-- for jakarta.xml.bind:jakarta.xml.bind-api  -->
                <dependency>
                    <groupId>javax.xml.bind</groupId>
                    <artifactId>jaxb-api</artifactId>
                    <version>2.3.1</version>
                </dependency>

                <!-- for org.glassfish.jaxb:jaxb-runtime -->
                <dependency>
                    <groupId>com.sun.xml.bind</groupId>
                    <artifactId>jaxb-core</artifactId>
                    <version>2.3.0.1</version>
                </dependency>
                <dependency>
                    <groupId>com.sun.xml.bind</groupId>
                    <artifactId>jaxb-impl</artifactId>
                    <version>2.3.0.1</version>
                </dependency>

                <!-- for jakarta.xml.ws-api -->
                <dependency>
                    <groupId>javax.xml.ws</groupId>
                    <artifactId>jaxws-api</artifactId>
                    <version>2.3.1</version>
                </dependency>

                <!-- for com.sun.xml.ws:jaxws-rt -->
                <dependency>
                    <groupId>com.sun.xml.ws</groupId>
                    <artifactId>jaxws-rt</artifactId>
                    <version>2.3.0.2</version>
                    <scope>runtime</scope>
                </dependency>

            </dependencies>
            <build>
                <plugins>
                    <!-- Copy sources to generated directory -->
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-resources-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>copy-sources</id>
                                <phase>initialize</phase>
                                <goals>
                                    <goal>copy-resources</goal>
                                </goals>
                                <configuration>
                                    <outputDirectory>
                                        ${project.build.directory}/generated-sources/javax</outputDirectory>
                                    <resources>
                                        <resource>
                                            <directory>src/main/java</directory>
                                            <filtering>false</filtering>
                                        </resource>
                                    </resources>
                                </configuration>
                            </execution>
                            <execution>
                                <id>copy-test-sources</id>
                                <phase>initialize</phase>
                                <goals>
                                    <goal>copy-resources</goal>
                                </goals>
                                <configuration>
                                    <outputDirectory>
                                        ${project.build.directory}/generated-test-sources/javax</outputDirectory>
                                    <resources>
                                        <resource>
                                            <directory>src/test/java</directory>
                                            <filtering>false</filtering>
                                        </resource>
                                    </resources>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>

                    <!-- Replace Jakarta with Javax in copied sources -->
                    <plugin>
                        <groupId>com.google.code.maven-replacer-plugin</groupId>
                        <artifactId>replacer</artifactId>
                        <version>1.5.3</version>
                        <executions>
                            <execution>
                                <phase>generate-sources</phase>
                                <goals>
                                    <goal>replace</goal>
                                </goals>
                            </execution>
                        </executions>
                        <configuration>
                            <basedir>${project.build.directory}</basedir>
                            <includes>
                                <include>generated-sources/javax/**/*.java</include>
                                <include>generated-test-sources/javax/**/*.java</include>
                            </includes>
                            <replacements>
                                <replacement>
                                    <token>jakarta.xml.bind</token>
                                    <value>javax.xml.bind</value>
                                </replacement>
                                <replacement>
                                    <token>jakarta.xml.ws</token>
                                    <value>javax.xml.ws</value>
                                </replacement>
                                <replacement>
                                    <token>jakarta.xml.soap</token>
                                    <value>javax.xml.soap</value>
                                </replacement>
                            </replacements>
                        </configuration>
                    </plugin>

                    <!-- Configure compiler to use only generated sources -->
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-compiler-plugin</artifactId>
                        <configuration>
                            <compileSourceRoots>
                                <compileSourceRoot>
                                    ${project.build.directory}/generated-sources/javax</compileSourceRoot>
                            </compileSourceRoots>
                            <testCompileSourceRoots>
                                <testCompileSourceRoot>
                                    ${project.build.directory}/generated-test-sources/javax</testCompileSourceRoot>
                            </testCompileSourceRoots>
                        </configuration>
                    </plugin>

                    <!-- Create both main JAR and javax classifier JAR -->
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-jar-plugin</artifactId>
                        <executions>
                            <!-- Main JAR (javax version) -->
                            <execution>
                                <id>default-jar</id>
                                <goals>
                                    <goal>jar</goal>
                                </goals>
                                <configuration>
                                    <classifier></classifier>
                                </configuration>
                            </execution>
                            <!-- Classifier JAR (javax version) -->
                            <execution>
                                <id>javax-jar</id>
                                <goals>
                                    <goal>jar</goal>
                                </goals>
                                <configuration>
                                    <classifier>javax</classifier>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>

                    <!-- Skip javadoc generation for javax profile -->
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-javadoc-plugin</artifactId>
                        <configuration>
                            <skip>true</skip>
                        </configuration>
                    </plugin>

                    <!-- Skip source generation for javax profile -->
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-source-plugin</artifactId>
                        <configuration>
                            <skipSource>true</skipSource>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>

    <build>
        <resources>
            <resource>
                <directory>src/main/resources</directory>
                <filtering>true</filtering>
            </resource>
        </resources>
    </build>
</project>