clapas
clapas

Reputation: 1846

How to create maven artifact for different platforms, i.e. needs system libraries

I have a JAR file which I want to add to my maven 2 repository as an artifact. The JAR depends on system libraries specific for each platform, e.g. .dll on Windows, .so on Linux, etc.

How should I create the artifact so that users from different platforms can use the JAR?

Upvotes: 0

Views: 92

Answers (1)

Zilvinas
Zilvinas

Reputation: 5578

If your JAR is a library that you expect to be included into other projects, then you can create maven profiles that can be activated based on a system and add whatever required system dependencies there.

<profiles>
  <profile>
    <activation>
      <os>
        <name>Windows XP</name>
        <family>Windows</family>
        <arch>x86</arch>
        <version>5.1.2600</version>
      </os>
    </activation>
    ...
  </profile>
</profiles>

However, if you are making an executable JAR then it's quite a different story.

There are many ways you can do this, not all are easy. If you know what you are looking for ( name of a DLL or SO lib ), then you could make a startup script to:

  1. Try finding one in the class path
  2. Try finding one in the system path
  3. Try finding one in "default" / "most expected" location(s)
  4. Search for a .config file having the file location
  5. Ask user to enter the path to the file

Some apps do all all of these steps, some do a few or just one. I would like to know if there is a better way too :)

Upvotes: 1

Related Questions