Differences between revisions 19 and 20
Revision 19 as of 2018-08-02 04:14:35
Size: 5044
Editor: ?MarkusKoschany
Comment:
Revision 20 as of 2018-08-02 07:44:10
Size: 3785
Editor: ?MarkusKoschany
Comment: More Java/Packaging clean up
Deletions are marked like this. Additions are marked like this.
Line 23: Line 23:
The idea behind javahelper is that most Java packages should be trivial. The integration with DH7 means that you shouldn't need anything in debian/rules, just a few files under the debian directory. To demonstrate this there are a selection of [[http://pkg-java.alioth.debian.org/examples/|sample demo packages]] available showing a complete debian/ directory for a few simple types of package.

Alternatively you might want to look at one of the [[Java/ExamplePackages|good examples of up to date packages]].
The idea behind javahelper is that most Java packages should be trivial. The integration with debhelper and the dh sequencer means that you shouldn't need anything in debian/rules, just a few files under the debian directory.
Line 39: Line 37:


== Java compilation 1x1 ==

This section explains the basic terms and methods to compile Java source files into bytecode and the creation of jar files.

== No build system ==

There are some upstream projects that don't provide a proper build system. In some cases it is useful to download source packages from Maven Central and in those cases they also come with no build system, just source code. For all those reasons Javahelper is the perfect tool to compile the code and create a proper Debian package.
Line 55: Line 62:

=== jh_build ===

jh_build is a very simple build system provided by javahelper for packages which don't come with an upstream build system or come with a broken one. It's described in the examples and the javahelper documentation referred to above.

=== Other build systems ===

If you have a different build system, or need to do something special with one of the build systems above, then you will need to add an override_dh_auto_build target to your debian/rules which will do whatever is necessary.

== Things you need to do ==

There are a few things you do need to do in your package which javahelper can't do for you.

=== Package names ===

Naming convention
## help FIXME
Close to upstream

=== Cleaning upstream ===

`debian/copyright` can `exclude`

=== Classpath ===

... help ...
=== Version Control System ===
See [[Java/JavaVCS| VCS a.k.a. Source Code Management]]
for guidence on version control system.

== References ==

 * [[http://pkg-java.alioth.debian.org/docs/tutorial.html|javahelper documentation]] broken, pkg-java.alioth
 * [[http://pkg-java.alioth.debian.org/docs/debconf10-javahelper-slides.pdf|javahelper DC10 talk slides]] broken, pkg-java.alioth
 * [[http://pkg-java.alioth.debian.org/docs/debconf10-javahelper-paper.pdf|javahelper DC10 paper]] broken, pkg-java.alioth
 * [[http://pkg-java.alioth.debian.org/examples/|Sample demo packages]] broken, pkg-java.alioth
 * [[Java/ExamplePackages|Good packaging examples]]

Translation(s): English ~ español

Introduction

In addition to the normal debhelper packaging tools there are some additional tools specifically for dealing with Java packages. Javahelper for packages without sane build systems and in combination with build systems to make them Debian compliant, maven-repo-helper for adding Maven artifacts to a non-Maven package, maven-debian-helper as the primary helper tool for any Maven project and gradle-debian-helper for Gradle-based projects. This page will inform you about common Java packaging workflows in Debian and point you to real-life examples which can be used as a starting point for your own packages.

Java Policy

Java packages in Debian abide like all other packages by the Debian Policy. Java-specific Policy elements are documented in the Debian policy for Java.

Javahelper

Javahelper is documented in the javahelper package in /usr/share/doc/javahelper/tutorial.txt.gz, also replicated here.

In addition to the tutorial, a talk was given at DebConf10 covering the use of javahelper. The talk is available as:

The idea behind javahelper is that most Java packages should be trivial. The integration with debhelper and the dh sequencer means that you shouldn't need anything in debian/rules, just a few files under the debian directory.

Using javahelper and DH7 ideally your rules file will look like this:

JAVA_HOME=/usr/lib/jvm/default-java

%:
        dh $@ --with javahelper

All of the work is done by javahelper working from other files under debian/.

Java compilation 1x1

This section explains the basic terms and methods to compile Java source files into bytecode and the creation of jar files.

No build system

There are some upstream projects that don't provide a proper build system. In some cases it is useful to download source packages from Maven Central and in those cases they also come with no build system, just source code. For all those reasons Javahelper is the perfect tool to compile the code and create a proper Debian package.

Build systems

There are a few build systems in use by Java programs.

Ant

If your package uses Ant then DH7 should automatically detect the build.xml and call things appropriately.

Maven

Use maven-debian-helper for standard Maven projects, use maven-repo-helper and maven-ant-helper to fallback the build to Ant - usefull mostly for building a library which is part of the Build-Depends of Maven itself.

Gradle

Use gradle-debian-helper. Gradle is a flexible project so you may need to patch the build scripts anyway. This helper is currently in early stage so if you do not want to use it, you can follow the example of Gradle itself, or from the list of packages using gradle as mentioned here.