%bcond_with bootstrap
Name:                byte-buddy
Version:             1.12.0
Release:             2
Summary:             Runtime code generation for the Java virtual machine
License:             Apache-2.0
URL:                 http://bytebuddy.net/
Source0:             https://github.com/raphw/byte-buddy/archive/byte-buddy-%{version}.tar.gz
Source1:             xmvn-reactor
Patch0:              0001-Avoid-bundling-asm.patch
Patch1:              0002-Remove-dependencies.patch
Patch2:              0003-Remove-Java-14-tests.patch
Patch3:              0004-Remove-JDK-15-sealed-classes.patch

BuildRequires:       maven-local
BuildRequires:       java-1.8.0-openjdk-devel maven
Requires:            byte-buddy-agent byte-buddy-maven-plugin byte-buddy-parent 
BuildArch:           noarch

%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
Requires:            byte-buddy

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

%package maven-plugin
Summary:             Byte Buddy Maven plugin
Requires:            byte-buddy

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

%package parent
Summary:             Byte Buddy parent POM
Requires:            byte-buddy

%description parent
The parent artifact contains configuration information that
concern all modules.

%package javadoc
Summary:             Javadoc for %{name}

%description javadoc
This package contains API documentation for %{name}.

%prep
%setup -q -n %{name}-%{name}-%{version}
%patch0 -p1
%patch1 -p1
%patch2 -p1
%patch3 -p1

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

mv byte-buddy-dep/src/precompiled/java/net/bytebuddy/build/*.java \
  byte-buddy-dep/src/main/java/net/bytebuddy/build
mkdir -p byte-buddy-dep/src/test/java/net/bytebuddy/test/precompiled/
mv byte-buddy-dep/src/precompiled/java/net/bytebuddy/test/precompiled/*.java \
  byte-buddy-dep/src/test/java/net/bytebuddy/test/precompiled/
%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 :clirr-maven-plugin
%pom_remove_plugin :maven-release-plugin
%pom_remove_plugin :nexus-staging-maven-plugin
%pom_remove_plugin :byte-buddy-maven-plugin byte-buddy-dep

%pom_xpath_set "pom:createSourcesJar" "false" byte-buddy
%pom_remove_dep :findbugs-annotations
sed -i -e '/SuppressFBWarnings/d' $(grep -lr SuppressFBWarnings)
%pom_remove_plugin -r :modulemaker-maven-plugin

%pom_remove_dep org.ow2.asm:asm-deprecated
%pom_remove_plugin :maven-shade-plugin byte-buddy
%pom_remove_plugin :maven-shade-plugin byte-buddy-benchmark
%pom_remove_dep net.java.dev.jna:jna byte-buddy
%pom_remove_dep net.java.dev.jna:jna byte-buddy-dep
%pom_remove_dep net.java.dev.jna:jna byte-buddy-agent
%pom_remove_dep net.java.dev.jna:jna-platform byte-buddy
%pom_remove_dep net.java.dev.jna:jna-platform byte-buddy-dep
%pom_remove_dep net.java.dev.jna:jna-platform byte-buddy-agent

cp %{SOURCE1} ./.xmvn-reactor
echo `pwd` > absolute_prefix.log
sed -i 's/\//\\\//g' absolute_prefix.log
absolute_prefix=`head -n 1 absolute_prefix.log`
sed -i 's/absolute-prefix/'"$absolute_prefix"'/g' .xmvn-reactor

%build
mvn package -Dsourcecode.test.version=1.8 -Dmaven.test.failure.ignore=true -P'java8,!checks' verify org.fedoraproject.xmvn:xmvn-mojo:javadoc

%install
%mvn_install
JAVADOC_DIR=%{buildroot}%{_javadocdir}/%{name}
if [ ! -d $JAVADOC_DIR ];then
mkdir -p %{buildroot}%{_javadocdir}/%{name}
cp -rf target/xmvn-apidocs/* %{buildroot}%{_javadocdir}/%{name}
fi

%files 
%attr(0644,root,root) /usr/share/maven-metadata/byte-buddy.xml
%attr(0755,root,root) %dir /usr/share/java/byte-buddy
%attr(0644,root,root) /usr/share/java/byte-buddy/byte-buddy.jar
%attr(0755,root,root) %dir /usr/share/maven-poms/byte-buddy
%attr(0644,root,root) /usr/share/maven-poms/byte-buddy/byte-buddy.pom
%attr(0755,root,root) %dir /usr/share/java/byte-buddy
%attr(0644,root,root) /usr/share/java/byte-buddy/byte-buddy-dep.jar
%attr(0755,root,root) %dir /usr/share/maven-poms/byte-buddy
%attr(0644,root,root) /usr/share/maven-poms/byte-buddy/byte-buddy-dep.pom
%doc README.md release-notes.md
%license LICENSE NOTICE

%files agent 
%attr(0755,root,root) %dir /usr/share/java/byte-buddy
%attr(0644,root,root) /usr/share/java/byte-buddy/byte-buddy-agent.jar
%attr(0755,root,root) %dir /usr/share/maven-poms/byte-buddy
%attr(0644,root,root) /usr/share/maven-poms/byte-buddy/byte-buddy-agent.pom
%license LICENSE NOTICE

%files maven-plugin 
%attr(0755,root,root) %dir /usr/share/java/byte-buddy
%attr(0644,root,root) /usr/share/java/byte-buddy/byte-buddy-maven-plugin.jar
%attr(0755,root,root) %dir /usr/share/maven-poms/byte-buddy
%attr(0644,root,root) /usr/share/maven-poms/byte-buddy/byte-buddy-maven-plugin.pom

%files parent 
%attr(0755,root,root) %dir /usr/share/maven-poms/byte-buddy
%attr(0644,root,root) /usr/share/maven-poms/byte-buddy/byte-buddy-parent.pom
%license LICENSE NOTICE

%files javadoc 
/usr/share/javadoc/byte-buddy
%license LICENSE NOTICE

%changelog
* Tue Feb 25 2025 Ge Wang <wang__ge@126.com> - 1.12.0-2
- Replace maven-javadoc-plugin with xmvn-mojo to generate javadoc file
 
* 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
