Skip to content

Conversation

@mizdebsk
Copy link
Member

@mizdebsk mizdebsk commented Nov 22, 2024

Add new experimental %jp_binding macro for generating binding packages, which are typically used to configure Java applications such as Maven to run with particular JVM implementation, but the mechanism is generic and can be used for other things as well.

Unlike earlier implementations of binding packages, the new approach does not lead to creating conflicting packages. Instead a hierarchy of symlinks is maintained, similarly to the alternatives system.

Currently there is no way to specify which binding will be selected in case when there is more than one installed (there is nothing like priorities yet), but this subject to change in the future.

The implementation of %jp_binding relies on "dynamic spec generation" (aka "specparts") feature of RPM 4.19, but later it could be updated to work with older RPM versions too. More info in RPM docs: https://rpm-software-management.github.io/rpm/manual/dynamic_specs.html

Example usage:

%install
mkdir -p %{buildroot}/etc
echo JAVA_HOME=/opt/jvm/java-17-somejdk >%{buildroot}/etc/marvin-somejdk17.conf
echo JAVA_HOME=/opt/jvm/java-21-somejdk >%{buildroot}/etc/marvin-somejdk21.conf
touch %{buildroot}/etc/marvin-unbound.conf
ln -s %{_jpbindingdir}/marvin.conf %{buildroot}/etc/marvin.conf

%jp_binding --provides marvin-jdk-binding \
            --base-pkg marvin \
 	    --variant unbound \
 	    --ghost marvin.conf \
 	    --target /etc/marvin-unbound.conf

# bindings can be also added in a loop
for jdk in 17 21; do
  %jp_binding --provides marvin-jdk-binding \
              --base-pkg marvin \
	      --variant somejdk${jdk} \
	      --ghost marvin.conf \
	      --target /etc/marvin-somejdk${jdk}.conf \
	      --requires somejdk-${jdk}-headless \
	      --recommends somejdk-${jdk}-devel
done

%files
%config /etc/marvin*.conf

Add new experimental %jp_binding macro for generating binding
packages, which are typically used to configure Java applications such
as Maven to run with particular JVM implementation, but the mechanism
is generic and can be used for other things as well.

Unlike earlier implementations of binding packages, the new approach
does not lead to creating conflicting packages.  Instead a hierarchy
of symlinks is maintained, similarly to the alternatives system.

Currently there is no way to specify which binding will be selected in
case when there is more than one installed (there is nothing like
priorities yet), but this subject to change in the future.

The implementation of %jp_binding relies on "dynamic spec generation"
(aka "specparts") feature of RPM 4.19, but later it could be updated
to work with older RPM versions too.  More info in RPM docs:
https://rpm-software-management.github.io/rpm/manual/dynamic_specs.html
@mizdebsk mizdebsk merged commit f3da643 into fedora-java:master Nov 22, 2024
1 check passed
@mizdebsk mizdebsk deleted the poc-bindings branch November 22, 2024 18:52
@codecov-commenter
Copy link

codecov-commenter commented Nov 22, 2024

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 91.00%. Comparing base (3471e50) to head (e1afdcc).
Report is 26 commits behind head on master.

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #140   +/-   ##
=======================================
  Coverage   91.00%   91.00%           
=======================================
  Files          45       45           
  Lines        3401     3401           
=======================================
  Hits         3095     3095           
  Misses        306      306           
Flag Coverage Δ
?

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.


🚨 Try these New Features:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants