# Limit native dependencies to one platform on SBT

**URL:** <https://community.konduit.ai/t/limit-native-dependencies-to-one-platform-on-sbt/2005>\
**Category:** DL4J\
**Created:** [September 6, 2022, 6:44pm UTC](https://community.konduit.ai/t/limit-native-dependencies-to-one-platform-on-sbt/2005 "2022-09-06T18:44:03Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![jdo](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.konduit.ai/jdo/32/900_2.png) [@jdo](https://community.konduit.ai/u/jdo)\
**Post date:** [September 6, 2022, 6:44pm UTC](https://community.konduit.ai/t/limit-native-dependencies-to-one-platform-on-sbt/2005/1 "2022-09-06T18:44:03Z")

</div>

Hi,

Im aware of the recent similar solved/closed [Limit native dependencies to one platform - #3 by sogawa-sps](https://community.konduit.ai/t/limit-native-dependencies-to-one-platform/1998/3) - but for me its about SBT and I have a open Stackoverflow issue on that here:

> <https://stackoverflow.com/questions/73546888/avoid-platform-specific-dependencies-in-sbt-packagebin>

In short: My `sbt universal:packageBin` also packs up all platform dependent jars instead of the few Im interested in and on SBT I cant exclude them.  
I also followed the hint to NOT depend on “nd4j-native-platform-1.0.0-M2”, but e.g “nd4j-native-1.0.0-M1-linux-x86\_64” … but that saves only the nd4j-native jars. The other ones: javacpp-platform , hdf5-platform , openblas-platform , opencv-platform I still get pulled in in all variants through transitive dependencies that I dont control.

I can re-post the full stackoverflow issue here, if thats preferred.

Thanks for any help

---

<div class="post-metadata">

**Author:** ![agibsonccc](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.konduit.ai/agibsonccc/32/697_2.png) [@agibsonccc](https://community.konduit.ai/u/agibsonccc)\
**Post date:** [September 7, 2022, 1:06am UTC](https://community.konduit.ai/t/limit-native-dependencies-to-one-platform-on-sbt/2005/2 "2022-09-07T01:06:33Z")

</div>

@jdo could you try setting javacpp.platform via a system property in sbt like: [scala - How do I set a system property for my project in sbt? - Stack Overflow](https://stackoverflow.com/questions/3127007/how-do-i-set-a-system-property-for-my-project-in-sbt)

Sorry I’m not as familiar with SBT’s internals but I do believe there’s a way to do it.

---

<div class="post-metadata">

**Author:** ![jdo](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.konduit.ai/jdo/32/900_2.png) [@jdo](https://community.konduit.ai/u/jdo)\
**Post date:** [September 7, 2022, 8:27pm UTC](https://community.konduit.ai/t/limit-native-dependencies-to-one-platform-on-sbt/2005/3 "2022-09-07T20:27:45Z")

</div>

Hi @agibsonccc , thanks for the reply. I added

```auto
javacOptions ++= Seq("-J-Djavacpp.platform=windows-x86_64")

```

into the build.sbt but it doesnt do any difference and the fat-jar outcome still contains all platforms. To my understanding (from [GitHub - bytedeco/javacpp-presets: The missing Java distribution of native C++ libraries](https://github.com/bytedeco/javacpp-presets) & [Reducing the Number of Dependencies · bytedeco/javacpp-presets Wiki · GitHub](https://github.com/bytedeco/javacpp-presets/wiki/Reducing-the-Number-of-Dependencies)) this is a maven only trick and I already tried before the hinted “SBT-JavaCV”.

Just for my understanding - from pure (SBT) dependency management perspective there is no way to exclude them? (So basically SBT is not to blame)  
The way the artifacts are declared, they will pull in all those platforms and the only way to control this is not via common dependency management declarations, but the specific (maven-first) tool that all those “org.bytedeco.\*” libraries share ?

PS: just for the dimensions: a sibling module (same PlayFramework base, actually more business logic inside) has ~ 150 MB of gziped fatjar size. This one with the deeplearning4j dependency and a more narrow functional scope comes in at 1.2 GB gziped. The immediate problem is actually that is breaks the build pipeline now because of memory constrains.

---

<div class="post-metadata">

**Author:** ![agibsonccc](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.konduit.ai/agibsonccc/32/697_2.png) [@agibsonccc](https://community.konduit.ai/u/agibsonccc)\
**Post date:** [September 8, 2022, 5:59am UTC](https://community.konduit.ai/t/limit-native-dependencies-to-one-platform-on-sbt/2005/4 "2022-09-08T05:59:24Z")

</div>

@jdo thanks for confirming. Try following the instructions here: [GitHub - bytedeco/sbt-javacpp: Use JavaCPP and JavaCPP presets with ease. Base plugin for JavaCPP-related projects.](https://github.com/bytedeco/sbt-javacpp) It looks like the plugin should handle that for you. I think Sam gave you the right advice following this here: [Reducing the Number of Dependencies · bytedeco/javacpp-presets Wiki · GitHub](https://github.com/bytedeco/javacpp-presets/wiki/Reducing-the-Number-of-Dependencies)

---

<div class="post-metadata">

**Author:** ![jdo](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.konduit.ai/jdo/32/900_2.png) [@jdo](https://community.konduit.ai/u/jdo)\
**Post date:** [September 8, 2022, 10:20pm UTC](https://community.konduit.ai/t/limit-native-dependencies-to-one-platform-on-sbt/2005/5 "2022-09-08T22:20:05Z")

</div>

I think I solved it for my specific case. I could not get the “_SBT-JavaCV_” plugin to work. In short, I managed via plain SBT and excluded first all "_org.bytedeco.xyz-platform_ " dependencies from my direct dependency “_org.deeplearning4j.deeplearning4j-nlp:1.0.0-M2_” and in a second step added explicitly the platform specific variants back that I need (via “classifier”).

The details are in [java - Avoid platform specific dependencies in SBT packageBin - Stack Overflow](https://stackoverflow.com/questions/73546888/avoid-platform-specific-dependencies-in-sbt-packagebin/73655486#73655486)
