I would like to use DL4J and ND4J in Java EE app but adding them as dependencies inflates WAR size to the whooping 1.5 Gb. The culprits are the unnecessary platform-specific jar files. And the problem is not only the ND4J itself but also indirect dependencies:
- WEB-INF\lib\hdf5-1.12.1-1.5.7-windows-x86_64.jar
- WEB-INF\lib\javacpp-1.5.7-windows-x86_64.jar
- WEB-INF\lib\leptonica-1.82.0-1.5.7-windows-x86_64.jar
- WEB-INF\lib\mkl-2022.0-1.5.7-windows-x86_64.jar
- WEB-INF\lib\javacpp-1.5.7-windows-x86_64.jar
- WEB-INF\lib\openblas-0.3.19-1.5.7-windows-x86_64.jar
- WEB-INF\lib\ffmpeg-5.0-1.5.7-windows-x86_64.jar
I tried couple of suggestions from the net, but nothing helped.
I added “classifier” in pom:
<dependency>
<groupId>org.nd4j</groupId>
<artifactId>nd4j-native-platform</artifactId>
<version>1.0.0-M2.1</version>
<classifier>windows-x86_64</classifier>
</dependency>
But it resulted in the error:
Could not find artifact org.nd4j:nd4j-native-platform:jar:windows-x86_64:1.0.0-M2.1
I tried to use “-Djavacpp.platform=windows-x86_64” option:
mvn -Djavacpp.platform=windows-x86_64 install
But got an error:
Unknown lifecycle phase ".platform=windows-x86_64".
Could somebody please advise a working solution that will help with inherited dependencies as well?