%bcond_with bootstrap

Name:           byte-buddy
Version:        1.18.8
Release:        1
Summary:        Runtime code generation for the Java virtual machine
License:        Apache-2.0
URL:            https://bytebuddy.net
BuildArch:      noarch

Source0:        https://github.com/raphw/byte-buddy/archive/refs/tags/byte-buddy-%{version}.tar.gz

Patch0:         0001-Avoid-bundling-asm.patch
Patch1:         0002-Remove-dependencies.patch

BuildRequires:  jurand
%if %{with bootstrap}
BuildRequires:  javapackages-bootstrap
%else
BuildRequires:  maven-local
BuildRequires:  mvn(codes.rafael.modulemaker:modulemaker-maven-plugin)
BuildRequires:  mvn(junit:junit)
BuildRequires:  mvn(net.bytebuddy:byte-buddy)
BuildRequires:  mvn(net.bytebuddy:byte-buddy-dep)
BuildRequires:  mvn(org.apache.felix:maven-bundle-plugin)
BuildRequires:  mvn(org.apache.maven.plugin-testing:maven-plugin-testing-harness)
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-plugin-plugin)
BuildRequires:  mvn(com.google.code.findbugs:jsr305)
BuildRequires:  mvn(org.apache.maven:maven-compat)
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.eclipse.aether:aether-api)
BuildRequires:  mvn(org.eclipse.aether:aether-util)
BuildRequires:  mvn(org.mockito:mockito-core)
BuildRequires:  mvn(org.ow2.asm:asm)
BuildRequires:  mvn(org.ow2.asm:asm-analysis)
BuildRequires:  mvn(org.ow2.asm:asm-commons)
BuildRequires:  mvn(org.ow2.asm:asm-util)
%endif

Obsoletes:      %{name}-parent < %{version}-%{release}

%description
Byte Buddy is a code generation library for creating Java classes during the
runtime of a Java application and without the help of a compiler. Other than
the code generation utilities that ship with the Java Class Library, Byte Buddy
allows the creation of arbitrary classes and is not limited to implementing
interfaces for the creation of runtime proxies. 

%package agent
Summary:        Byte Buddy Java agent

%description agent
The Byte Buddy Java agent allows to access the JVM's HotSwap feature.

%package maven-plugin
Summary:        Byte Buddy Maven plugin

%description maven-plugin
A plugin for post-processing class files via Byte Buddy in a Maven build.

%package javadoc
Summary:        API documentation for %{name}

%description javadoc
API documentation for %{name}.

%prep
%autosetup -n %{name}-%{name}-%{version} -p1

find -name '*.class' -delete

rm byte-buddy-agent/src/test/java/net/bytebuddy/agent/VirtualMachineAttachmentTest.java
rm byte-buddy-agent/src/test/java/net/bytebuddy/agent/VirtualMachineForOpenJ9Test.java
rm byte-buddy-agent/src/test/java/net/bytebuddy/test/utility/JnaRule.java

%pom_disable_module byte-buddy-android
%pom_disable_module byte-buddy-android-test
%pom_disable_module byte-buddy-benchmark
%pom_disable_module byte-buddy-gradle-plugin

%pom_remove_plugin :jacoco-maven-plugin
%pom_remove_plugin :license-maven-plugin
%pom_remove_plugin :pitest-maven
%pom_remove_plugin :coveralls-maven-plugin
%pom_remove_plugin :spotbugs-maven-plugin
%pom_remove_plugin :jitwatch-jarscan-maven-plugin
%pom_remove_plugin :maven-release-plugin
%pom_remove_plugin :central-publishing-maven-plugin
%pom_remove_plugin :byte-buddy-maven-plugin byte-buddy-dep

%pom_xpath_set "pom:createSourcesJar" "false" byte-buddy

%pom_remove_dep -r :findbugs-annotations
jurand -i -s -a byte-buddy-agent byte-buddy-dep byte-buddy-maven-plugin -n SuppressFBWarnings

%pom_remove_dep org.ow2.asm:asm-deprecated

%pom_remove_plugin -r :maven-shade-plugin
%pom_remove_dep -r net.java.dev.jna:jna
%pom_remove_dep -r net.java.dev.jna:jna-platform
%pom_remove_dep -r codes.rafael.asmjdkbridge:asm-jdk-bridge

%mvn_package :byte-buddy-parent __noinstall

%build
profiles='-Pjava-8-precompile -Pjava-8-parameters-precompile -Pjava-11-precompile -Pjava-16-precompile -Pjava-17-precompile'
%mvn_build -s -- -P'java8,!checks' "${profiles}" -Dsourcecode.main.version=8 -Dsourcecode.test.version=8 -Dmaven.test.failure.ignore=true

%install
%mvn_install

%files -f .mfiles-%{name} -f .mfiles-%{name}-dep
%doc README.md release-notes.md
%license LICENSE NOTICE

%files agent -f .mfiles-%{name}-agent
%license LICENSE NOTICE

%files maven-plugin -f .mfiles-%{name}-maven-plugin

%files javadoc -f .mfiles-javadoc
%license LICENSE NOTICE

%changelog
* Tue May 26 2026 yaoxin <1024769339@qq.com> - 1.18.8-1
- Update to 1.18.8

* Tue Feb 10 2026 yaoxin <1024769339@qq.com> - 1.14.10-2
- Adapting to maven upgrade

* Wed Apr 24 2024 Ge Wang <wang__ge@126.com> - 1.14.10-1
- Update to version 1.14.10

* Wed Aug 02 2023 xu_ping <707078654@qq.com> - 1.14.2-1
- Upgrade to version 1.14.2

* Thu Jun 16 2022 Ge Wang <wangge20@h-partners.com> - 1.12.0-1
- Upgrade to version 1.12.0

* Fri Aug 14 2020 leiju <leiju4@huawei.com> - 1.9.5-1
- Package init