Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to build a jar with maven for a specific OS?

I am using maven for Eclipse to build a jar that will run on a remote server. My system is running OS X, the server is running CestOS. For the project I need tensorflow library. Maven successfully resolves dependencies so I am able to run the project locally. However, on the server I am getting error that tensorflow library is not there because by default maven includes only macosx version. How can I force maven to substitute macosx version of tensorflow by the linux version during build?

TensorFlow java libraries for different platforms can be found here.

P.S. I already tried adding a dependency in pom with the system scope pointing to jar.

like image 951
Little Owl Avatar asked Nov 10 '16 19:11

Little Owl


People also ask

How do I create an executable jar from Maven?

In order to compile the project into an executable jar, please run Maven with mvn clean package command.

Does Maven create a jar file?

The Maven JAR plugin builds your Maven project as a JAR file, including the resources generated by the BND Maven plugin. The above configuration also sets the default project MANIFEST. MF file path for your project, which is essential when packaging your module using the BND Maven plugin.


1 Answers

Try this in your POM:

<dependency>
    <groupId>org.bytedeco.javacpp-presets</groupId>
    <artifactId>tensorflow</artifactId>
    <version>0.9.0-1.2</version>
</dependency>
<dependency>
    <groupId>org.bytedeco.javacpp-presets</groupId>
    <artifactId>tensorflow</artifactId>
    <version>0.9.0-1.2</version>
    <classifier>linux-x86_64</classifier>
</dependency>

Or linux-x86 instead, if your server is 32-bit.

Of course, defining a conditional dependency with profiles would be nice.

like image 145
nandsito Avatar answered Sep 18 '22 12:09

nandsito