These guidelines are laid out in order of relevance to packaging.
This page represents Fedora guidelines for packaging libraries and applications written in Java and related languages using Java Virtual Machine as bytecode interpreter. It DOES NOT aim to extensively describe packaging techniques and tips. RPM macros and commands used here are documented in man pages. Furthermore a separate Java Packaging HOWTO describes Java packaging techniques in detail and includes examples, templates and documentation aimed at packagers and Java developers who are taking their first steps in Java RPM packaging.
Fedora Java packaging is originally based on JPackage Project standards. Over time we have diverged in packaging tools in most areas but we mostly keep backward compatibility with older packages that make use of JPackage standards.
Packages MUST follow the standard Fedora package naming guidelines.
Java API documentation MUST be placed into a sub-package called %{name}-javadoc
.
Packages MUST follow the standard Fedora package versioning guidelines.
Packages MUST follow the standard Fedora dependency bundling guidelines.
In particular *.class
and *.jar
files from upstream releases MUST NOT be used during build of Fedora packages and they MUST NOT be included in binary RPM.
The following applies to all JAR files except JNI-using JAR files and application-specific JAR files (ie. JAR files that can only reasonably be used as part of an application and therefore constitute application-private data).
If a project offers the choice of packaging it as a single monolithic JAR or several ones, the split packaging SHOULD be preferred.
%{_javadir}
or its subdirectory.%{name}.jar
.%{name}
subdirectory*-%{version}.jar
) MUST NOT be installed unless the package is a compatibility packageJava packages MUST BuildRequire their respective build system:
BuildRequires:
maven-local
for packages built with MavenBuildRequires:
ant
for packages built with antBuildRequires:
java-devel
for packages built with javacJava binary packages or their dependencies MUST have Requires (generated by RPM or manual) on:
java-headless
or java-headless
>=
1:minimal_required_version
javapackages-tools
If java-headless requirement is insufficient package MUST have Requires:
java
or java
>=
1:minimal_required_version
%{_javadocdir}/%{name}
as part of javadoc subpackage%{_javadocdir}/%{name}-%{version}
SHOULD NOT exist.noarch
even if main package is architecture specific.class-path
entry inside META-INF/MANIFEST.MFPackages MUST NOT hardcode paths to JAR files they use. When package needs to reference a JAR file, packager SHOULD use one of tools designed to locating JAR files in the system.
If upstream project is shipping Maven pom.xml
files, these MUST be installed. Additionally package MUST install mapping between upstream artifact and filesystem by using either %mvn_install
or %add_maven_depmap
macros.
If upstream project does not ship Maven pom.xml
file, official maven repository should be searched and if there are pom.xml
files they SHOULD be installed.
If modifications to Maven pom.xml files are needed %pom_*
family of macros SHOULD be used
Applications wishing to provide a convenient method of execution SHOULD provide a wrapper script in %{_bindir}
. Packages SHOULD use %jpackage_script
to create these wrapper scripts.
In certain cases it might be necessary to create compatibility packages that provide older API/ABI level of the same library. However creating these compatibility packages is strongly discouraged. To standardize and simplify packaging of such compatibility packages following rules apply:
Java programs that wish to make calls into native libraries do so via the Java Native Interface (JNI). A Java package uses JNI if it contains a .so file. Note that this file can be embedded within JAR files themselves.
Note that GCJ packages contain .so
s in %{_libdir}/gcj/%{name}
but they are not JNI .sos.
%{_jnidir}
and CAN BE symlinked to %{_libdir}/%{name}
.%{_libdir}/%{name}