MODULES+=		jsc17
MODULE_SUFFIX_jsc17=	jsc17

MODULE_SUMMARY_jsc17=	Java 17 module for NGINX Unit

MODULE_VERSION_jsc17=	$(VERSION)
MODULE_RELEASE_jsc17=	1

ifeq ($(OSVER),amazonlinux2023)
MODULE_CONFARGS_jsc17=	java --module=java17 --home=/usr/lib/jvm/java-17-amazon-corretto --lib-path=/usr/lib/jvm/java-17-amazon-corretto/lib --jars=/usr/share/unit-jsc-common/
else ifeq ($(OSVER),fedora39)
MODULE_CONFARGS_jsc17=	java --module=java17 --home=/usr/lib/jvm/java-17-openjdk --lib-path=/usr/lib/jvm/java-17-openjdk/lib --jars=/usr/share/unit-jsc-common/
endif
MODULE_MAKEARGS_jsc17=	java17
MODULE_INSTARGS_jsc17=	java17-install

MODULE_SOURCES_jsc17=	unit.example-jsc-app \
			unit.example-jsc17-config

ifeq ($(OSVER),amazonlinux2023)
BUILD_DEPENDS_jsc17=	java-17-amazon-corretto-devel
else ifeq ($(OSVER),fedora39)
BUILD_DEPENDS_jsc17=	java-17-openjdk-devel
BUILD_DEPENDS+=		$(BUILD_DEPENDS_jsc17)
endif

define MODULE_DEFINITIONS_jsc17
Requires: unit-jsc-common == $(MODULE_VERSION_jsc_common)-$(MODULE_RELEASE_jsc_common)%{?dist}.ngx
%if (0%{?amzn} == 2023)
Requires: java-17-amazon-corretto-headless
%endif
%if (0%{?fedora} >= 39)
Requires: java-17-openjdk-headless
%endif
endef
export MODULE_DEFINITIONS_jsc17

define MODULE_PREINSTALL_jsc17
%{__mkdir} -p %{buildroot}%{_datadir}/doc/unit-jsc17/examples/jsc-app
%{__install} -m 644 -p %{SOURCE100} \
    %{buildroot}%{_datadir}/doc/unit-jsc17/examples/jsc-app/index.jsp
%{__install} -m 644 -p %{SOURCE101} \
    %{buildroot}%{_datadir}/doc/unit-jsc17/examples/unit.config
%{__install} -m 644 -p %{bdir}/src/java/README.JSR-340 \
    %{buildroot}%{_datadir}/doc/unit-jsc17/
endef
export MODULE_PREINSTALL_jsc17

define MODULE_POSTINSTALL_jsc17
DESTDIR=%{buildroot} make java-shared-uninstall
endef
export MODULE_POSTINSTALL_jsc17

define MODULE_FILES_jsc17
%{_libdir}/unit/modules/*
%{_libdir}/unit/debug-modules/*
%dir %{_datadir}/doc/unit-jsc17
%{_datadir}/doc/unit-jsc17/*
%{_datadir}/unit-jsc-common/*
endef
export MODULE_FILES_jsc17

define MODULE_POST_jsc17
cat <<BANNER
----------------------------------------------------------------------

The $(MODULE_SUMMARY_jsc17) has been installed.

To check out the sample app, run these commands:

 sudo service unit restart
 cd /usr/share/doc/%{name}/examples
 sudo curl -X PUT --data-binary @unit.config --unix-socket /var/run/unit/control.sock http://localhost/config
 curl http://localhost:8800/

Online documentation is available at https://unit.nginx.org

`cat /usr/share/doc/unit-jsc17/README.JSR-340`

----------------------------------------------------------------------
BANNER
endef
export MODULE_POST_jsc17
