%bcond_with bootstrap

%if %{without bootstrap}
%bcond_without bnd_maven_plugin
%else
%bcond_with bnd_maven_plugin
%endif

Name:           javaparser
Version:        3.27.1
Release:        3
Summary:        Java 1 to 13 Parser and Abstract Syntax Tree for Java
License:        LGPL-2.0-or-later OR Apache-2.0
URL:            https://javaparser.org
Source0:        https://github.com/javaparser/javaparser/archive/%{name}-parent-%{version}.tar.gz
BuildArch:      noarch

Patch0:         0001-Port-to-OpenJDK-21.patch

%if %{with bnd_maven_plugin}
BuildRequires:  mvn(biz.aQute.bnd:bnd-maven-plugin)
%endif
%if %{with bootstrap}
BuildRequires:  javapackages-bootstrap
%else
BuildRequires:  maven-local
BuildRequires:  mvn(junit:junit)
BuildRequires:  mvn(javax.annotation:javax.annotation-api)
BuildRequires:  mvn(net.java.dev.javacc:javacc)
BuildRequires:  mvn(org.codehaus.mojo:build-helper-maven-plugin)
BuildRequires:  mvn(org.codehaus.mojo:javacc-maven-plugin)
%endif

%description
This package contains a Java 1 to 13 Parser with AST generation and
visitor support. The AST records the source code structure, javadoc
and comments. It is also possible to change the AST nodes or create new
ones to modify the source code.

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

%prep
%autosetup -n %{name}-%{name}-parent-%{version} -p1
sed -i 's/\r//' readme.md

%pom_remove_dep -r :junit-bom

%pom_remove_plugin :maven-source-plugin
%pom_remove_plugin :central-publishing-maven-plugin
%pom_remove_plugin -r :jacoco-maven-plugin

%if %{without bnd_maven_plugin}
%pom_remove_plugin :bnd-maven-plugin javaparser-core
mkdir -p javaparser-core/target/classes/META-INF/
touch javaparser-core/target/classes/META-INF/MANIFEST.MF
%endif

%mvn_alias :javaparser-core com.google.code.javaparser:javaparser
sed -i \
  -e 's/ph-javacc-maven-plugin/javacc-maven-plugin/' \
  -e 's/com.helger.maven/org.codehaus.mojo/' \
  javaparser-core/pom.xml
%pom_remove_plugin :templating-maven-plugin javaparser-core
%pom_xpath_inject "pom:build" "
<resources>
  <resource>
    <directory>src/main/java-templates</directory>
    <filtering>true</filtering>
    <targetPath>\${basedir}/src/main/java</targetPath>
  </resource>
</resources>" javaparser-core
%pom_disable_module javaparser-core-testing
%pom_disable_module javaparser-core-testing-bdd
%pom_disable_module javaparser-symbol-solver-core
%pom_disable_module javaparser-symbol-solver-testing
%pom_disable_module javaparser-core-generators
%pom_disable_module javaparser-core-metamodel-generator
%pom_disable_module javaparser-core-serialization

%build
%mvn_build

%install
%mvn_install

%files -f .mfiles
%doc readme.md changelog.md
%license LICENSE LICENSE.APACHE LICENSE.GPL LICENSE.LGPL

%files javadoc -f .mfiles-javadoc
%license LICENSE LICENSE.APACHE LICENSE.GPL LICENSE.LGPL

%changelog
* Thu Feb 26 2026 yaoxin <1024769339@qq.com> - 3.27.1-3
- Unuse bootstrap

* Fri Feb 13 2026 yaoxin <1024769339@qq.com> - 3.27.1-2
- Adapting to maven upgrade

* Thu Oct 16 2025 yaoxin <1024769339@qq.com> - 3.27.1-1
- Update to 3.27.1:
  * Fix: Adjusts the range limits of lambda expression parameters
    to ignore brackets.
  * Fix: issue 4832 Resolving type of fully qualified varargs
    invocation throws IndexOutOfBoundsException
  * Fix: Issue 4829 Infinite loop in DifferenceElementCalculator
    when calling setPermittedTypes
  * XmlPrinter: fix duplicate attribute name in generated xml
  * Use lambda parameter counts and block bodies for improved resolution

* Thu May 15 2025 yaoxin <1024769339@qq.com> - 3.25.10-1
- Upgrade to 3.25.10:
  * Fix strange error when trying to find erasure of generic type 
    where one of two type parameters is an array
  * Fix prevent infinite cycles with static imports
  * Refactor ResolvedReferenceType#equals
  * Fix cannot be 'abstract' and also 'private'. for a private 
    method in an interface

* Sat Aug 1 2020 Jeffery.Gao <gaojianxing@huawei.com> - 3.3.5-1
- Package init