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

I use maven for Eclipse to create a jar that will work on a remote server. OS X is running on my system; CestOS is running on the server. For the project I need a tensor flow library . Maven successfully resolves dependencies, so I can run the project locally. However, on the server I get the error that the tensorflow library does not exist, because by default maven only includes the macosx version. How can I get maven to replace the macosx version of the tensor stream with the linux version during build?

TensorFlow java libraries for different platforms can be found here .

PS I have already tried adding a dependency to pom with a system area pointing to jar.

+4
source share
2 answers

Try in 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-x86if your server is 32-bit.

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

0
source

Judging by the jar names on the page you linked, the difference between MacOs and Linux versions lies in the text after the part versionon the banner name.

This is called classifier(see Maven coordinates ) and is an optional coordinate that provides additional differentiation after the artifact version.

nandsito, , (, , ):

<profiles>
    <profile>
        <id>osx</id>

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

    </profile>

    <profile>
        <id>linux</id>

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

    </profile>

</profiles>

<dependency> POM ( <profiles> tensorflow) .

( POM ): MacOS mvn clean package -Pmacos Centos mvn clean package -Plinux

Eclipse Project properties > Maven ( , Project explorer.

0

Source: https://habr.com/ru/post/1660436/


All Articles