Skip to content
Permalink
edge
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
# snapcraft.yaml - builds a Snap package of OpenJDK
# Copyright (C) 2020-2023 John Neffenger
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
name: openjdk
title: OpenJDK
summary: Current JDK release and early-access builds
description: |
OpenJDK is the official reference implementation of the Java
Platform, Standard Edition, a cross-platform computing environment
that lets you develop and deploy Java applications on desktops,
servers, and embedded systems.
This package provides everything you need to develop a Java
application on Linux, including all of the latest development tools,
class libraries, API documentation, and source code of the Java
Development Kit (JDK).
To get started, see the README file for this package on GitHub:
https://github.com/jgneff/openjdk
Java and OpenJDK are trademarks or registered trademarks of Oracle
and/or its affiliates.
adopt-info: jdk
license: GPL-2.0-with-classpath-exception
base: core18
grade: devel
confinement: strict
architectures:
- build-on: amd64
- build-on: arm64
- build-on: armhf
- build-on: i386
- build-on: ppc64el
- build-on: s390x
slots:
jdk-20-1804:
interface: content
read: [$SNAP/jdk]
jdk-21-1804:
interface: content
read: [$SNAP/jdk]
plugs:
home: null
jfx-21-1804:
interface: content
target: $SNAP/jfx
apps:
openjdk:
command: bin/openjdk.sh
environment:
LC_ALL: C.UTF-8
java:
command: jdk/bin/java
plugs:
# Adds the interfaces of the GNOME Snapcraft Extensions plus 'network'
- desktop
- desktop-legacy
- gsettings
- network
- opengl
- wayland
- x11
environment:
LC_ALL: C.UTF-8
XAUTHORITY: $SNAP_REAL_HOME/.Xauthority
LD_LIBRARY_PATH: $SNAP/jfx/lib/$SNAPCRAFT_ARCH_TRIPLET
GTK_PATH: $SNAP/jfx/lib/$SNAPCRAFT_ARCH_TRIPLET/gtk-3.0
javac:
command: jdk/bin/javac
environment:
LC_ALL: C.UTF-8
javadoc:
command: jdk/bin/javadoc
environment:
LC_ALL: C.UTF-8
jar:
command: jdk/bin/jar
environment:
LC_ALL: C.UTF-8
jarsigner:
command: jdk/bin/jarsigner
environment:
LC_ALL: C.UTF-8
jlink:
command: jdk/bin/jlink
environment:
LC_ALL: C.UTF-8
jpackage:
command: jdk/bin/jpackage
environment:
LC_ALL: C.UTF-8
jwebserver:
command: jdk/bin/jwebserver
plugs:
- network-bind
environment:
LC_ALL: C.UTF-8
parts:
bin:
plugin: dump
source: .
source-type: local
stage: [bin]
jdk:
plugin: autotools
source: https://github.com/openjdk/jdk.git
source-type: git
source-tag: jdk-$SNAPCRAFT_PROJECT_VERSION
source-depth: 1
build-snaps:
- openjdk/latest/stable
build-packages:
- curl
- libasound2-dev
- libcups2-dev
- libfontconfig1-dev
- libfreetype6-dev
- libx11-dev
- libxext-dev
- libxrandr-dev
- libxrender-dev
- libxt-dev
- libxtst-dev
- unzip
- zip
override-pull: |
release=21
giturl=https://github.com/openjdk/jdk.git
tagurl=https://github.com/openjdk/jdk/tags.atom
# Gets the version from the latest release tag on GitHub
# $1 = feature release number (formerly "major" version)
# $2 = URL of Atom web feed providing recent tags
getversion() {
local feature=$1
local webfeed=$2
curl -s "$webfeed" | grep "<title>jdk-${feature}[.0-9]*+" \
| sed -E -e '1!d' -e 's| *<title>jdk-(.*)</title>|\1|'
}
# Sets the version and saves its environment variable
# $1 = the version string
setversion() {
snapcraftctl set-version "$1"
printf "export SNAPCRAFT_PROJECT_VERSION=%s\n" "$1" \
> /tmp/snapcraft-project-version
}
# See https://forum.snapcraft.io/t/17597
if [ -z "$SNAPCRAFT_PROJECT_VERSION" ]; then
version=$(getversion $release $tagurl)
setversion "$version"
git clone --branch "jdk-$version" --depth 1 \
$giturl "$SNAPCRAFT_PART_SRC"
else
snapcraftctl pull
fi
build-environment:
- JAVA_HOME: /snap/openjdk/current/jdk
override-build: |
# Loads the version environment variable if not defined
if [ -z "$SNAPCRAFT_PROJECT_VERSION" ]; then
. /tmp/snapcraft-project-version
fi
# Sets the environment variable for reproducible builds
SOURCE_DATE_EPOCH=$(git log -1 --pretty=%ct)
export SOURCE_DATE_EPOCH
# Builds the JDK ('--enable-warnings-as-errors=no' for armhf)
bash configure \
--enable-warnings-as-errors=no \
--enable-javac-server=no \
--with-vendor-name="Snap Build" \
--with-vendor-url="https://snapcraft.io/openjdk" \
--with-vendor-bug-url="https://github.com/jgneff/openjdk/issues" \
--with-version-pre=ea \
--with-version-opt=snap \
--with-version-build="${SNAPCRAFT_PROJECT_VERSION#*+}" \
--with-extra-cflags="$CFLAGS" \
--with-extra-cxxflags="$CXXFLAGS" \
--with-extra-ldflags="$LDFLAGS" \
--with-native-debug-symbols=none
make images docs
# Installs the build output
cd build/linux-*-server-release/images || exit
mv jdk docs "$SNAPCRAFT_PART_INSTALL"
organize:
docs: jdk/docs
stage-packages:
# Adds all DejaVu fonts and the 'jlink' and 'jpackage' dependencies
- binutils
- dpkg
- fakeroot
- fonts-dejavu-extra
# Adds library packages suggested by Snapcraft plus 'libfontconfig1'
- libasound2
- libfontconfig1
- libfreetype6
- libpng16-16
- libx11-6
- libxau6
- libxcb1
- libxdmcp6
- libxext6
- libxi6
- libxrender1
- libxtst6
del:
after: [jdk]
plugin: nil
# Deletes files and links already available in the base snap
override-prime: |
cd "$SNAPCRAFT_PRIME" || exit
base=/snap/core18/current
for d in etc lib usr/lib usr/share; do
find "$d" -type f -exec test -f "$base/{}" \; -delete
find "$d" -type l -exec test -L "$base/{}" \; -delete
done
find ./* -type d -empty -exec test -d "$base/{}" \; -delete
layout:
# For Java Swing apps
# Fontconfig error: Cannot load config file from /etc/fonts/fonts.conf
/etc/fonts:
bind: $SNAP/etc/fonts
# Exception in thread "AWT-EventQueue-0" java.lang.InternalError:
# java.lang.reflect.InvocationTargetException
# Caused by: java.lang.NullPointerException: Cannot load from short array
# because "sun.awt.FontConfiguration.head" is null
/usr/share/fonts/truetype/dejavu:
bind: $SNAP/usr/share/fonts/truetype/dejavu
# For the JDK 'jpackage' tool
# dpkg: error: error opening configuration directory '/etc/dpkg/dpkg.cfg.d':
# Permission denied
/etc/dpkg:
bind: $SNAP/etc/dpkg
# Can not find fakeroot. Reason: Cannot run program "fakeroot": error=2,
# No such file or directory
/usr/bin/fakeroot:
symlink: $SNAP/usr/bin/fakeroot-sysv
# fakeroot: preload library `libfakeroot-sysv.so' not found, aborting.
/usr/lib/$SNAPCRAFT_ARCH_TRIPLET/libfakeroot/libfakeroot-sysv.so:
symlink: $SNAP/usr/lib/$SNAPCRAFT_ARCH_TRIPLET/libfakeroot/libfakeroot-sysv.so
# /usr/bin/fakeroot: 1: eval: /usr/bin/faked-sysv: not found
/usr/bin/faked-sysv:
symlink: $SNAP/usr/bin/faked-sysv
# For JavaFX apps
# libGL error: MESA-LOADER: failed to open i965 (search paths
# /usr/lib/x86_64-linux-gnu/dri:\$${ORIGIN}/dri:/usr/lib/dri)
# libGL error: failed to load driver: i965
/usr/lib/$SNAPCRAFT_ARCH_TRIPLET/dri:
symlink: $SNAP/jfx/lib/$SNAPCRAFT_ARCH_TRIPLET/dri
# GdkPixbuf-WARNING **: 16:04:55.707: Cannot open pixbuf loader module
# file '/usr/lib/x86_64-linux-gnu/gdk-pixbuf-2.0/2.10.0/loaders.cache':
# No such file or directory
/usr/lib/$SNAPCRAFT_ARCH_TRIPLET/gdk-pixbuf-2.0:
symlink: $SNAP/jfx/lib/$SNAPCRAFT_ARCH_TRIPLET/gdk-pixbuf-2.0
# For Raspberry Pi OS
# ERROR: ld.so: object '/usr/lib/arm-linux-gnueabihf/libarmmem-${PLATFORM}.so'
# from /etc/ld.so.preload cannot be preloaded (cannot open shared object
# file): ignored.
/etc/ld.so.preload:
bind-file: $SNAP/etc/ld.so.preload