From: Alexandre Rossi <alexandre.rossi@gmail.com>
Subject: Explicitly export java9 private API for compilation
Forwarded: https://sourceforge.net/p/davmail/feature-requests/114/

Davmail uses com.sun.jndi.ldap JDK private API. java9 introduces modules
which hide non public API from java apps. As davmail uses this private API,
it must be explicitly exported.

This is a workaround: the proper fix for this would be to stop using this
private API.

Index: davmail.git/build.xml
===================================================================
--- davmail.git.orig/build.xml	2018-06-27 13:27:56.124869590 +0200
+++ davmail.git/build.xml	2018-06-27 13:27:56.124869590 +0200
@@ -35,6 +35,12 @@
         </not>
     </condition>
 
+    <condition property="is.java9">
+        <not>
+            <matches string="${ant.java.version}" pattern="1\.[0-8]"/>
+        </not>
+    </condition>
+
     <condition property="is.utf8">
         <equals arg1="${file.encoding}" arg2="UTF-8"/>
     </condition>
@@ -73,7 +79,19 @@
         <mkdir dir="target/classes"/>
     </target>
 
-    <target name="compile" depends="init">
+    <target name="compile-java9" depends="init" if="is.java9">
+        <mkdir dir="target/classes"/>
+        <javac srcdir="src/java" destdir="target/classes" source="9" debug="on" encoding="UTF-8"
+               includeantruntime="false">
+            <compilerarg value="--add-exports" />
+            <compilerarg value="java.naming/com.sun.jndi.ldap=ALL-UNNAMED" />
+            <classpath>
+                <path refid="classpath"/>
+            </classpath>
+        </javac>
+    </target>
+
+    <target name="compile-java" depends="init" unless="is.java9">
         <mkdir dir="target/classes"/>
         <javac srcdir="src/java" destdir="target/classes" source="1.6" target="1.6" debug="on" encoding="UTF-8"
                includeantruntime="false">
@@ -81,6 +99,9 @@
                 <path refid="classpath"/>
             </classpath>
         </javac>
+    </target>
+
+    <target name="compile" depends="compile-java,compile-java9">
         <copy todir="target/classes">
             <fileset dir="src/java">
                 <include name="**/*"/>
