#
# spec file for package jacoco
#
# Copyright (c) 2024 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.
# Please submit bugfixes or comments via https://bugs.opensuse.org/
#
Name: jacoco
Version: 0.8.12
Release: 0
Summary: Java Code Coverage for Eclipse
License: EPL-2.0
URL: https://www.eclemma.org/jacoco/
Source0: https://github.com/jacoco/jacoco/archive/v%{version}/%{name}-%{version}.tar.gz
Patch0: new-reporting-api.patch
BuildRequires: fdupes
BuildRequires: maven-local
BuildRequires: mvn(args4j:args4j)
BuildRequires: mvn(org.apache.ant:ant)
BuildRequires: mvn(org.apache.felix:maven-bundle-plugin)
BuildRequires: mvn(org.apache.maven.plugin-tools:maven-plugin-annotations)
BuildRequires: mvn(org.apache.maven.plugins:maven-antrun-plugin)
BuildRequires: mvn(org.apache.maven.plugins:maven-dependency-plugin)
BuildRequires: mvn(org.apache.maven.plugins:maven-plugin-plugin)
BuildRequires: mvn(org.apache.maven.plugins:maven-shade-plugin)
BuildRequires: mvn(org.apache.maven.reporting:maven-reporting-api)
BuildRequires: mvn(org.apache.maven.shared:file-management)
BuildRequires: mvn(org.apache.maven:maven-core)
BuildRequires: mvn(org.apache.maven:maven-plugin-api)
BuildRequires: mvn(org.codehaus.mojo:build-helper-maven-plugin)
BuildRequires: mvn(org.codehaus.mojo:buildnumber-maven-plugin)
BuildRequires: mvn(org.codehaus.mojo:exec-maven-plugin)
BuildRequires: mvn(org.codehaus.plexus:plexus-utils)
BuildRequires: mvn(org.ow2.asm:asm)
BuildRequires: mvn(org.ow2.asm:asm-commons)
BuildRequires: mvn(org.ow2.asm:asm-tree)
# required by wrapper scripts
Requires: javapackages-tools
BuildArch: noarch
%description
JaCoCo is a free code coverage library for Java,
which has been created by the EclEmma team based on the lessons learned
from using and integration existing libraries over the last five years.
%package maven-plugin
Summary: A Jacoco plugin for maven
%description maven-plugin
A Jacoco plugin for maven.
%package javadoc
Summary: Javadoc for %{name}
%description javadoc
This package contains javadoc for %{name}.
%prep
%autosetup -p1
find -type f '(' -iname '*.jar' -o -iname '*.class' ')' -print -delete
%pom_disable_module ../jacoco org.jacoco.build
%pom_disable_module ../org.jacoco.doc org.jacoco.build
%pom_disable_module ../org.jacoco.examples org.jacoco.build
%pom_disable_module ../org.jacoco.tests org.jacoco.build
# Remove unnecessary dependency on maven-javadoc-plugin
%pom_remove_plugin -r :maven-javadoc-plugin
%pom_remove_dep -r :asm-bom
# Remove enforcer plugin that causes build failure of 'Jacoco :: Maven Plugin'
%pom_remove_plugin -r :maven-enforcer-plugin
# Don't build jars with classifier ":nodeps:"
%pom_remove_plugin :maven-shade-plugin \
org.jacoco.ant \
org.jacoco.cli
%pom_remove_plugin -r :spotless-maven-plugin
# Need to redefine various properties
%pom_remove_plugin :beanshell-maven-plugin \
org.jacoco.build
# Remove "requires osgi(org.apache.ant)"
%pom_xpath_remove 'pom:configuration/pom:instructions/pom:Require-Bundle' \
org.jacoco.ant
# Remove requires on maven-plugin-plugin:report
%pom_xpath_remove 'pom:execution[pom:id = "report"]' \
jacoco-maven-plugin
# Define properties
%pom_xpath_inject 'pom:properties' '
${project.version}
${maven.build.timestamp}
${unqualifiedVersion}.${buildQualifier}
org.jacoco.agent.rt.internal' \
org.jacoco.build
%{mvn_package} ":jacoco-maven-plugin:{jar,pom}:{}:" maven-plugin
%{mvn_package} ":{org.}*:{jar,pom}:runtime:"
%{mvn_package} :root __noinstall
%{mvn_package} :org.jacoco.build __noinstall
%build
%{mvn_build} -f -- \
-Dproject.build.outputTimestamp=$(date -u -d @${SOURCE_DATE_EPOCH:-$(date +%%s)} +%%Y-%%m-%%dT%%H:%%M:%%SZ) \
-Dbuild.date=$(date -u -d @${SOURCE_DATE_EPOCH:-$(date +%%s)} +%%Y/%%m/%%d) \
-Dproject.build.sourceEncoding=UTF-8 -Dmaven.compiler.source=1.8 -Dmaven.compiler.target=1.8
%install
%mvn_install
%fdupes -s %{buildroot}%{_javadocdir}
# ant config
mkdir -p %{buildroot}%{_sysconfdir}/ant.d
echo %{name} %{name}/org.jacoco.ant objectweb-asm/asm{,-commons,-tree} > %{buildroot}%{_sysconfdir}/ant.d/%{name}
# wrapper script
%jpackage_script org.jacoco.cli.internal.Main "" "" jacoco/org.jacoco.cli:args4j:objectweb-asm:jacoco/org.jacoco.core:jacoco/org.jacoco.report jacococli true
%files -f .mfiles
%config(noreplace) %{_sysconfdir}/ant.d/%{name}
%{_bindir}/jacococli
%license LICENSE.md
%doc README.md
%files maven-plugin -f .mfiles-maven-plugin
%files javadoc -f .mfiles-javadoc
%changelog