%{?scl:%scl_package jmc}
%{!?scl:%global pkg_name %{name}}
# Version
%global major 8
%global minor 0
%global patchlevel 1
# Revision
%global revnum 4
# set to 1 for snapshots, 0 for release
%global usesnapshot 0
# SNAPSHOT version
%global revhash 699a121bd449fe8a9350221282bd3f809691a766
%global revdate 20210623
%global tarball_name jmc-%{revhash}
# Install jmc in /usr/lib/jmc (arch-specific and multilib exempt)
%global _jmcdir %{_prefix}/lib/%{pkg_name}
# Drop debug package. rh-eclipse is patched to strip symbols so it would be empty
# See: http://pkgs.devel.redhat.com/cgit/rpms/eclipse/tree/0003-SCL-specific-debuginfo-patch.patch?h=devtools-2020.2-rh-eclipse-rhel-7
%global debug_package %{nil}
%if %{usesnapshot}
%global releasestr %{revnum}.%{revdate}
%else
%global releasestr %{revnum}
%endif
%ifarch %{ix86}
%global eclipse_arch x86
%endif
%ifarch %{arm}
%global eclipse_arch arm
%endif
%ifarch s390x x86_64 aarch64 ppc64le
%global eclipse_arch %{_arch}
%endif
# Don't export Eclipse libraries
%global __provides_exclude_from ^%{_jmcdir}/plugins/org.eclipse.*$
%global __requires_exclude_from ^%{_jmcdir}/plugins/org.eclipse.*$
Name: %{scl_prefix}jmc
Version: %{major}.%{minor}.%{patchlevel}
Release: %{releasestr}%{?dist}
Summary: JDK Mission Control is a profiling and diagnostics tool
License: UPL
URL: http://openjdk.java.net/projects/jmc/
Source0: https://github.com/openjdk/jmc/archive/%{revhash}.tar.gz
Source1: %{name}.desktop
Source2: %{pkg_name}.1
Source3: symlink_libs.sh
# Remove optional twitter related functionality
Patch0: 0-remove-twitter.patch
# Remove maven build profiles that won't be used in local build
Patch1: 1-remove-profiles.patch
# Remove localization files that currently cannot be supported
# due to a packaging issue for Eclipse language packs
# eclipse-nls-ja and eclipse-nls-zh
# They currently provide multiple archs within the same package
# and the local build system cannot fulfill dependencies from them
Patch2: 2-remove-localization.patch
# Remove unused module org.openjdk.jmc.ide.jdt
Patch3: 3-remove-ide-jdt.patch
# Remove unused remote repository definition
Patch4: 4-remove-buchen-repo.patch
# Add dependency on org. hamcrest-core to provide class used in unit tests
Patch5: 5-add-hamcrest.patch
# Remove windows and mac arches
Patch6: 6-remove-arch.patch
# Remove unnecessary dependency
Patch7: 7-remove-jacoco-dep.patch
# Revert downloading of flameview assets from the web
Patch8: 8-revert-flameview.patch
# Revert the adjusted lz4-java name as seen in jmc
Patch9: 9-revert-lz4-java-name-override.patch
# Patch pom.xml Use to tycho version 2.1
Patch10: 10-tycho.patch
# Remove Chromium (currently Windows-only) from the plugin list
Patch11: 11-remove-chromium.patch
# Revert downloading of graphview assets from the web
Patch12: 12-revert-graphview.patch
# Simplify the path to the jmc product
Patch13: 13-revert-6852.patch
# Remove surefireArgLine used by jacoco
Patch14: 14-surefireArgLine.patch
# RHSCL: there are issues with tycho finding the commons-codec; remove it from
# the feature.xml and it should still be okay because it's symlinked
Patch15: 15-remove-commons-codec.patch
BuildRequires: desktop-file-utils
BuildRequires: java-11-openjdk-devel
BuildRequires: %{?scl_prefix_maven}osgi(javax.annotation-api)
BuildRequires: %{?scl_prefix_eclipse}eclipse-pde
BuildRequires: %{?scl_prefix_eclipse}tycho
BuildRequires: %{?scl_prefix_jmc}javamail
BuildRequires: %{?scl_prefix_jmc}mvn(org.commonjava.maven.plugins:directory-maven-plugin)
BuildRequires: %{?scl_prefix_jmc}mvn(com.sun.activation:jakarta.activation)
BuildRequires: %{?scl_prefix_jmc}mvn(org.openjdk.jmc:common)
BuildRequires: %{?scl_prefix_jmc}HdrHistogram >= 2.1.11
Requires: java-11-openjdk-devel
Requires: %{?scl_prefix_jmc}osgi(com.sun.activation.jakarta.activation)
Requires: %{?scl_prefix_jmc}osgi(jakarta.mail.api)
Requires: %{?scl_prefix_jmc}osgi(org.openjdk.jmc.common)
Requires: %{?scl_prefix_jmc}osgi(org.openjdk.jmc.flightrecorder)
Requires: %{?scl_prefix_jmc}osgi(org.openjdk.jmc.flightrecorder.rules)
Requires: %{?scl_prefix_jmc}osgi(org.openjdk.jmc.flightrecorder.rules.jdk)
Requires: %{?scl_prefix_jmc}osgi(org.owasp.encoder)
Requires: %{?scl_prefix_jmc}osgi(org.hdrhistogram.HdrHistogram) >= 2.1.11
Requires: rh-maven35-glassfish-el >= 3.0.1
Requires: rh-maven35-xpp3
Requires: %{?scl_prefix_maven}apache-commons-io
Requires: %{?scl_prefix_maven}apache-commons-jxpath
Requires: %{?scl_prefix_maven}apache-commons-logging
Requires: %{?scl_prefix_maven}atinject
Requires: %{?scl_prefix_maven}glassfish-annotation-api
Requires: %{?scl_prefix_maven}glassfish-el-api >= 3.0.1
Requires: %{?scl_prefix_maven}glassfish-jsp-api >= 2.2.1-4
Requires: %{?scl_prefix_maven}glassfish-servlet-api >= 3.1.0
Requires: %{?scl_prefix_maven}httpcomponents-client
Requires: %{?scl_prefix_maven}httpcomponents-core
Requires: %{?scl_prefix_maven}jsch >= 0.1.46-2
Requires: %{?scl_prefix_maven}osgi(org.tukaani.xz)
Requires: %{?scl_prefix_maven}xml-commons-apis
Requires: gtk3
Requires: webkitgtk4
Requires: libGLU.so.1()(64bit)
%description
JDK Mission Control is a powerful profiler for HotSpot JVMs and has an
advanced set of tools that enables efficient and detailed analysis of the
extensive data collected by JDK Flight Recorder. The tool chain enables
developers and administrators to collect and analyze data from Java
applications running locally or deployed in production environments.
%prep
%setup -q -n %{tarball_name}
%patch0 -p1
%patch1 -p1
%patch2 -p1
%patch3 -p1
%patch4 -p1
%patch5 -p1
%patch6 -p1
%patch7 -p1
%patch8 -p1
%patch9 -p1
%patch10 -p1
%patch11 -p1
%patch12 -p1
%patch13 -p1
%patch14 -p1
%patch15 -p1
%pom_disable_module releng
%pom_disable_module l10n application
%pom_disable_module org.openjdk.jmc.updatesite.ide application
%pom_disable_module org.openjdk.jmc.updatesite.rcp application
# disable tests that require the use of jfr
%pom_disable_module org.openjdk.jmc.rjmx.services.jfr.test application/tests
%pom_disable_module org.openjdk.jmc.flightrecorder.controlpanel.ui.test application/tests
%pom_remove_plugin com.github.spotbugs:spotbugs-maven-plugin
%pom_remove_plugin :maven-enforcer-plugin
%pom_remove_plugin :jacoco-maven-plugin application/tests
%pom_remove_plugin :jacoco-maven-plugin application/uitests
%pom_disable_module coverage application
# Info.plist are mac files and we only build for Linux
%pom_remove_plugin name.abuchen:fix-info-plist-maven-plugin application/org.openjdk.jmc.rcp.product
%pom_remove_plugin org.codehaus.mojo:buildnumber-maven-plugin
%pom_remove_plugin org.apache.maven.plugins:maven-deploy-plugin
TYCHO_ENV="linuxgtk%{eclipse_arch}"
%pom_xpath_set "pom:configuration/pom:environments" "$TYCHO_ENV"
%build
%{?scl:scl enable %{scl} %{scl_maven} %{scl_eclipse} - << "EOFSCL"}
# some tests require large heap and fail with OOM
# depending on the builder resources
%mvn_build -j -- -Dmaven.test.failure.ignore=true -Dmaven.test.skip=true -DbuildId=rhscl -DbuildNumber=%{revhash} -Dbuild.date=%{revdate}
%{?scl:EOFSCL}
%install
# not using mvn_install macro because it installs JMC as an Eclipse plugin
# we want to install JMC as an RCP application
# change jmc.ini to use jdk 11
sed -i '/-vmargs/i-vm\n/usr/lib/jvm/java-11/bin/java' %{_builddir}/%{tarball_name}/target/products/org.openjdk.jmc/%{_os}/gtk/%{eclipse_arch}/%{pkg_name}.ini
sed -i '/^..\/..\/bin\/$/d' %{_builddir}/%{tarball_name}/target/products/org.openjdk.jmc/%{_os}/gtk/%{eclipse_arch}/%{pkg_name}.ini
# add IgnoreUnrecognizedVMOptions flag to allow running on OpenJDK 8 without 'Unrecognized VM option' error
sed -i '/^-vmargs$/a -XX:+IgnoreUnrecognizedVMOptions' %{_builddir}/%{tarball_name}/target/products/org.openjdk.jmc/%{_os}/gtk/%{eclipse_arch}/%{pkg_name}.ini
# specify a new location for eclipse config files (at ~/.jmc/${version}/eclipse) so it doesn't interfere with other eclipse installations
sed -i '$ a -Dosgi.configuration.area=@user.home/.%{pkg_name}/%{version}/eclipse' %{_builddir}/%{tarball_name}/target/products/org.openjdk.jmc/%{_os}/gtk/%{eclipse_arch}/%{pkg_name}.ini
# move contents of target/products/org.openjdk.jmc/${_os}/gtk/%{eclipse_arch}/ to /usr/lib/jmc/
install -d -m 755 %{buildroot}%{_jmcdir}
cp -p -r %{_builddir}/%{tarball_name}/target/products/org.openjdk.jmc/%{_os}/gtk/%{eclipse_arch}/* %{buildroot}%{_jmcdir}/
# move jmc.ini to /etc/jmc.ini
install -d -m 755 %{buildroot}%{_sysconfdir}
mv %{buildroot}%{_jmcdir}/%{pkg_name}.ini %{buildroot}%{_sysconfdir}/%{pkg_name}.ini
ln -s %{_sysconfdir}/%{pkg_name}.ini %{buildroot}%{_jmcdir}/%{pkg_name}.ini
# create symlink to jmc in /usr/bin/
install -d -m 755 %{buildroot}%{_bindir}
ln -s %{_jmcdir}/%{pkg_name} %{buildroot}%{_bindir}/%{pkg_name}
# replace jars with symlinks to installed libraries
bash %{SOURCE3} %{buildroot}%{_jmcdir}/plugins %{_javadir} %{_jnidir} %{_javadir_maven} %{_jnidir_maven} /opt/rh/rh-maven35/root/usr/share/java
# create application launcher in desktop menu
install -d -m 755 %{buildroot}%{_root_datadir}/pixmaps
mv %{buildroot}%{_jmcdir}/icon.xpm %{buildroot}%{_root_datadir}/pixmaps/%{name}.xpm
chmod 644 %{buildroot}%{_root_datadir}/pixmaps/%{name}.xpm
desktop-file-install --dir=%{buildroot}%{_root_datadir}/applications %{SOURCE1}
# install pom file
install -d -m 755 %{buildroot}%{_datadir}/maven-poms/%{pkg_name}
install -p -m 644 %{_builddir}/%{tarball_name}/pom.xml %{buildroot}%{_datadir}/maven-poms/%{pkg_name}/%{pkg_name}.pom
# install manpage and insert location of config file
install -d -m 755 %{buildroot}%{_mandir}/man1
install -p -m 644 %{SOURCE2} %{buildroot}%{_mandir}/man1/%{pkg_name}.1
sed -i "/.SH FILES/a .I %{_sysconfdir}/%{pkg_name}.ini" %{buildroot}%{_mandir}/man1/%{pkg_name}.1
%files
%license license/LICENSE.txt
%license license/THIRDPARTYREADME.txt
%doc README.md
%config(noreplace) %{_sysconfdir}/%{pkg_name}.ini
%{_jmcdir}
%{_mandir}/man1/%{pkg_name}.1*
%{_bindir}/%{pkg_name}
%{_datadir}/maven-poms/%{pkg_name}
%{_root_datadir}/pixmaps/%{name}.xpm
%{_root_datadir}/applications/%{name}.desktop
%changelog
* Wed Aug 25 2021 Alex Macdonald - 8.0.1-4
- Update jmc jar references in the symlink script
* Wed Aug 25 2021 Alex Macdonald - 8.0.1-3
- Revert accidental deletion of BuildRequires
- Revert folder name change for sources tarball
* Wed Aug 25 2021 Alex Macdonald - 8.0.1-2
- Fix path to folder in sources tarball
* Mon Aug 23 2021 Alex Macdonald - 8.0.1-1
- Update to JMC revision for tag 8.0.1-ga
* Fri Mar 26 2021 Alex Macdonald - 8.0.0-6
- Modify jmc.ini to use a jmc version-specific folder for ~/.eclipse contents
* Wed Mar 03 2021 Alex Macdonald - 8.0.0-5
- Revert removal of glassfish-el dep, explicitly require rh-maven35
- Re-introduce glassfish-el to symlink script
- Remove unrequired patch 9 that prevented jfr from running on jmc start; update patch numbering
- Update requires and jmc.ini for jdk 11; eclipse requires jdk 11+
* Thu Feb 25 2021 Alex Macdonald - 8.0.0-4
- Remove requires on glassfish-el, which is not provided by rh-maven36
- glassfish-el only supplied by rh-maven35 in rhscl 3.7 ..
- xpp3 is not provided by rh-maven36; remove scl prefix from requires
- Do not apply the patch that stops flightrecorder from running by default
* Tue Feb 16 2021 Alex Macdonald - 8.0.0-3
- Update to JMC revision for tag 8.0.0-ga
* Tue Feb 02 2021 Alex Macdonald - 8.0.0-2
- Fix org.apache.commons.codec dependency
- Fix symlink script (remove annotation-api)
* Thu Jan 28 2021 Alex Macdonald - 8.0.0-1
- Update to version 8.0.0
- Update patch files and symlink script
* Tue Mar 03 2020 Jie Kang - 7.1.1.-2
- Drop debuginfo package. It would be empty since rh-eclipse strips symbols
* Tue Feb 25 2020 Alex Macdonald - 7.1.1-1
- Update to latest upstream
* Tue Feb 11 2020 Jie Kang - 7.1.0-1
- Update to JMC 7.1.0
* Tue Mar 12 2019 Jie Kang - 7.0.0-12.20190211hg62c5279452a6
- Bump revnum for rebuild
* Wed Mar 06 2019 Jie Kang - 7.0.0-11.20190211hg62c5279452a6
- Fix JMC name
* Tue Mar 05 2019 Jie Kang - 7.0.0-10.20190211hg62c5279452a6
- Add two patches fixing text and dialog issues
* Tue Mar 05 2019 Jie Kang - 7.0.0-9.20190211hg62c5279452a6
- Add more explicit requires for SWT library dependencies
* Tue Mar 05 2019 Jie Kang - 7.0.0-8.20190211hg62c5279452a6
- Add explicit requires for SWT library dependencies
* Thu Feb 28 2019 Jie Kang - 7.0.0-7.20190211hg62c5279452a6
- Apply ds patch
* Thu Feb 28 2019 Jie Kang - 7.0.0-6.20190211hg62c5279452a6
- Preemptively fix ds package issue
* Wed Feb 27 2019 Jie Kang - 7.0.0-5.20190211hg62c5279452a6
- Update desktop icon
- Update to latest jmc/jmc7 revision 62c5279452a6
* Tue Feb 26 2019 Jie Kang - 7.0.0-4.20190204hgbfd2c61eb116
- Symlink rh-jmc libs
- Fix BuildRequires
- Add Requires for maven35 packages and JDK 8
* Thu Feb 14 2019 Jie Kang - 7.0.0-3.20190204hgbfd2c61eb116
- Keep p2 folder
* Fri Feb 08 2019 Jie Kang - 7.0.0-2.20190204hgbfd2c61eb116
- Update to jmc7 revision bfd2c61eb116
* Mon Jan 21 2019 Jie Kang - 7.0.0-1.20181130hg1ddf3baa4e26
- SCL-ize package
* Fri Nov 30 2018 Salman Siddiqui - 7.0.0-0.20181130hg1ddf3baa4e26
- Update to latest snapshot version
* Fri Sep 14 2018 Salman Siddiqui - 7.0.0-0
- Initial packaging