1

I am trying to package a Java application that is built with Maven.

I created the debian/ folder with mh_make and I have been reading/watching the tutorials:

The project structure is as follows:

  • parent POM
  • my_app submodule
  • my_app_lib submodule (used exclusively by my_app)
  • shared_lib submodule (used by my_app but may also be needed by other apps)

I am trying to create two deb packages, which will:

  • Install my_app and its lib in /usr/share/my-app (package 1)
  • Install the shared lib in /usr/share/java (package 2)

I am at the point where I have created part of package 1:

  • Installed my app's main jar in /usr/share/my-app/my-app.jar and its dependency lib jar /usr/share/my-app/lib/my-lib.jar (via my-app.install)
  • Created a launch script /usr/share/my-app/bin/my-app and symlinked it to /usr/bin (via my-app.install and my-app.links)

In the POM I also set the main class and instructed Maven to add a classpath in the jar's manifest.

My questions:

  1. How do I force the mh_* scripts to not install the my_app or my_app_lib artifacts and POMs in the /usr/share/maven-repo or /usr/share/java dirs? My poms file for reference:
# The setup below does not work - my_app and my_app_lib are installed in /usr/share/maven-repo
pom.xml --ignore-pom
my_app/pom.xml --has-package-version --ignore-pom --no-usj-versionless --dest-jar=/usr/share/my_app/my_app.jar
my_app_lib/pom.xml --has-package-version --ignore-pom
lshared_lib/pom.xml --ignore
  1. How do I set the lib/ prefix to the classpath generated by Maven? I have currently solved this by adding a <classpathPrefix>lib/</classpathPrefix> in the POM but I would prefer to set it as part of the packaging process as it is a Debian-specific change.
  2. How do I link the shared lib to my app? Currently, I am thinking:
  • Install it as usual with another <package>.poms

  • Add dependency on the lib binary package to the my-app binary package

  • Add a symlink between /usr/share/my-app/lib/shared-lib.jar and /usr/share/java/shared-lib.jar in my-app.links

    Would that work? Can I build a second binary package from the same source package? Is this the correct way of doing this?

Slav
  • 11
  • 2

0 Answers0