javagradledependenciesjavacv

Add JavaCV as a dependency, to run on a Raspberry PI?


JavaCV documentation says I should use this to add JavaCV as a dependency to my project;

dependencies {
    implementation group: 'org.bytedeco', name: 'javacv-platform', version: '1.5.4'
}

The problem with this is that this includes all kinds of crap like runtime libs for Mac, Android, Windows, etc.

Which dependencies do I need to use JavaCV in my project, in a more non-bloated fashion?


Solution

  • After some research I've found that this is easily done using the "platform plugin of Gradle JavaCPP":

    http://bytedeco.org/builds/

    https://github.com/bytedeco/gradle-javacpp#the-platform-plugin

    Using said plugin you can specify the target platform with : gradle -PjavacppPlatform=linux-armhf and only the needed platform dependencies will be used.

    You also can look at the example:

    https://github.com/bytedeco/gradle-javacpp/tree/master/samples/javacv-demo

    I've tried building the example and a uber-jar of "only" around 100Mb is generated.

    I think you could also add some exclusions to eliminate unneeded libs and further reduce the size of the jar.