Files
processing4/java/build.xml
A Samuel Pottinger ee299ef935 Move to ANTLR 4 with Java 11 lang features and localization. (#5)
* Move to ANTLR 4 with Java 11 lang features and localization.

Introduces ANTLR4 and Java 8 language feature support within IDE while also adding additional hooks for localization of syntax error messages, addressing https://github.com/processing/processing/issues/3054 and https://github.com/processing/processing/issues/3055.

The PR is broadly a continuation of https://github.com/processing/processing/issues/3055, bringing it up to speed with the latest Processing master plus the changes introduced at https://github.com/processing/processing/pull/5753. **Requires https://github.com/processing/processing/pull/5753 as pre-requisite.** This introduces a number of edits beyond https://github.com/processing/processing/issues/3055 beyond compatibility with current Processing master and https://github.com/processing/processing/pull/5753 including:

 - Update to the grammar itself
 - Change ANTLR listeners to emit `TextTransform.Edit` to unify JDT-based `PreprocessingService` and `JavaBuild`, removing code with duplicate purpose.
 - Introduction of syntax error rewriting with support for localization.
 - Addition of complete localized strings set for English and Spanish.
 - Addition of partial localized strings set for other languages.
 - Refactor of ANTLR-related code for testability and readability
 - Expansion of tests including full parse tests for new Java features (type inference, lambdas).

* Ask travis for ant upgrade prior to run.

* Ask Travis for java11 update.

* Add openjdk ppa

* Travis no confirmation on add ppa.

* Force newer ant on travis.

* Swtich ant download to www-us mirror.

* Switch ant to 1.10.7

* Start x for unit tests in travis.

* More complete start x in travis.

* Revert x in travis.

* Try x in services.
2019-10-05 23:34:38 -07:00

149 lines
5.0 KiB
XML

<?xml version="1.0"?>
<project name="Java Mode" default="build">
<property name="generated"
value="${basedir}/generated/processing/mode/java/preproc" />
<mkdir dir="${generated}" />
<property name="grammars"
value="${basedir}/src/processing/mode/java/preproc" />
<property name="antlr_jar"
value="${basedir}/mode/antlr-4.7.2-complete.jar" />
<property name="mode_jar"
value="${basedir}/mode/JavaMode.jar" />
<classloader taskname="antlr">
<classpath path="${antlr_jar}" />
</classloader>
<target name="clean" description="Clean the build directories">
<delete dir="bin" />
<delete dir="bin-test" />
<delete file="${mode_jar}" />
<delete>
<fileset dir="${generated}">
<include name="*.java" />
<include name="*.tokens" />
<include name="*.txt" />
<include name="*.g" />
<include name="*.smap" />
<include name="*.properties" />
</fileset>
</delete>
</target>
<target name="preproc" description="Compile ANTLR 4 grammar">
<java classname="org.antlr.v4.Tool"
failonerror="true">
<classpath path="${antlr_jar}" />
<arg value="-o" />
<arg value="${generated}" />
<arg value="-package" />
<arg value="processing.mode.java.preproc" />
<arg value="${grammars}/Processing.g4" />
</java>
</target>
<path id="classpath.base">
<pathelement location="../core/library/core.jar" />
<pathelement location="../app/pde.jar" />
<pathelement location="../app/lib/ant.jar" />
<pathelement location="../app/lib/ant-launcher.jar" />
<pathelement location="../app/lib/apple.jar" />
<pathelement location="../app/lib/jna.jar" />
<pathelement location="../app/lib/jna-platform.jar" />
<pathelement location="mode/antlr-4.7.2-complete.jar" />
<pathelement location="mode/classpath-explorer-1.0.jar" />
<pathelement location="mode/jsoup-1.7.1.jar" />
<pathelement location="mode/org.netbeans.swing.outline.jar" />
<pathelement location="mode/jdi.jar" />
<pathelement location="mode/jdimodel.jar" />
<pathelement location="mode/com.ibm.icu.jar" />
<pathelement location="mode/org.eclipse.core.contenttype.jar" />
<pathelement location="mode/org.eclipse.core.jobs.jar" />
<pathelement location="mode/org.eclipse.core.resources.jar" />
<pathelement location="mode/org.eclipse.core.runtime.jar" />
<pathelement location="mode/org.eclipse.equinox.common.jar" />
<pathelement location="mode/org.eclipse.equinox.preferences.jar" />
<pathelement location="mode/org.eclipse.jdt.compiler.apt.jar" />
<pathelement location="mode/org.eclipse.jdt.core.jar" />
<pathelement location="mode/org.eclipse.osgi.jar" />
<pathelement location="mode/org.eclipse.text.jar" />
</path>
<path id="classpath.test">
<pathelement location="../core/library-test/junit-4.8.1.jar" />
<pathelement location="../core/library-test/mockito-all-1.10.19.jar" />
<pathelement location = "bin-test" />
<path refid="classpath.base" />
</path>
<macrodef name="compilecommon">
<attribute name="destdir"/>
<attribute name="srcdir"/>
<attribute name="classpath"/>
<sequential>
<condition property="core-built">
<available file="../core/library/core.jar" />
</condition>
<fail unless="core-built" message="Please first build the core library and make sure it is located at ../core/library/core.jar" />
<condition property="app-built">
<available file="../app/pde.jar" />
</condition>
<fail unless="app-built" message="Please build app first and make sure it is located at ../app/pde.jar" />
<mkdir dir="@{destdir}" />
<!-- in some cases, pde.jar was not getting built
https://github.com/processing/processing/issues/1792 -->
<delete file="${mode_jar}" />
<!-- env used to set classpath below -->
<property environment="env" />
<javac source="1.8"
target="1.8"
destdir="@{destdir}"
excludes="**/tools/format/**"
encoding="UTF-8"
includeAntRuntime="false"
debug="on"
nowarn="true"
compiler="modern">
<src path="@{srcdir}" />
<src path="generated" />
<classpath refid="@{classpath}"/>
</javac>
</sequential>
</macrodef>
<target name="test-compile" depends="preproc">
<compilecommon srcdir="src; test/processing" destdir="bin-test" classpath="classpath.test" />
</target>
<target name="test" depends="test-compile">
<junit haltonfailure="true">
<classpath refid="classpath.test" />
<formatter type="brief" usefile="false" />
<batchtest>
<fileset dir="test">
<include name="**/*Test.java" />
<include name="**/*Tests.java" />
</fileset>
</batchtest>
</junit>
</target>
<target name="compile" depends="test" description="Compile sources">
<compilecommon srcdir="src" destdir="bin" classpath="classpath.base" />
</target>
<target name="build" depends="compile" description="Build PDE">
<jar basedir="bin" destfile="${mode_jar}" />
</target>
</project>