Bug 553769: [Doclet] add support for Java9 Doclet API

  split doclet into a version for Java8 and earlier and one for Java9 or
  newer

Change-Id: I512ebd3781275c26a23dc3f283d1bffd3254ebdc
diff --git a/developers/org.eclipse.ease.helpgenerator/src/org/eclipse/ease/helpgenerator/AbstractModuleDoclet.java b/developers/org.eclipse.ease.helpgenerator/src/org/eclipse/ease/helpgenerator/AbstractModuleDoclet.java
index f31a055..fc1f81a 100644
--- a/developers/org.eclipse.ease.helpgenerator/src/org/eclipse/ease/helpgenerator/AbstractModuleDoclet.java
+++ b/developers/org.eclipse.ease.helpgenerator/src/org/eclipse/ease/helpgenerator/AbstractModuleDoclet.java
@@ -104,10 +104,10 @@
 	}
 
 	public void setParameter(String option, List<String> arguments) {
-		if (ModuleDoclet.OPTION_LINK.equals(option))
+		if (V8ModuleDoclet.OPTION_LINK.equals(option))
 			registerLinks(arguments.get(0));
 
-		else if (ModuleDoclet.OPTION_LINK_OFFLINE.equals(option))
+		else if (V8ModuleDoclet.OPTION_LINK_OFFLINE.equals(option))
 			registerOfflineLinks(arguments.get(0), arguments.get(1) + "/package-list");
 
 		else
@@ -189,9 +189,9 @@
 	}
 
 	public File getRootFolder() throws IOException {
-		final List<String> parameter = fParameters.get(ModuleDoclet.OPTION_PROJECT_ROOT);
+		final List<String> parameter = fParameters.get(V8ModuleDoclet.OPTION_PROJECT_ROOT);
 		if ((parameter == null) || (parameter.size() != 1))
-			throw new IOException("Root folder not found, use " + ModuleDoclet.OPTION_PROJECT_ROOT + " parameter");
+			throw new IOException("Root folder not found, use " + V8ModuleDoclet.OPTION_PROJECT_ROOT + " parameter");
 
 		final File rootFolder = new File(parameter.get(0));
 
@@ -205,7 +205,7 @@
 	}
 
 	public boolean failOnMissingDocs() {
-		final List<String> parameter = fParameters.get(ModuleDoclet.OPTION_FAIL_ON_MISSING_DOCS);
+		final List<String> parameter = fParameters.get(V8ModuleDoclet.OPTION_FAIL_ON_MISSING_DOCS);
 		if ((parameter == null) || (parameter.size() != 1))
 			return true;
 
@@ -213,7 +213,7 @@
 	}
 
 	public boolean failOnHtmlErrors() {
-		final List<String> parameter = fParameters.get(ModuleDoclet.OPTION_FAIL_ON_HTML_ERRORS);
+		final List<String> parameter = fParameters.get(V8ModuleDoclet.OPTION_FAIL_ON_HTML_ERRORS);
 		if ((parameter == null) || (parameter.size() != 1))
 			return true;
 
diff --git a/developers/org.eclipse.ease.helpgenerator/src/org/eclipse/ease/helpgenerator/V8ModuleDoclet.java b/developers/org.eclipse.ease.helpgenerator/src/org/eclipse/ease/helpgenerator/V8ModuleDoclet.java
new file mode 100644
index 0000000..58662cb
--- /dev/null
+++ b/developers/org.eclipse.ease.helpgenerator/src/org/eclipse/ease/helpgenerator/V8ModuleDoclet.java
@@ -0,0 +1,116 @@
+/*******************************************************************************
+ * Copyright (c) 2014 Christian Pontesegger and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v2.0
+ * which accompanies this distribution, and is available at
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
+ * Contributors:
+ *     Christian Pontesegger - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.ease.helpgenerator;
+
+import java.util.List;
+
+import org.eclipse.ease.helpgenerator.sunapi.Java5ModuleDoclet;
+
+import com.sun.javadoc.DocErrorReporter;
+import com.sun.javadoc.Doclet;
+import com.sun.javadoc.LanguageVersion;
+import com.sun.javadoc.RootDoc;
+
+public class V8ModuleDoclet extends Doclet {
+
+	public static final String OPTION_PROJECT_ROOT = "-root";
+	public static final String OPTION_LINK = "-link";
+	public static final String OPTION_LINK_OFFLINE = "-linkoffline";
+	public static final String OPTION_FAIL_ON_HTML_ERRORS = "-failOnHTMLError";
+	public static final String OPTION_FAIL_ON_MISSING_DOCS = "-failOnMissingDocs";
+
+	public static boolean start(final RootDoc root) {
+		final Java5ModuleDoclet doclet = new Java5ModuleDoclet();
+		doclet.setRootDoc(root);
+
+		// parse options
+		final String[][] options = root.options();
+		for (final String[] option : options) {
+
+			if (OPTION_PROJECT_ROOT.equals(option[0]))
+				doclet.setParameter(OPTION_PROJECT_ROOT, List.of(option[1]));
+
+			else if (OPTION_LINK.equals(option[0]))
+				doclet.registerLinks(option[1]);
+
+			else if (OPTION_LINK_OFFLINE.equals(option[0]))
+				doclet.registerOfflineLinks(option[1], option[2] + "/package-list");
+
+			else if (OPTION_FAIL_ON_HTML_ERRORS.equals(option[0]))
+				doclet.setParameter(OPTION_FAIL_ON_HTML_ERRORS, List.of(option[1]));
+
+			else if (OPTION_FAIL_ON_MISSING_DOCS.equals(option[0]))
+				doclet.setParameter(OPTION_FAIL_ON_MISSING_DOCS, List.of(option[1]));
+		}
+
+		return doclet.run();
+	}
+
+	public static LanguageVersion languageVersion() {
+		return LanguageVersion.JAVA_1_5;
+	}
+
+	public static int optionLength(final String option) {
+		if (OPTION_PROJECT_ROOT.equals(option))
+			return 2;
+
+		if (OPTION_LINK.equals(option))
+			return 2;
+
+		if (OPTION_LINK_OFFLINE.equals(option))
+			return 3;
+
+		if (OPTION_FAIL_ON_HTML_ERRORS.equals(option))
+			return 2;
+
+		if (OPTION_FAIL_ON_MISSING_DOCS.equals(option))
+			return 2;
+
+		if ("-encoding".equals(option))
+			return 2;
+
+		if ("-protected".equals(option))
+			return 1;
+
+		if ("-author".equals(option))
+			return 1;
+
+		if ("-bottom".equals(option))
+			return 2;
+
+		if ("-charset".equals(option))
+			return 2;
+
+		if ("-docencoding".equals(option))
+			return 2;
+
+		if ("-doctitle".equals(option))
+			return 2;
+
+		if ("-windowtitle".equals(option))
+			return 2;
+
+		if ("-d".equals(option))
+			return 2;
+
+		if ("-use".equals(option))
+			return 1;
+
+		if ("-version".equals(option))
+			return 1;
+
+		return Doclet.optionLength(option);
+	}
+
+	public static boolean validOptions(final String options[][], final DocErrorReporter reporter) {
+		return true;
+	}
+}
diff --git a/developers/org.eclipse.ease.helpgenerator/src/org/eclipse/ease/helpgenerator/ModuleDoclet.java b/developers/org.eclipse.ease.helpgenerator/src/org/eclipse/ease/helpgenerator/V9ModuleDoclet.java
similarity index 63%
rename from developers/org.eclipse.ease.helpgenerator/src/org/eclipse/ease/helpgenerator/ModuleDoclet.java
rename to developers/org.eclipse.ease.helpgenerator/src/org/eclipse/ease/helpgenerator/V9ModuleDoclet.java
index e7260d2..f4e1cf9 100644
--- a/developers/org.eclipse.ease.helpgenerator/src/org/eclipse/ease/helpgenerator/ModuleDoclet.java
+++ b/developers/org.eclipse.ease.helpgenerator/src/org/eclipse/ease/helpgenerator/V9ModuleDoclet.java
@@ -19,17 +19,11 @@
 import javax.lang.model.SourceVersion;
 
 import org.eclipse.ease.helpgenerator.docletapi.Jep221ModuleDoclet;
-import org.eclipse.ease.helpgenerator.sunapi.Java5ModuleDoclet;
-
-import com.sun.javadoc.DocErrorReporter;
-import com.sun.javadoc.Doclet;
-import com.sun.javadoc.LanguageVersion;
-import com.sun.javadoc.RootDoc;
 
 import jdk.javadoc.doclet.DocletEnvironment;
 import jdk.javadoc.doclet.Reporter;
 
-public class ModuleDoclet extends Doclet implements jdk.javadoc.doclet.Doclet {
+public class V9ModuleDoclet implements jdk.javadoc.doclet.Doclet {
 
 	public static final String OPTION_PROJECT_ROOT = "-root";
 	public static final String OPTION_LINK = "-link";
@@ -37,97 +31,6 @@
 	public static final String OPTION_FAIL_ON_HTML_ERRORS = "-failOnHTMLError";
 	public static final String OPTION_FAIL_ON_MISSING_DOCS = "-failOnMissingDocs";
 
-	// ---------- Java 1.5 API
-
-	public static boolean start(final RootDoc root) {
-		final Java5ModuleDoclet doclet = new Java5ModuleDoclet();
-		doclet.setRootDoc(root);
-
-		// parse options
-		final String[][] options = root.options();
-		for (final String[] option : options) {
-
-			if (OPTION_PROJECT_ROOT.equals(option[0]))
-				doclet.setParameter(OPTION_PROJECT_ROOT, List.of(option[1]));
-
-			else if (OPTION_LINK.equals(option[0]))
-				doclet.registerLinks(option[1]);
-
-			else if (OPTION_LINK_OFFLINE.equals(option[0]))
-				doclet.registerOfflineLinks(option[1], option[2] + "/package-list");
-
-			else if (OPTION_FAIL_ON_HTML_ERRORS.equals(option[0]))
-				doclet.setParameter(OPTION_FAIL_ON_HTML_ERRORS, List.of(option[1]));
-
-			else if (OPTION_FAIL_ON_MISSING_DOCS.equals(option[0]))
-				doclet.setParameter(OPTION_FAIL_ON_MISSING_DOCS, List.of(option[1]));
-		}
-
-		return doclet.run();
-	}
-
-	public static LanguageVersion languageVersion() {
-		return LanguageVersion.JAVA_1_5;
-	}
-
-	public static int optionLength(final String option) {
-		if (OPTION_PROJECT_ROOT.equals(option))
-			return 2;
-
-		if (OPTION_LINK.equals(option))
-			return 2;
-
-		if (OPTION_LINK_OFFLINE.equals(option))
-			return 3;
-
-		if (OPTION_FAIL_ON_HTML_ERRORS.equals(option))
-			return 2;
-
-		if (OPTION_FAIL_ON_MISSING_DOCS.equals(option))
-			return 2;
-
-		if ("-encoding".equals(option))
-			return 2;
-
-		if ("-protected".equals(option))
-			return 1;
-
-		if ("-author".equals(option))
-			return 1;
-
-		if ("-bottom".equals(option))
-			return 2;
-
-		if ("-charset".equals(option))
-			return 2;
-
-		if ("-docencoding".equals(option))
-			return 2;
-
-		if ("-doctitle".equals(option))
-			return 2;
-
-		if ("-windowtitle".equals(option))
-			return 2;
-
-		if ("-d".equals(option))
-			return 2;
-
-		if ("-use".equals(option))
-			return 1;
-
-		if ("-version".equals(option))
-			return 1;
-
-		return Doclet.optionLength(option);
-	}
-
-	public static boolean validOptions(final String options[][], final DocErrorReporter reporter) {
-		return true;
-	}
-
-	// ---------- Java 11 API
-
 	private AbstractModuleDoclet fModuleDoclet = null;
 
 	@Override
diff --git a/developers/org.eclipse.ease.helpgenerator/test/org/eclipse/ease/helpgenerator/IntegrationTestJava11API.java b/developers/org.eclipse.ease.helpgenerator/test/org/eclipse/ease/helpgenerator/IntegrationTestJava11API.java
index f854d97..4323c19 100644
--- a/developers/org.eclipse.ease.helpgenerator/test/org/eclipse/ease/helpgenerator/IntegrationTestJava11API.java
+++ b/developers/org.eclipse.ease.helpgenerator/test/org/eclipse/ease/helpgenerator/IntegrationTestJava11API.java
@@ -30,7 +30,7 @@
 		return documentationTool.run(System.in, System.out, System.err,
 
 				"-sourcepath", new File("./resources/org.eclipse.ease.helpgenerator.testproject/src").getAbsolutePath(), "-root",
-				new File("./resources/org.eclipse.ease.helpgenerator.testproject").getAbsolutePath(), "-doclet", ModuleDoclet.class.getName(), "-docletpath",
+				new File("./resources/org.eclipse.ease.helpgenerator.testproject").getAbsolutePath(), "-doclet", V9ModuleDoclet.class.getName(), "-docletpath",
 				new File("./target/classes").getAbsolutePath(),
 
 				"-failOnHTMLError", Boolean.toString(failOnHtmlError), "-failOnMissingDocs", Boolean.toString(failOnMissingDocs),
diff --git a/developers/org.eclipse.ease.helpgenerator/test/org/eclipse/ease/helpgenerator/IntegrationTestJava5API.java b/developers/org.eclipse.ease.helpgenerator/test/org/eclipse/ease/helpgenerator/IntegrationTestJava5API.java
index aa62d54..cdf400b 100644
--- a/developers/org.eclipse.ease.helpgenerator/test/org/eclipse/ease/helpgenerator/IntegrationTestJava5API.java
+++ b/developers/org.eclipse.ease.helpgenerator/test/org/eclipse/ease/helpgenerator/IntegrationTestJava5API.java
@@ -26,7 +26,7 @@
 		return com.sun.tools.javadoc.Main.execute(new String[] {
 				"-sourcepath", new File("./resources/org.eclipse.ease.helpgenerator.testproject/src").getAbsolutePath(),
 				"-root", new File("./resources/org.eclipse.ease.helpgenerator.testproject").getAbsolutePath(),
-				"-doclet", ModuleDoclet.class.getName(),
+				"-doclet", V8ModuleDoclet.class.getName(),
 				"-docletpath",  new File("./target/classes").getAbsolutePath(),
 
 				"-failOnHTMLError", Boolean.toString(failOnHtmlError),