Search code examples
javamavennd4j

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


I want to use the project from nd4j-cuda-10.2. it has jar files for two Operating Systems, Linux and Windows. than How can I exclude the jar from Linux when using a windows system and vice versa?.

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

due to the weight of the jar files. I want to exclude files that are not useful to each operating system. Is this possible?.

I mean, I would like maven to download the file "nd4j-cuda-10.2-1.0.0-beta7-linux-ppc64le.jar" only when it be on a linux system and the file "nd4j-cuda-10.2-1.0.0-beta7-windows-x86_64.jar" when on a system windows.

Part of 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> 

I have worked a bit on the profiles for each operating system because I have found that it is the correct way to do it but it is not enough, I attach a bit of the code from my file, I appreciate your collaboration, any contribution is highly valued.


Solution

  • Check if there are separate artifacts/maven dependencies that you could refer to. A quick check revealed there is something like https://mvnrepository.com/artifact/org.nd4j/jcuda-windows64.