Hello Guillaume, [ I assume you are not subscribed to debian-java, hence I will CC you ] On 24.05.2015 22:31, Guillaume Turri wrote: > Hi, > > Context > ======= > > There's a Java application I've been working on during the last few > years [1], and I'd like to package it. (It also uses two dependencies > [2][3] which aren't available in a debian package, so I should also > package them). > > I'm new to Debian packaging, so I've spent the last few days reading > documentation and experimenting. Now I'm nearly able to package my > application and its dependencies, but there are some things that I don't > understand yet. > > To complete the overview, I should add that, my application builds with > Maven. One of its dependency builds with Gradle. And the other with Ant. First of all thanks for your interest in packaging your application for Debian. I think this e-mail is also a wake-up call to improve the documentation for packaging Java software for Debian. :) You can find some older information here: https://wiki.debian.org/Java/Packaging and there are also a few examples but they should be updated, really https://pkg-java.alioth.debian.org/examples/ > In short > ======== > In short, my main questions are: > > 1- Is it ok to package each of those 3 projects with jh_helper? In short: Yes, it is but.... I believe it will be easier for you to package your application with Maven. I assume you are familiar with it, then there is no reason to switch to jh_ helpers. You should take a look at Debian packages that use "maven-debian-helper". Just install this package on your system and run "mh_make" in the source directory of your application which contains the pom.xml file. That should further you. > 2- My application should be usable as an executable, but it would also > make sense to provide this jar as a library. Is there a standard way to > handle it? Yes, this is possible. I don't know your application yet but you could provide two binary packages from the same sources. The first one installs a wrapper script that executes your jar file. This is basically your application. The other binary package is your library. maven-debian-helper will help you to install the jar file to the correct system paths. (/usr/share/java, and the /usr/share/maven-repo/ directories) > 3- How can I force compilation with java7, using java helper? You can use jh_build for that by using --javacopts . See also /usr/share/doc/javahelper/tutorial.txt.gz. However I suggest to use maven-debian-helper, then you can simply force the compilation target with a maven.properties file. > 4- What is the standard way to avoid shipping unit tests in package > built with java helper? If you use maven-debian-helper, the proper way would be to disable the tests in maven.properties with maven.test.skip=true. If I recall correctly there is no specific option in javahelper for disabling unit tests. > In details > ========== > > With a bit more details, my questions are: > > 1- I've seen that there are several packaging tools for Java. In > particular I've tried maven helper and java helper; and I've seen > there's also a ad hoc tool for projects built with ant. > Since I want to build 3 projects which each use a different build > system, it seems to me it would be easier to use jh_helper for each (and > to let jh_build take care of their compilations). > Is it ok to do it, or are there any drawbacks? In fact jh_build is a very simplistic way to build Java packages. It is well suited for simple packages but I suggest to use more sophisticated tools like maven-debian-helper for Maven projects or javahelper + maven-repo-helper for Ant projects. > > 2- As far as I've understood, if my jar is supposed to be used as a > library, it should be installed in /usr/share/java. But when I create an > application package with jh_makepkg, my jar is installed in > /usr/share/<my-application>/<my-application>.jar > I can think of a workaround: create a library package, and create > another package with an executable script that would launch this jar. > Is there a better way to handle this case? I think in your case it makes sense to create two binary packages, one library package and another one which installs the wrapper to launch your application. > > 3- With jh_build, I can force compilation with java7 (with `jh_build > -o'-source 1.7'). > However, I don't understand how I can pass this option when I launch the > "debuild" command. So it ends up calling jh_build without this option, > and the build fails. > I've seen I can specify to jh_makepkg that I want to build with opendjdk > 7. As far as I understand, it sets JAVA_HOME accordingly. However, when > jh_build is called without arguments, it then calls javac with flag > '-source 1.5' (so my build fails). > How can I ensure javac will try to compile as java 7? debuild will execute everything in debian/rules, so it should be possible to use jh_build with javacopts here. > 4- By default, jh_build will compile each java file it finds. So it ends > up compiling tests (which bloats the jar I get in my .deb; and which > adds an unneeded dependency on junit). > A workaround would be to remove each test files from the upstream > tarball. Is it an acceptable way to do it, or is there a more standard way? > > Many thanks for your replies! You should try the following: 1. First ensure that all your dependencies already exist in Debian. 2. If not package them separately but use higher level tools like maven-debian-helper, maven-repo-helper + javahelper. Some example packages: Maven-based library: https://anonscm.debian.org/cgit/pkg-java/jboss-logmanager.git Ant-based application: http://anonscm.debian.org/cgit/collab-maint/mediathekview.git Ant-based library: https://anonscm.debian.org/cgit/pkg-java/libjide-oss-java.git Hope that helps a little Regards, Markus
Attachment:
signature.asc
Description: OpenPGP digital signature