summaryrefslogtreecommitdiff
path: root/javaparser.spec
blob: e25b8c0ab657c271089b7629302fcbc46b9220ac (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
%global debug_package %{nil}

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

BuildRequires:  maven-local
BuildRequires:  java-17-openjdk-devel
# RPM names (rather than mvn(group:artifact) capabilities) are used for the
# external Maven plugins; both package the corresponding artifacts into the
# local xmvn repository.
BuildRequires:  javacc
BuildRequires:  javacc-maven-plugin
BuildRequires:  maven-plugin-build-helper

%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}-%{version}
sed -i 's/\r//' readme.md

# The JUnit BOM import is only used by the (disabled) test modules and is
# not needed to build javaparser-core.
%pom_remove_dep -r :junit-bom

# Release / publishing plugins are not available in the offline build.
%pom_remove_plugin :maven-source-plugin
%pom_remove_plugin :central-publishing-maven-plugin

# Coverage plugin is used by the test modules only.
%pom_remove_plugin -r :jacoco-maven-plugin

%mvn_alias :javaparser-core com.google.code.javaparser:javaparser

# openEuler ships JavaCC 7.0.2, whose Java grammar parser does not accept the
# diamond operator (new NodeList<>()) used in an action-code block of java.jj
# (ParseException at line 3536).  Spell out the type argument so the grammar is
# accepted by the older JavaCC.
sed -i 's/new NodeList<>()/new NodeList<ComponentPatternExpr>()/' \
  javaparser-core/src/main/javacc/java.jj

# ph-javacc-maven-plugin is not packaged in openEuler; the codehaus
# javacc-maven-plugin provides the same JavaCC grammar generation.
sed -i \
  -e 's/ph-javacc-maven-plugin/javacc-maven-plugin/' \
  -e 's/com.helger.maven/org.codehaus.mojo/' \
  javaparser-core/pom.xml

# templating-maven-plugin is unavailable; use an equivalent filtered copy
# of src/main/java-templates into src/main/java instead.
%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

# bnd-maven-plugin (OSGi manifest generation) is not needed; provide an
# empty MANIFEST.MF so that the maven-jar-plugin manifestFile reference
# still resolves.
%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

# Only javaparser-core is packaged; tests, generators and the symbol
# solver carry dependencies that are not part of this package.
%pom_disable_module javaparser-core-testing
%pom_disable_module javaparser-core-testing-bdd
%pom_disable_module javaparser-core-generators
%pom_disable_module javaparser-core-metamodel-generator
%pom_disable_module javaparser-core-serialization
%pom_disable_module javaparser-symbol-solver-core
%pom_disable_module javaparser-symbol-solver-testing

%build
export JAVA_HOME=/usr/lib/jvm/java-17-openjdk
%mvn_build -f

%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
* Mon Nov 02 2026 openEuler Build <build@openeuler.org> - 3.28.0-1
- Initial package