File ecj.spec of Package ecj

# spec file for package ecj
# Copyright (c) 2019 SUSE LINUX GmbH, Nuernberg, Germany.
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

# Please submit bugfixes or comments via

%global qualifier R-4.12-201906051800
%global jdk10_revision 45b1d041a4ef
Name:           ecj
Version:        4.12
Release:        0
Summary:        Eclipse Compiler for Java
License:        EPL-2.0 AND GPL-2.0 WITH Classpath-exception-2.0
Group:          Development/Libraries/Java
# Jdk10 sources to build Java API stubs for newer JDKs
# wget -O jdk10u.tar.bz2
# tar xf jdk10u.tar.bz2 && rm jdk10u.tar.bz2
# mv jdk10u-45b1d041a4ef/src/java.compiler/share/classes java10api-src && rm -rf jdk10u-45b1d041a4ef
# tar cJf java10api-src.tar.xz java10api-src && rm -rf java10api-src
Source1:        java10api-src.tar.xz
# Simple pom file to declare org.eclipse:java10api artifact
Source3:        java10api.pom
# Extracted from{qualifier}/ecj-%%{version}.jar
Source4:        MANIFEST.MF
# Always generate debug info when building RPMs
Patch0:         %{name}-rpmdebuginfo.patch
# Include java API stubs in build with java < 9
Patch1:         javaAPI.patch
# Fix build with java >= 9
Patch2:         ecj-encoding.patch
# Patch out deprecation annotation not understood by java 8
Patch3:         jdk10u-jdk8compat.patch
BuildRequires:  ant
BuildRequires:  java-devel >= 1.8
BuildRequires:  javapackages-local
BuildRequires:  unzip
BuildArch:      noarch

ECJ is the Java bytecode compiler of the Eclipse Platform.  It is also known as
the JDT Core batch compiler.

%setup -q -c -a 1
%patch0 -p1
%if %{?pkg_vcmp:%pkg_vcmp java-devel < 9}%{!?pkg_vcmp:1}
%patch2 -p1

sed -i -e 's|debuglevel=\"lines,source\"|debug=\"yes\"|g' build.xml

mkdir -p scripts/binary/META-INF/
cp %{SOURCE4} scripts/binary/META-INF/MANIFEST.MF

# JDTCompilerAdapter isn't used by the batch compiler
rm -f org/eclipse/jdt/core/

# Not compatible with non-modular Java
%if %{?pkg_vcmp:%pkg_vcmp java-devel < 9}%{!?pkg_vcmp:1}
rm -f java10api-src/javax/tools/


mkdir -p build/classes
javac -d build/classes -source 8 -target 8 \
  $(find java10api-src/javax -name \*.java | xargs)
jar -cf java10api.jar -C build/classes .
# Remove everything except the jar, since ant looks for java files in "."
rm -rf java10api-src build/classes

ant \
%if %{?pkg_vcmp:%pkg_vcmp java-devel < 9}%{!?pkg_vcmp:1}
	-Djavaapi=java10api.jar -Drtjar=%{_jvmdir}/jre/lib/rt.jar \

# jar
install -dm 0755 %{buildroot}%{_javadir}/%{name}
install -pm 0644 ecj.jar %{buildroot}%{_javadir}/%{name}/ecj.jar
install -pm 0644 java10api.jar %{buildroot}%{_javadir}/%{name}/java10api.jar

# pom
install -dm 0755 %{buildroot}%{_mavenpomdir}/%{name}
install -pm 0644 %{SOURCE2} %{buildroot}%{_mavenpomdir}/%{name}/ecj.pom
%add_maven_depmap %{name}/ecj.pom %{name}/ecj.jar -a "org.eclipse.jdt:core,org.eclipse.jdt.core.compiler:ecj,org.eclipse.tycho:org.eclipse.jdt.core,org.eclipse.tycho:org.eclipse.jdt.compiler.apt"
install -pm 0644 %{SOURCE3} %{buildroot}%{_mavenpomdir}/%{name}/java10api.pom
%add_maven_depmap %{name}/java10api.pom %{name}/java10api.jar -a "org.eclipse:java9api"

# Install the ecj wrapper script
%jpackage_script org.eclipse.jdt.internal.compiler.batch.Main '' '' ecj ecj true

# Install manpage
mkdir -p %{buildroot}%{_mandir}/man1
install -m 644 -p ecj.1 %{buildroot}%{_mandir}/man1/ecj.1

%files -f .mfiles
%license about.html

openSUSE Build Service is sponsored by