Epoch:          1

Name:           ecj
Version:        4.9
Release:        3
Summary:        the Eclipse Compiler for Java
License:        EPL-2.0
URL:            http://www.eclipse.org

Source0:        http://download.eclipse.org/eclipse/downloads/drops4/R-4.9-201809060745/ecjsrc-4.9.jar
Source1:        ecj.sh.in
Source3:        https://repo1.maven.org/maven2/org/eclipse/jdt/core/compiler/ecj/%{version}/ecj-%{version}.pom
Source4:        MANIFEST.MF
Source5:        java10api.jar

Patch0:         javaAPI.patch

BuildArch:      noarch
BuildRequires:  ant javapackages-local

%description
ECJ is the the Eclipse Compiler for Java.  It is also known as the JDT Core batch compiler.

%package_help

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

sed -i -e 's|debuglevel=\"lines,source\"|debug=\"yes\"|g' build.xml
sed -i -e "s/Xlint:none/Xlint:none -encoding cp1252/g" build.xml
rm -f org/eclipse/jdt/core/JDTCompilerAdapter.java
cp %{SOURCE3} pom.xml
mkdir -p scripts/binary/META-INF/
cp %{SOURCE4} scripts/binary/META-INF/MANIFEST.MF

%pom_remove_dep org.apache.ant:ant

%mvn_file :ecj ecj jdtcore
%mvn_alias org.eclipse.jdt.core.compiler:ecj org.eclipse.jdt:core org.eclipse.jdt:ecj \
  org.eclipse.tycho:org.eclipse.jdt.core org.eclipse.tycho:org.eclipse.jdt.compiler.apt
%mvn_artifact "org.eclipse:java10api:jar:10" %{SOURCE5}
%mvn_alias "org.eclipse:java10api:jar:10" "org.eclipse:java9api:jar:9"

%build
ant -Djavaapi=%{SOURCE5}

%install
%mvn_artifact pom.xml ecj.jar
%mvn_install

sed -i 's/[0-9a-f]\{8\}-[0-9a-f]\{4\}-[0-9a-f]\{4\}-[0-9a-f]\{4\}-[0-9a-f]\{12\}/f2f42549-cfab-4d71-be48-5e9f9a41e5f5/g' $(find %{_buildrootdir} -name ecj.xml)

install -p -D -m0755 %{SOURCE1} %{buildroot}%{_bindir}/ecj
mkdir -p %{buildroot}%{_mandir}/man1
install -m 644 -p ecj.1 %{buildroot}%{_mandir}/man1/ecj.1

%files -f .mfiles
%defattr(-,root,root)
%doc about.html
%{_bindir}/ecj

%files help
%defattr(-,root,root)
%{_mandir}/man1/ecj*

%changelog
* Wed Dec 4 2019 openEuler Buildteam <buildteam@openeuler.org> - 1:4.9-3
- Package init
