# Copyright (c) 2000-2007, JPackage Project
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the
# distribution.
# 3. Neither the name of the JPackage Project nor the names of its
# contributors may be used to endorse or promote products derived
# from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
%global jtuid 110
%global username %{name}
%global confdir %{_sysconfdir}/%{name}
%global logdir %{_localstatedir}/log/%{name}
%global homedir %{_datadir}/%{name}
%global jettycachedir %{_localstatedir}/cache/%{name}
%global tempdir %{jettycachedir}/temp
%global rundir %{_localstatedir}/run/%{name}
%global jettylibdir %{_localstatedir}/lib/%{name}
%global appdir %{jettylibdir}/webapps
%global addver .v20190610
# minimal version required to build eclipse and thermostat
# eclipse needs: util, server, http, continuation, io, security, servlet
# thermostat needs: server, jaas, webapp
# above modules need: jmx, xml
%bcond_with jp_minimal
Name: jetty
Version: 9.4.19
Release: 1%{addver}%{?dist}
Summary: Java Webserver and Servlet Container
# Jetty is dual licensed under both ASL 2.0 and EPL 1.0, see NOTICE.txt
License: ASL 2.0 or EPL-1.0
URL: http://www.eclipse.org/jetty/
Source0: https://github.com/eclipse/%{name}.project/archive/%{name}-%{version}%{addver}.tar.gz
Source1: jetty.sh
Source3: jetty.logrotate
Source5: %{name}.service
# MIT license text taken from Utf8Appendable.java
Source6: LICENSE-MIT
Patch1: 0001-Fedora-jetty.home.patch
BuildRequires: maven-local
BuildRequires: mvn(javax.servlet:javax.servlet-api)
BuildRequires: mvn(org.apache.felix:maven-bundle-plugin)
BuildRequires: mvn(org.apache.maven.plugins:maven-shade-plugin)
BuildRequires: mvn(org.codehaus.mojo:build-helper-maven-plugin)
BuildRequires: mvn(org.slf4j:slf4j-api)
%if %{without jp_minimal}
BuildRequires: maven-local
BuildRequires: mvn(com.github.jnr:jnr-unixsocket)
BuildRequires: mvn(javax.annotation:javax.annotation-api)
BuildRequires: mvn(javax.enterprise:cdi-api)
BuildRequires: mvn(javax.servlet:javax.servlet-api)
BuildRequires: mvn(javax.servlet.jsp:javax.servlet.jsp-api)
BuildRequires: mvn(javax.servlet:jstl)
BuildRequires: mvn(javax.transaction:javax.transaction-api)
BuildRequires: mvn(javax.websocket:javax.websocket-api)
BuildRequires: mvn(javax.websocket:javax.websocket-client-api)
BuildRequires: mvn(org.apache.ant:ant)
BuildRequires: mvn(org.apache.ant:ant-launcher)
BuildRequires: mvn(org.apache.felix:maven-bundle-plugin)
BuildRequires: mvn(org.apache.maven:maven-artifact)
BuildRequires: mvn(org.apache.maven:maven-core)
BuildRequires: mvn(org.apache.maven:maven-plugin-api)
BuildRequires: mvn(org.apache.maven:maven-project)
BuildRequires: mvn(org.apache.maven.plugins:maven-antrun-plugin)
BuildRequires: mvn(org.apache.maven.plugins:maven-assembly-plugin)
BuildRequires: mvn(org.apache.maven.plugins:maven-dependency-plugin)
BuildRequires: mvn(org.apache.maven.plugins:maven-failsafe-plugin)
BuildRequires: mvn(org.apache.maven.plugins:maven-plugin-plugin)
BuildRequires: mvn(org.apache.maven.plugins:maven-remote-resources-plugin)
BuildRequires: mvn(org.apache.maven.plugins:maven-shade-plugin)
BuildRequires: mvn(org.apache.maven.plugins:maven-war-plugin)
BuildRequires: mvn(org.apache.maven.plugin-tools:maven-plugin-annotations)
BuildRequires: mvn(org.apache.maven.plugin-tools:maven-plugin-tools-api)
BuildRequires: mvn(org.apache.maven.shared:maven-artifact-transfer)
BuildRequires: mvn(org.apache.taglibs:taglibs-standard-impl)
BuildRequires: mvn(org.apache.taglibs:taglibs-standard-spec)
BuildRequires: mvn(org.apache.tomcat:tomcat-jasper)
BuildRequires: mvn(org.codehaus.mojo:build-helper-maven-plugin)
BuildRequires: mvn(org.codehaus.mojo:exec-maven-plugin)
BuildRequires: mvn(org.eclipse.jetty.alpn:alpn-api)
BuildRequires: mvn(org.eclipse.jetty.orbit:javax.mail.glassfish)
BuildRequires: mvn(org.eclipse.jetty.orbit:javax.security.auth.message)
BuildRequires: mvn(org.eclipse.jetty.toolchain:jetty-assembly-descriptors)
BuildRequires: mvn(org.eclipse.jetty.toolchain:jetty-schemas)
BuildRequires: mvn(org.eclipse.jetty.toolchain:jetty-test-helper)
BuildRequires: mvn(org.jboss.weld.servlet:weld-servlet-core)
BuildRequires: mvn(org.mongodb:mongo-java-driver)
BuildRequires: mvn(org.ow2.asm:asm)
BuildRequires: mvn(org.ow2.asm:asm-commons)
BuildRequires: mvn(org.slf4j:slf4j-api)
BuildRequires: mvn(org.springframework:spring-beans)
BuildRequires: mvn(org.mortbay.jetty.alpn:alpn-boot)
BuildRequires: mvn(org.eclipse.jetty.toolchain:jetty-artifact-remote-resources)
BuildRequires: mvn(org.eclipse.jetty.toolchain:jetty-distribution-remote-resources)
BuildRequires: mvn(org.eclipse.jetty.toolchain:jetty-test-policy)
#BuildRequires: mvn(org.eclipse.jetty.toolchain.setuid:jetty-setuid-java)
BuildRequires: maven-javadoc-plugin
BuildRequires: glassfish-el
BuildRequires: systemd
BuildRequires: junit5
# duplicate providers, choose one
BuildRequires: jboss-websocket-1.0-api
Requires: jboss-websocket-1.0-api
%endif # without jp_minimal
BuildArch: noarch
# jp_minimal doesn't have main package
%if %{without jp_minimal}
# Explicit requires for javapackages-tools since jetty.sh script
# uses /usr/share/java-utils/java-functions
Requires: javapackages-tools
Requires: %{name}-annotations = %{version}-%{release}
Requires: %{name}-ant = %{version}-%{release}
Requires: %{name}-client = %{version}-%{release}
Requires: %{name}-continuation = %{version}-%{release}
Requires: %{name}-deploy = %{version}-%{release}
Requires: %{name}-fcgi-client = %{version}-%{release}
Requires: %{name}-fcgi-server = %{version}-%{release}
Requires: %{name}-http = %{version}-%{release}
Requires: %{name}-http-spi = %{version}-%{release}
Requires: %{name}-io = %{version}-%{release}
Requires: %{name}-jaas = %{version}-%{release}
Requires: %{name}-jaspi = %{version}-%{release}
Requires: %{name}-jmx = %{version}-%{release}
Requires: %{name}-jndi = %{version}-%{release}
Requires: %{name}-jsp = %{version}-%{release}
Requires: %{name}-jspc-maven-plugin = %{version}-%{release}
Requires: %{name}-maven-plugin = %{version}-%{release}
Requires: %{name}-plus = %{version}-%{release}
Requires: %{name}-proxy = %{version}-%{release}
Requires: %{name}-rewrite = %{version}-%{release}
Requires: %{name}-security = %{version}-%{release}
Requires: %{name}-server = %{version}-%{release}
Requires: %{name}-servlet = %{version}-%{release}
Requires: %{name}-servlets = %{version}-%{release}
Requires: %{name}-spring = %{version}-%{release}
Requires: %{name}-start = %{version}-%{release}
Requires: %{name}-unixsocket = %{version}-%{release}
Requires: %{name}-util = %{version}-%{release}
Requires: %{name}-util-ajax = %{version}-%{release}
Requires: %{name}-webapp = %{version}-%{release}
Requires: %{name}-xml = %{version}-%{release}
Requires: %{name}-cdi = %{version}-%{release}
Requires: %{name}-websocket-api = %{version}-%{release}
Requires: %{name}-websocket-client = %{version}-%{release}
Requires: %{name}-websocket-common = %{version}-%{release}
Requires: %{name}-websocket-server = %{version}-%{release}
Requires: %{name}-websocket-servlet = %{version}-%{release}
Requires: %{name}-javax-websocket-client-impl = %{version}-%{release}
Requires: %{name}-javax-websocket-server-impl = %{version}-%{release}
Requires: %{name}-nosql = %{version}-%{release}
Requires: %{name}-quickstart = %{version}-%{release}
Requires: %{name}-jstl = %{version}-%{release}
Requires: %{name}-alpn-client = %{version}-%{release}
Requires: %{name}-alpn-server = %{version}-%{release}
Requires: %{name}-http2-client = %{version}-%{release}
Requires: %{name}-http2-common = %{version}-%{release}
Requires: %{name}-http2-hpack = %{version}-%{release}
Requires: %{name}-http2-http-client-transport = %{version}-%{release}
Requires: %{name}-http2-server = %{version}-%{release}
Requires(pre): shadow-utils
%{?systemd_ordering}
Provides: group(%username) = %jtuid
Provides: user(%username) = %jtuid
%endif # without jp_minimal
# (Added in F25)
Obsoletes: %{name}-monitor < 9.4.0-0.4
# Hazelcast in Fedora is too old for jetty to build against (Added in F29)
Obsoletes: %{name}-hazelcast < 9.4.18-1
# Infinispan in Fedora is too old for jetty to build against (Added in F31)
Obsoletes: %{name}-infinispan < 9.4.18-1
# Eclipse no longer available (Added in F31)
Obsoletes: %{name}-osgi-alpn < 9.4.18-1
Obsoletes: %{name}-osgi-boot < 9.4.18-1
Obsoletes: %{name}-osgi-boot-jsp < 9.4.18-1
Obsoletes: %{name}-osgi-boot-warurl < 9.4.18-1
%description
%global desc \
Jetty is a 100% Java HTTP Server and Servlet Container. This means that you\
do not need to configure and run a separate web server (like Apache) in order\
to use Java, servlets and JSPs to generate dynamic content. Jetty is a fully\
featured web server for static and dynamic content. Unlike separate\
server/container solutions, this means that your web server and web\
application run in the same process, without interconnection overheads\
and complications. Furthermore, as a pure java component, Jetty can be simply\
included in your application for demonstration, distribution or deployment.\
Jetty is available on all Java supported platforms.
%{desc}
%global extdesc %{desc}\
\
This package contains
# packages in jp_minimal set
%package client
Summary: client module for Jetty
%description client
%{extdesc} %{summary}.
%package continuation
Summary: continuation module for Jetty
%description continuation
%{extdesc} %{summary}.
%package http
Summary: http module for Jetty
%description http
%{extdesc} %{summary}.
%package http-spi
Summary: http-spi module for Jetty
%description http-spi
%{extdesc} %{summary}.
%package io
Summary: io module for Jetty
%description io
%{extdesc} %{summary}.
%package jaas
Summary: jaas module for Jetty
%description jaas
%{extdesc} %{summary}.
%package jsp
Summary: jsp module for Jetty
Requires: glassfish-el
%description jsp
%{extdesc} %{summary}.
%package security
Summary: security module for Jetty
%description security
%{extdesc} %{summary}.
%package server
Summary: server module for Jetty
%description server
%{extdesc} %{summary}.
%package servlet
Summary: servlet module for Jetty
# Eclipse no longer available (Added in F31)
Obsoletes: %{name}-httpservice < 9.4.18-1
%description servlet
%{extdesc} %{summary}.
%package util
Summary: util module for Jetty
# Utf8Appendable.java is additionally under MIT license
License: (ASL 2.0 or EPL-1.0) and MIT
%description util
%{extdesc} %{summary}.
%package webapp
Summary: webapp module for Jetty
%description webapp
%{extdesc} %{summary}.
%package jmx
Summary: jmx module for Jetty
%description jmx
%{extdesc} %{summary}.
%package xml
Summary: xml module for Jetty
%description xml
%{extdesc} %{summary}.
%if %{without jp_minimal}
%package project
Summary: POM files for Jetty
Obsoletes: %{name}-websocket-parent < 9.4.0-0.4
Provides: %{name}-websocket-parent = %{version}-%{release}
Obsoletes: %{name}-osgi-project < 9.4.0-0.4
Provides: %{name}-osgi-project = %{version}-%{release}
%description project
%{extdesc} %{summary}.
%package deploy
Summary: deploy module for Jetty
%description deploy
%{extdesc} %{summary}.
%package annotations
Summary: annotations module for Jetty
%description annotations
%{extdesc} %{summary}.
%package ant
Summary: ant module for Jetty
%description ant
%{extdesc} %{summary}.
%package cdi
Summary: Jetty CDI Configuration
%description cdi
%{extdesc} %{summary}.
%package fcgi-client
Summary: FastCGI client module for Jetty
%description fcgi-client
%{extdesc} %{summary}.
%package fcgi-server
Summary: FastCGI client module for Jetty
%description fcgi-server
%{extdesc} %{summary}.
%package jaspi
Summary: jaspi module for Jetty
%description jaspi
%{extdesc} %{summary}.
%package jndi
Summary: jndi module for Jetty
%description jndi
%{extdesc} %{summary}.
%package jspc-maven-plugin
Summary: jspc-maven-plugin module for Jetty
%description jspc-maven-plugin
%{extdesc} %{summary}.
%package maven-plugin
Summary: maven-plugin module for Jetty
%description maven-plugin
%{extdesc} %{summary}.
%package plus
Summary: plus module for Jetty
%description plus
%{extdesc} %{summary}.
%package proxy
Summary: proxy module for Jetty
%description proxy
%{extdesc} %{summary}.
%package rewrite
Summary: rewrite module for Jetty
%description rewrite
%{extdesc} %{summary}.
%package servlets
Summary: servlets module for Jetty
%description servlets
%{extdesc} %{summary}.
%package spring
Summary: spring module for Jetty
%description spring
%{extdesc} %{summary}.
%package start
Summary: start module for Jetty
%description start
%{extdesc} %{summary}.
%package unixsocket
Summary: unixsocket module for Jetty
%description unixsocket
%{extdesc} %{summary}.
%package util-ajax
Summary: util-ajax module for Jetty
%description util-ajax
%{extdesc} %{summary}.
%package websocket-api
Summary: websocket-api module for Jetty
%description websocket-api
%{extdesc} %{summary}.
%package websocket-client
Summary: websocket-client module for Jetty
%description websocket-client
%{extdesc} %{summary}.
%package websocket-common
Summary: websocket-common module for Jetty
%description websocket-common
%{extdesc} %{summary}.
%package websocket-server
Summary: websocket-server module for Jetty
%description websocket-server
%{extdesc} %{summary}.
%package websocket-servlet
Summary: websocket-servlet module for Jetty
%description websocket-servlet
%{extdesc} %{summary}.
%package javax-websocket-client-impl
Summary: javax-websocket-client-impl module for Jetty
%description javax-websocket-client-impl
%{extdesc} %{summary}.
%package javax-websocket-server-impl
Summary: javax-websocket-server-impl module for Jetty
%description javax-websocket-server-impl
%{extdesc} %{summary}.
%package nosql
Summary: nosql module for Jetty
%description nosql
%{extdesc} %{summary}.
%package quickstart
Summary: quickstart module for Jetty
%description quickstart
%{extdesc} %{summary}.
%package alpn-client
Summary: alpn-client module for Jetty
%description alpn-client
%{extdesc} %{summary}.
%package alpn-server
Summary: alpn-server module for Jetty
%description alpn-server
%{extdesc} %{summary}.
%package http2-client
Summary: http2-client module for Jetty
%description http2-client
%{extdesc} %{summary}.
%package http2-common
Summary: http2-common module for Jetty
%description http2-common
%{extdesc} %{summary}.
%package http2-hpack
Summary: http2-hpack module for Jetty
%description http2-hpack
%{extdesc} %{summary}.
%package http2-http-client-transport
Summary: http2-http-client-transport module for Jetty
%description http2-http-client-transport
%{extdesc} %{summary}.
%package http2-server
Summary: http2-server module for Jetty
%description http2-server
%{extdesc} %{summary}.
%package jstl
Summary: jstl module for Jetty
%description jstl
%{extdesc} %{summary}.
%endif # without jp_minimal
%package javadoc
Summary: Javadoc for %{name}
# some MIT-licensed code (from Utf8Appendable) is used to generate javadoc
License: (ASL 2.0 or EPL-1.0) and MIT
%description javadoc
%{summary}.
%prep
%setup -q -n %{name}.project-%{name}-%{version}%{addver}
%patch1 -p1
find . -name "*.?ar" -exec rm {} \;
find . -name "*.class" -exec rm {} \;
# Plugins irrelevant or harmful to building the package
%pom_remove_plugin -r :findbugs-maven-plugin
%pom_remove_plugin -r :maven-enforcer-plugin
%pom_remove_plugin -r :clirr-maven-plugin
%pom_remove_plugin -r :maven-eclipse-plugin
%pom_remove_plugin -r :maven-pmd-plugin
%pom_remove_plugin -r :license-maven-plugin
%pom_remove_plugin -r :maven-site-plugin
%pom_remove_plugin -r :maven-source-plugin
%pom_remove_plugin -r :maven-deploy-plugin
%pom_remove_plugin -r :jacoco-maven-plugin
%pom_remove_plugin -r :maven-release-plugin
%pom_remove_plugin -r :buildnumber-maven-plugin
%pom_remove_plugin -r :h2spec-maven-plugin
# Unnecessary pom flattening can be skipped
%pom_remove_plugin -r :flatten-maven-plugin jetty-bom
%pom_disable_module aggregates/jetty-all
# Use proper groupId for apache ant
%pom_xpath_replace "pom:groupId[text()='ant']" "org.apache.ant" jetty-ant/pom.xml
%pom_remove_dep "com.sun.net.httpserver:http" jetty-http-spi
%pom_change_dep -r org.mortbay.jasper:apache-jsp org.apache.tomcat:tomcat-jasper
%pom_add_dep 'org.junit.jupiter:junit-jupiter-engine:${junit.version}' tests/test-sessions/test-sessions-common
# Old version of jetty not available for tests, so use this version
%pom_change_dep 'org.eclipse.jetty:jetty-util' 'org.eclipse.jetty:jetty-util:${project.version}' tests/test-webapps/test-servlet-spec/test-spec-webapp
# provided by glassfish-jsp-api that has newer version
%pom_change_dep -r javax.servlet.jsp:jsp-api javax.servlet.jsp:javax.servlet.jsp-api
# txt artifact - not installable
%pom_remove_plugin ":jetty-version-maven-plugin"
%pom_xpath_remove "pom:artifactItem[pom:classifier='version']" jetty-home
# Disable building source release
%pom_xpath_remove 'pom:execution[pom:id="sources"]' jetty-home
# Unwanted JS in javadoc
sed -i '/^\s*\*.*