Differences between revisions 10 and 11
Revision 10 as of 2018-08-13 15:44:50
Size: 3588
Editor: ?MarkusKoschany
Comment:
Revision 11 as of 2018-09-19 22:04:27
Size: 4203
Editor: ?MarkusKoschany
Comment: Add How to find a specific jar file on Debian systems
Deletions are marked like this. Additions are marked like this.
Line 48: Line 48:

== How to find a specific jar file on Debian systems ==

Usually a package name corresponds to a specific jar file. That means you can often find a (build)-dependency by using tools like aptitude or apt. You can also [[https://www.debian.org/distrib/packages | search for packages on debian.org]]. Then there is [[https://codesearch.debian.net/ | codesearch.debian.net]]. Last but not least you can also use [[https://sources.debian.org/ | sources.debian.org]]. For instance you can type "package com.sun.xml.internal.bind.v2.runtime" in https://sources.debian.org to find out what package provides the class.

Translation(s): English

FAQ

How can I use a specific version of OpenJDK to build a package?

Instead of a build-dependency on default-jdk, you can build-depend on openjdk-8-jdk or openjdk-11-jdk. Then you have to make sure JAVA_HOME points to your specific version and not to the default one. You can achieve that by adding

export JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-amd64/

to debian/rules in case you are building the package on amd64.

This is useful for debugging build failures with a non-default JDK. Not build-depending on default-jdk should be avoided though unless there is a very good reason. Otherwise it would make transitions to newer JDK versions more difficult.

[MAVEN] Failed to execute goal [...] dependencies could not be resolved

Failed to execute goal [...] one of its dependencies could not be resolved [...] and the artifact XYZ has not been downloaded from it 

This is a very common error message when you try to package Maven projects. There are multiple possible reasons for this error.

  1. The build-dependency was not added to debian/control. How can you find out wheter a certain jar file is already packaged for Debian? Use codesearch.debian.net or search for packages on https://www.debian.org/distrib/packages. If in doubt ask for help on the debian-java mailing list.

  2. Make sure that all submodules of a Maven project are added to your debian/*.poms file. If the artifact has not been packaged for Debian yet, it is often possible to just ignore a certain submodule.
  3. Check if the Maven coordinates in upstream's pom.xml file match with Debian's system libraries. If they don't, then you have to override groupId/artifactId/version in debian/maven.rules, so that the build system can find them in Debian's local /usr/share/maven-repo directory.

Error: package XYZ does not exist, cannot find symbol

This is also a very common Java error message. The build system tries to compile a *.java file into a *.class file but fails to find a referenced class or method.

  1. Make sure that the class/method which is missing, is imported correctly. The import statement might be outdated or missing completely.
  2. Ensure that the package which contains the missing class/method is referenced in debian/control as a build-dependency.
  3. If this error message occurs after you have successfully packaged your project, it might have been caused by changes to one of your build-dependencies. A newer version might have removed or renamed the class/method. In this case you could either patch the file or maybe a newer upstream version will resolve this issue for you.
  4. Make sure that maven.rules correctly points to the jar file in /usr/share/maven-repo or that the jar file is really on your CLASSPATH (Ant, no-build system)

Unmappable character for encoding US-ASCII

Unfortunately all build systems default to US-ASCII as the default encoding. Some packages contain umlauts or chinese characters that cannot be displayed with the default encoding and thus will cause build failures. You can fix this by

  1. [MAVEN] Adding project.build.sourceEncoding=UTF-8 (or some ISO encoding) to debian/maven.properties.
  2. [ANT] export JAVA_TOOL_OPTIONS=-Dfile.encoding=UTF8 in debian/rules
  3. [jh_build] Pass --javacopts='-encoding UTF-8' or --javadoc-opts='-encoding UTF-8' to jh_build
  4. Patch build.xml, pom.xml or build.gradle

How to find a specific jar file on Debian systems

Usually a package name corresponds to a specific jar file. That means you can often find a (build)-dependency by using tools like aptitude or apt. You can also search for packages on debian.org. Then there is codesearch.debian.net. Last but not least you can also use sources.debian.org. For instance you can type "package com.sun.xml.internal.bind.v2.runtime" in https://sources.debian.org to find out what package provides the class.