如何从 Maven 存储库中的依赖项中排除特定的 jar

how to exclude specific jars from a dependency in a maven repository

我想使用 nd4j-cuda-10.2 的项目。它有两个操作系统的 jar 文件,Linux 和 Windows。比使用 windows 系统时如何从 Linux 中排除 jar,反之亦然?

[Maven 存储库][1] [1]: https://repo1.maven.org/maven2/org/nd4j/nd4j-cuda-10.2/1.0.0-beta7/

由于 jar 文件的重量。我想排除对每个操作系统都没有用的文件。这可能吗?

我的意思是,我想让maven下载文件 “nd4j-cuda-10.2-1.0.0-beta7-linux-ppc64le.jar”仅当它在 linux 系统和文件上时“nd4j-cuda-10.2-1.0.0-beta7-windows-x86_64.jar”在系统 windows.

pom.xml的一部分:

     <profile>
            <id>Windows_Profile</id>
            <activation>
                <os>
                    <name>windows 10</name>
                    <family>Windows</family>
                    <arch>amd64</arch>
                </os>
            </activation>
            <dependencies>
                <dependency>
                    <groupId>org.nd4j</groupId>
                    <artifactId>nd4j-cuda-10.2-platform</artifactId>
                    <version>${nd4j.version}</version>
                    <classifier></classifier>
                </dependency>
                <dependency>
                    <groupId>org.deeplearning4j</groupId>
                    <artifactId>deeplearning4j-cuda-10.2</artifactId>
                    <version>1.0.0-beta7</version>
                    <exclusions>
                        <exclusion>
                            <groupId></groupId>
                            <artifactId></artifactId>
                        </exclusion>
                    </exclusions>
                </dependency>
            </dependencies>
        </profile> 

我对每个操作系统的配置文件做了一些工作,因为我发现这是正确的方法,但这还不够,我附上了我文件中的一些代码,感谢您合作,任何贡献都受到高度重视。

检查是否有单独的 artifacts/maven 依赖项可供您参考。快速检查发现有类似 https://mvnrepository.com/artifact/org.nd4j/jcuda-windows64.

的内容