<?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 和 artifactId -->
    <groupId>com.icetech</groupId>
    <artifactId>bouncycastle-156</artifactId>
    <version>1.0.1</version>
    <packaging>jar</packaging>

    <dependencies>
        <!-- 要重打包的目标版本 bcprov -->
        <dependency>
            <groupId>org.bouncycastle</groupId>
            <artifactId>bcpkix-jdk15on</artifactId>
            <version>1.65</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>org.bouncycastle</groupId>
            <artifactId>bcprov-jdk15on</artifactId>
            <version>1.65</version>
            <scope>compile</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-shade-plugin</artifactId>
                <version>3.5.1</version>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>shade</goal>
                        </goals>
                        <configuration>
                            <!-- 核心1：包重定向，把 bc 原生包名改成自定义包名 -->
                            <relocations>
                                <relocation>
                                    <!-- 原生包前缀 -->
                                    <pattern>org.bouncycastle</pattern>
                                    <!-- 重命名后的自定义包前缀，建议带上版本号区分 -->
                                    <shadedPattern>com.icetech.bc165.org.bouncycastle</shadedPattern>
                                </relocation>
                            </relocations>

                            <!-- 核心2：生成精简依赖的pom，避免传递原生bcprov造成冲突 -->
                            <createDependencyReducedPom>true</createDependencyReducedPom>
                            <!-- 可选：把精简pom命名为原pom名，安装到仓库时默认使用 -->
                            <dependencyReducedPomLocation>${project.build.directory}/dependency-reduced-pom.xml</dependencyReducedPomLocation>

                            <!-- 可选：排除META-INF里的签名文件，避免运行时校验报错 -->
                            <filters>
                                <filter>
                                    <artifact>*:*</artifact>
                                    <excludes>
                                        <exclude>META-INF/*.SF</exclude>
                                        <exclude>META-INF/*.DSA</exclude>
                                        <exclude>META-INF/*.RSA</exclude>
                                    </excludes>
                                </filter>
                            </filters>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>