How to package a Maven Java application for Debian?
1
vote
0
answers
462
views
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:
* https://wiki.debian.org/Java/Packaging/Maven
* https://wiki.debian.org/Java/MavenRepoHelper
* https://wiki.debian.org/Java/Packaging
* https://www.youtube.com/watch?v=p767bS_8C_o
* And more which I am forgetting now
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
2. How do I set the lib/
prefix to the classpath generated by Maven? I have currently solved this by adding a lib/
in the POM but I would prefer to set it as part of the packaging process as it is a Debian-specific change.
3. How do I link the shared lib to my app? Currently, I am thinking:
- Install it as usual with another .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?
Asked by Slav
(111 rep)
May 2, 2023, 02:30 PM
Last activity: May 2, 2023, 05:07 PM
Last activity: May 2, 2023, 05:07 PM