TechCrunch
TechCrunch

Reputation: 3134

Include a Jar in Maven Project based on Operating System

I'm using a third party software in my Maven Project. The API calls are same for both Windows and Mac OS but the JAR files are different. Is there a way to identify the operating system at run-time and load appropriate jar from my lib folder in a Maven Project ? I want to be able to provide this final executable Jar to my client who may use my final Jar in an Windows or Mac OS and should be able to work on it by including my Jar in his project. For now, my client is including the Jar in his class path which seems as a horrible way of doing.

Upvotes: 0

Views: 259

Answers (2)

Mysterion
Mysterion

Reputation: 9320

It could be nicely done by using Maven profiles and activation feature

<profiles>
    <profile>
        <id>windows-x86_64</id>
        <activation>
            <os>
                <family>windows</family>
                <arch>amd64</arch>
            </os>
        </activation>            
    </profile>

    <profile>
        <id>windows-x86</id>
        <activation>
            <os>
                <family>windows</family>
                <arch>x86</arch>
            </os>
        </activation>
    </profile>

In this profiles you could set up custom properties, custom dependencies, etc.

Upvotes: 1

user3159253
user3159253

Reputation: 17455

Likely you need Maven NAR Plugin or may be use profiles depending on the actual content of system-specific parts

Upvotes: 0

Related Questions