<?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>com.atina-connection</groupId>
    <artifactId>JDEGPRCShaded</artifactId>
    <version>1.0.1</version>
    <packaging>jar</packaging>
    <name>JDEGPRCShaded</name>
    <description>Library used by JDE Atina Mulesoft Connector.</description>
    <url>http://www.example.com/example-application</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>
        <io.grpc.version>1.59.1</io.grpc.version>
        <protobuf.version>3.25.8</protobuf.version>
        <maven.jdeps.version>3.1.2</maven.jdeps.version>
        <maven.shade.version>3.5.1</maven.shade.version>
    </properties>

    <licenses>
        <license>
            <name>Apache License, Version 2.0</name>
            <url>https://www.apache.org/licenses/LICENSE-2.0.txt</url>
            <distribution>repo</distribution>
        </license>
    </licenses>

    <scm>
        <connection>scm:git:https://github.com/Atina-Connector/JDEAtinaCreateGRPCShader.git</connection>
        <developerConnection>scm:git:ssh://git@github.com/Atina-Connector/JDEAtinaCreateGRPCShader.git</developerConnection>
        <url>https://github.com/Atina-Connector/JDEAtinaCreateGRPCShader</url>
        <tag>HEAD</tag>
    </scm>

    <developers>
        <developer>
            <id>fjgodino</id>
            <name>Francisco Javier Godino</name>
            <email>fjgodino@gmail.com</email>
            <organization>Atina</organization>
            <organizationUrl>https://www.atina-connection.com</organizationUrl>
        </developer>
    </developers>

    <build>
        
        <extensions>
            <extension>
                <groupId>kr.motd.maven</groupId>
                <artifactId>os-maven-plugin</artifactId>
                <version>1.5.0.Final</version>
            </extension>
        </extensions>
        
        <plugins>
            
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.11.0</version>
            </plugin>

            <!--<plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-plugin-plugin</artifactId>
                <version>3.3</version>
            </plugin>-->

           <!-- Migracion JAVA 11 https://github.com/grpc/grpc-java -->
           
            <plugin>
                <groupId>org.xolstice.maven.plugins</groupId>
                <artifactId>protobuf-maven-plugin</artifactId>
                <version>0.6.1</version>
                <configuration>
                    <protocArtifact>com.google.protobuf:protoc:${protobuf.version}:exe:${os.detected.classifier}</protocArtifact>
                    <pluginId>grpc-java</pluginId>
                    <pluginArtifact>io.grpc:protoc-gen-grpc-java:${io.grpc.version}:exe:${os.detected.classifier}</pluginArtifact>
                </configuration>
                <executions>
                    <execution>
                        <goals>
                            <goal>compile</goal>
                            <goal>compile-custom</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-shade-plugin</artifactId>
                <version>${maven.shade.version}</version>
                <configuration>
                    <createDependencyReducedPom>true</createDependencyReducedPom>
                    <minimizeJar>false</minimizeJar>
                    <createDependencyReducedPom>false</createDependencyReducedPom>
                    <relocations>
                        <!-- ya tenías Guava y Protobuf -->
                        <relocation>
                            <pattern>com.google.common</pattern>
                            <shadedPattern>com.google.shade.common</shadedPattern>
                        </relocation>
                        <relocation>
                            <pattern>com.google.protobuf</pattern>
                            <shadedPattern>com.google.shade.protobuf</shadedPattern>
                        </relocation>
                        <!-- NUEVO: evita que Mule runtime cargue otra copia de gRPC -->
                        <relocation>
                            <pattern>io.grpc</pattern>
                            <shadedPattern>com.google.shade.grpc</shadedPattern>
                        </relocation>
                        <!-- Si tienes advertencias por javax.annotation (Java>17) -->
                        <relocation>
                            <pattern>javax.annotation</pattern>
                            <shadedPattern>com.google.shade.javax.annotation</shadedPattern>
                        </relocation>
                    </relocations>
                    <transformers>
                        <!-- ya tenías ServicesResourceTransformer -->
                        <transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>
                        <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer"/>
                    </transformers>
                </configuration>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals><goal>shade</goal></goals>
                    </execution>
                </executions>
            </plugin>


            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jdeps-plugin</artifactId>
                <version>${maven.jdeps.version}</version>
                <executions>
                    <execution>
                        <id>jdeps-check</id>
                        <phase>verify</phase>          <!-- se dispara después del empaquetado -->
                        <goals>
                            <goal>jdkinternals</goal>
                        </goals>
                        <configuration>
                            <!-- Si pones FALSE, el build FALLA ante cualquier acceso interno -->
                            <failOnWarning>true</failOnWarning>
                            <!-- Ejemplo: solo clases de tu paquete raíz -->
                            <!-- <include>com/atina/**</include> -->
                            <!-- Ejemplo: modo recursivo (equivale a jdeps -R) -->
                            <!-- <recursive>true</recursive> -->
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <!-- Asegura que no usas APIs >1.8 -->

            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>animal-sniffer-maven-plugin</artifactId>
                <version>1.23</version>
                <executions>
                    <execution>
                        <id>check-java8-api</id>
                        <phase>verify</phase>
                        <goals><goal>check</goal></goals>
                        <configuration>
                            <signature>
                                <groupId>org.codehaus.mojo.signature</groupId>
                                <artifactId>java18</artifactId>
                                <version>1.0</version>
                            </signature>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

        </plugins>

    </build>
    
    <dependencies>
          
        <!-- io.grpc  -->
        
        <dependency>
            <groupId>io.grpc</groupId>
            <artifactId>grpc-netty-shaded</artifactId>
            <version>${io.grpc.version}</version>
        </dependency>
        
        <dependency>
            <groupId>io.grpc</groupId>
            <artifactId>grpc-protobuf</artifactId>
            <version>${io.grpc.version}</version>
            <exclusions>
                <exclusion>
                    <groupId>com.google.protobuf</groupId>
                    <artifactId>protobuf-java</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

        <dependency>
            <groupId>com.google.protobuf</groupId>
            <artifactId>protobuf-java</artifactId>
            <version>${protobuf.version}</version>
        </dependency>
        
        <dependency>
            <groupId>io.grpc</groupId>
            <artifactId>grpc-stub</artifactId>
            <version>${io.grpc.version}</version>
        </dependency>

        <!-- Migracion JAVA 11 https://github.com/grpc/grpc-java -->
        <dependency> <!-- necessary for Java 9+ -->
          <groupId>org.apache.tomcat</groupId>
          <artifactId>annotations-api</artifactId>
          <version>6.0.53</version>
          <scope>provided</scope>
        </dependency>

    </dependencies>

    <profiles>
        <!-- Perfil encriptacion-activa: se mantiene la versión 1.0.0 y no se agrega sufijo -->
        <profile>

            <id>jfrog</id>


            <activation>
                <activeByDefault>true</activeByDefault>
            </activation>

            <repositories>

                <repository>
                    <id>central</id>
                    <url>https://repo1.maven.org/maven2</url>
                    <releases>
                        <enabled>true</enabled>
                    </releases>
                    <snapshots>
                        <enabled>false</enabled>
                    </snapshots>
                </repository>

            </repositories>

            <distributionManagement>

                <repository>
                    <id>AcquaNet-central</id>
                    <name>jfrog-releases</name>
                    <url>https://jfrog.atina-connection.com/artifactory/libs-release-local</url>
                </repository>

                <snapshotRepository>
                    <id>acquanet-snapshots</id>
                    <url>https://jfrog.atina-connection.com/artifactory/libs-snapshot</url>
                </snapshotRepository>

            </distributionManagement>

        </profile>

        <!-- Perfil encriptacion-desactiva: se agrega el sufijo -SNAPSHOT y se actualiza la versión a 1.0.0-SNAPSHOT -->
        <profile>
            <id>central</id>
            <build>
                <plugins>
                    <!-- Sources JAR -->
                    <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</goal></goals>
                            </execution>
                        </executions>
                    </plugin>

                    <!-- Javadoc JAR -->
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-javadoc-plugin</artifactId>
                        <version>3.10.0</version>
                        <executions>
                            <execution>
                                <id>attach-javadocs</id>
                                <goals><goal>jar</goal></goals>
                            </execution>
                        </executions>
                        <!-- Opcional: evitar fallas por doclint en JDK8 -->
                        <configuration>
                            <additionalJOptions>
                                <additionalJOption>-Xdoclint:none</additionalJOption>
                            </additionalJOptions>
                        </configuration>
                    </plugin>

                    <!-- GPG signing -->
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-gpg-plugin</artifactId>
                        <version>3.2.4</version>
                        <executions>
                            <execution>
                                <id>sign-artifacts</id>
                                <phase>verify</phase>
                                <goals><goal>sign</goal></goals>
                                <configuration>
                                    <gpgArguments>
                                        <arg>--pinentry-mode</arg>
                                        <arg>loopback</arg>
                                    </gpgArguments>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>

                    <!-- Central Publishing -->
                    <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>
                            <waitUntil>published</waitUntil>
                        </configuration>
                    </plugin>
                </plugins>
            </build>

            <distributionManagement>
                <snapshotRepository>
                    <id>ossrh</id>
                    <url>https://s01.oss.sonatype.org/content/repositories/snapshots</url>
                </snapshotRepository>
                <repository>
                    <id>ossrh</id>
                    <url>https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/</url>
                </repository>
            </distributionManagement>
        </profile>
    </profiles>
</project>