Java Code Examples for com.sun.tools.javadoc.Main#execute()
The following examples show how to use
com.sun.tools.javadoc.Main#execute() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ReleaseOption.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
void doRunTest(int expectedResult, Predicate<String> validate, String... args) { System.err.println("running with args: " + Arrays.asList(args)); List<String> options = new ArrayList<>(); options.addAll(Arrays.asList(args)); options.add("-XDrawDiagnostics"); options.add(new File(System.getProperty("test.src", "."), "ReleaseOptionSource.java").getPath()); StringWriter out = new StringWriter(); PrintWriter pw = new PrintWriter(out); int actualResult = Main.execute("javadoc", pw, pw, pw, "com.sun.tools.doclets.formats.html.HtmlDoclet", options.toArray(new String[0])); System.err.println("actual result=" + actualResult); System.err.println("actual output=" + out.toString()); if (actualResult != expectedResult) throw new Error("Exit code not as expected"); if (!validate.test(out.toString())) { throw new Error("Output not as expected"); } }
Example 2
Source File: OutputRedirect.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
static void doTest() { ByteArrayOutputStream redirectedOutput = new ByteArrayOutputStream(); PrintStream originalOutput = System.out; // redirect System.out to a buffer System.setOut(new PrintStream(redirectedOutput)); PrintWriter sink = new PrintWriter(new ByteArrayOutputStream()); // execute javadoc int result = Main.execute("javadoc", sink, sink, sink, "com.sun.tools.doclets.standard.Standard", new String[] {"p"} ); // test whether javadoc did any output to System.out if (redirectedOutput.toByteArray().length > 0) { originalOutput.println("Test failed; here's what javadoc wrote on its standard output:"); originalOutput.println(redirectedOutput.toString()); throw new Error("javadoc output wasn\'t properly redirected"); } else if (result != 0) { throw new Error("javadoc run failed"); } else { originalOutput.println("OK, good"); } }
Example 3
Source File: SarlDocletTester.java From sarl with Apache License 2.0 | 5 votes |
/** Run the Javadoc generator. * * @param args arguments. * @throws RuntimeException a runtime exception. */ @SuppressWarnings("checkstyle:all") public static void main(String[] args) { try { System.setProperty("http.proxyHost", "proxy.utbm.fr"); //$NON-NLS-1$ //$NON-NLS-2$ System.setProperty("http.proxyPort", "3128"); //$NON-NLS-1$ //$NON-NLS-2$ Main.execute(new String[] { "-private", //$NON-NLS-1$ "-source", "1.8", //$NON-NLS-1$ //$NON-NLS-2$ "-doclet", SarlDoclet.class.getName(), //$NON-NLS-1$ "-sourcepath", "/home/sgalland/git/sarl/main/coreplugins/io.sarl.lang.core/src", //$NON-NLS-1$ //$NON-NLS-2$ //"-sourcepath", "/home/sgalland/git/sarl/main/apiplugins/io.sarl.core/src-gen", //$NON-NLS-1$ //$NON-NLS-2$ //"-sourcepath", "/home/sgalland/git/sarl/main/coreplugins/io.sarl.lang.core/src:/home/sgalland/git/sarl/main/apiplugins/io.sarl.core/src-gen", //$NON-NLS-1$ //$NON-NLS-2$ "-d", "/home/sgalland/tmp/gen-site", //$NON-NLS-1$ //$NON-NLS-2$ "-subpackages", "io", //$NON-NLS-1$ //$NON-NLS-2$ "-link", "http://docs.oracle.com/javase/8/docs/api/", //$NON-NLS-1$ //$NON-NLS-2$ "-link", "http://download.eclipse.org/modeling/tmf/xtext/javadoc/2.9/", //$NON-NLS-1$ //$NON-NLS-2$ "-tag", "mavengroupid", //$NON-NLS-1$ //$NON-NLS-2$ "-tag", "mavenartifactid", //$NON-NLS-1$ //$NON-NLS-2$ "-tag", "optionalparam", //$NON-NLS-1$ //$NON-NLS-2$ "-tag", "fires", //$NON-NLS-1$ //$NON-NLS-2$ }); } catch (Throwable ex) { final Throwable cause = Utils.getCause(ex); throw new RuntimeException(cause); } }
Example 4
Source File: OutputRedirect.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
static void doTest() { ByteArrayOutputStream redirectedOutput = new ByteArrayOutputStream(); PrintStream originalOutput = System.out; // redirect System.out to a buffer System.setOut(new PrintStream(redirectedOutput)); PrintWriter sink = new PrintWriter(new ByteArrayOutputStream()); // execute javadoc int result = Main.execute("javadoc", sink, sink, sink, "com.sun.tools.doclets.standard.Standard", new String[] {"p"} ); // test whether javadoc did any output to System.out if (redirectedOutput.toByteArray().length > 0) { originalOutput.println("Test failed; here's what javadoc wrote on its standard output:"); originalOutput.println(redirectedOutput.toString()); throw new Error("javadoc output wasn\'t properly redirected"); } else if (result != 0) { throw new Error("javadoc run failed"); } else { originalOutput.println("OK, good"); } }
Example 5
Source File: OutputRedirect.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
static void doTest() { ByteArrayOutputStream redirectedOutput = new ByteArrayOutputStream(); PrintStream originalOutput = System.out; // redirect System.out to a buffer System.setOut(new PrintStream(redirectedOutput)); PrintWriter sink = new PrintWriter(new ByteArrayOutputStream()); // execute javadoc int result = Main.execute("javadoc", sink, sink, sink, "com.sun.tools.doclets.standard.Standard", new String[] {"p"} ); // test whether javadoc did any output to System.out if (redirectedOutput.toByteArray().length > 0) { originalOutput.println("Test failed; here's what javadoc wrote on its standard output:"); originalOutput.println(redirectedOutput.toString()); throw new Error("javadoc output wasn\'t properly redirected"); } else if (result != 0) { throw new Error("javadoc run failed"); } else { originalOutput.println("OK, good"); } }
Example 6
Source File: OutputRedirect.java From hottub with GNU General Public License v2.0 | 5 votes |
static void doTest() { ByteArrayOutputStream redirectedOutput = new ByteArrayOutputStream(); PrintStream originalOutput = System.out; // redirect System.out to a buffer System.setOut(new PrintStream(redirectedOutput)); PrintWriter sink = new PrintWriter(new ByteArrayOutputStream()); // execute javadoc int result = Main.execute("javadoc", sink, sink, sink, "com.sun.tools.doclets.standard.Standard", new String[] {"p"} ); // test whether javadoc did any output to System.out if (redirectedOutput.toByteArray().length > 0) { originalOutput.println("Test failed; here's what javadoc wrote on its standard output:"); originalOutput.println(redirectedOutput.toString()); throw new Error("javadoc output wasn\'t properly redirected"); } else if (result != 0) { throw new Error("javadoc run failed"); } else { originalOutput.println("OK, good"); } }
Example 7
Source File: CompletionError.java From hottub with GNU General Public License v2.0 | 5 votes |
public static void main(String[] args) throws Exception { JavaCompiler compiler = ToolProvider.getSystemJavaCompiler(); String[] templateParts = template.split("#"); int sources = templateParts.length / 2; for (int source = 0; source < sources; source++) { StringBuilder testSource = new StringBuilder(); for (int i = 0; i < templateParts.length; i += 2) { testSource.append(templateParts[i]); if (i == 2 * source) { testSource.append(templateParts[i + 1]); } } test = 0; testsDone = false; while (!testsDone) { List<JavaSource> fileObjects = Arrays.asList(new JavaSource("CompletionErrorAuxiliary", testSource.toString()), new JavaSource("CompletionErrorMissing", "public class CompletionErrorMissing {}"), new JavaSource("CompletionErrorIntfMissing", "public interface CompletionErrorIntfMissing {}"), new JavaSource("CompletionErrorExcMissing", "public class CompletionErrorExcMissing extends Exception {}")); Boolean result = compiler.getTask(null, null, null, Arrays.asList("-d", "."), null, fileObjects).call(); if (!result) throw new Error(); for (String delete : new String[] {"CompletionErrorMissing.class", "CompletionErrorIntfMissing.class", "CompletionErrorExcMissing.class"}) { Files.delete(Paths.get(delete)); } // run javadoc: if (Main.execute("javadoc", "CompletionError", CompletionError.class.getClassLoader(), "-classpath", ".", System.getProperty("test.src", ".") + File.separatorChar + "CompletionError.java") != 0) throw new Error(); } } }
Example 8
Source File: OutputRedirect.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
static void doTest() { ByteArrayOutputStream redirectedOutput = new ByteArrayOutputStream(); PrintStream originalOutput = System.out; // redirect System.out to a buffer System.setOut(new PrintStream(redirectedOutput)); PrintWriter sink = new PrintWriter(new ByteArrayOutputStream()); // execute javadoc int result = Main.execute("javadoc", sink, sink, sink, "com.sun.tools.doclets.standard.Standard", new String[] {"p"} ); // test whether javadoc did any output to System.out if (redirectedOutput.toByteArray().length > 0) { originalOutput.println("Test failed; here's what javadoc wrote on its standard output:"); originalOutput.println(redirectedOutput.toString()); throw new Error("javadoc output wasn\'t properly redirected"); } else if (result != 0) { throw new Error("javadoc run failed"); } else { originalOutput.println("OK, good"); } }
Example 9
Source File: CompletionError.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
public static void main(String[] args) throws Exception { String[] templateParts = template.split("#"); int sources = templateParts.length / 2; for (int source = 0; source < sources; source++) { StringBuilder testSource = new StringBuilder(); for (int i = 0; i < templateParts.length; i += 2) { testSource.append(templateParts[i]); if (i == 2 * source) { testSource.append(templateParts[i + 1]); } } test = 0; testsDone = false; while (!testsDone) { ToolBox tb = new ToolBox(); new JavacTask(tb) .sources(testSource.toString(), "public class CompletionErrorMissing {}", "public interface CompletionErrorIntfMissing {}", "public class CompletionErrorExcMissing extends Exception {}") .outdir(".") .run() .writeAll(); tb.deleteFiles("CompletionErrorMissing.class", "CompletionErrorIntfMissing.class", "CompletionErrorExcMissing.class"); // run javadoc: if (Main.execute("javadoc", "CompletionError", CompletionError.class.getClassLoader(), "-classpath", "." + File.pathSeparator + testClassPath, new File(testSrc, "CompletionError.java").getPath()) != 0) throw new Error(); } } }
Example 10
Source File: CompletionError.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
public static void main(String[] args) throws Exception { JavaCompiler compiler = ToolProvider.getSystemJavaCompiler(); String[] templateParts = template.split("#"); int sources = templateParts.length / 2; for (int source = 0; source < sources; source++) { StringBuilder testSource = new StringBuilder(); for (int i = 0; i < templateParts.length; i += 2) { testSource.append(templateParts[i]); if (i == 2 * source) { testSource.append(templateParts[i + 1]); } } test = 0; testsDone = false; while (!testsDone) { List<JavaSource> fileObjects = Arrays.asList(new JavaSource("CompletionErrorAuxiliary", testSource.toString()), new JavaSource("CompletionErrorMissing", "public class CompletionErrorMissing {}"), new JavaSource("CompletionErrorIntfMissing", "public interface CompletionErrorIntfMissing {}"), new JavaSource("CompletionErrorExcMissing", "public class CompletionErrorExcMissing extends Exception {}")); Boolean result = compiler.getTask(null, null, null, Arrays.asList("-d", "."), null, fileObjects).call(); if (!result) throw new Error(); for (String delete : new String[] {"CompletionErrorMissing.class", "CompletionErrorIntfMissing.class", "CompletionErrorExcMissing.class"}) { Files.delete(Paths.get(delete)); } // run javadoc: if (Main.execute("javadoc", "CompletionError", CompletionError.class.getClassLoader(), "-classpath", ".", System.getProperty("test.src", ".") + File.separatorChar + "CompletionError.java") != 0) throw new Error(); } } }
Example 11
Source File: OutputRedirect.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
static void doTest() { ByteArrayOutputStream redirectedOutput = new ByteArrayOutputStream(); PrintStream originalOutput = System.out; // redirect System.out to a buffer System.setOut(new PrintStream(redirectedOutput)); PrintWriter sink = new PrintWriter(new ByteArrayOutputStream()); // execute javadoc int result = Main.execute("javadoc", sink, sink, sink, "com.sun.tools.doclets.standard.Standard", new String[] {"p"} ); // test whether javadoc did any output to System.out if (redirectedOutput.toByteArray().length > 0) { originalOutput.println("Test failed; here's what javadoc wrote on its standard output:"); originalOutput.println(redirectedOutput.toString()); throw new Error("javadoc output wasn\'t properly redirected"); } else if (result != 0) { throw new Error("javadoc run failed"); } else { originalOutput.println("OK, good"); } }
Example 12
Source File: CompletionError.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
public static void main(String[] args) throws Exception { JavaCompiler compiler = ToolProvider.getSystemJavaCompiler(); String[] templateParts = template.split("#"); int sources = templateParts.length / 2; for (int source = 0; source < sources; source++) { StringBuilder testSource = new StringBuilder(); for (int i = 0; i < templateParts.length; i += 2) { testSource.append(templateParts[i]); if (i == 2 * source) { testSource.append(templateParts[i + 1]); } } test = 0; testsDone = false; while (!testsDone) { List<JavaSource> fileObjects = Arrays.asList(new JavaSource("CompletionErrorAuxiliary", testSource.toString()), new JavaSource("CompletionErrorMissing", "public class CompletionErrorMissing {}"), new JavaSource("CompletionErrorIntfMissing", "public interface CompletionErrorIntfMissing {}"), new JavaSource("CompletionErrorExcMissing", "public class CompletionErrorExcMissing extends Exception {}")); Boolean result = compiler.getTask(null, null, null, Arrays.asList("-d", "."), null, fileObjects).call(); if (!result) throw new Error(); for (String delete : new String[] {"CompletionErrorMissing.class", "CompletionErrorIntfMissing.class", "CompletionErrorExcMissing.class"}) { Files.delete(Paths.get(delete)); } // run javadoc: if (Main.execute("javadoc", "CompletionError", CompletionError.class.getClassLoader(), "-classpath", ".", System.getProperty("test.src", ".") + File.separatorChar + "CompletionError.java") != 0) throw new Error(); } } }
Example 13
Source File: SwaggerPropertiesDocletTest.java From springfox-javadoc with Apache License 2.0 | 5 votes |
@Test public void testPropertiesGeneration() throws IOException { StringWriter err = new StringWriter(); StringWriter warn = new StringWriter(); StringWriter notice = new StringWriter(); String[] args = new String[] { "-sourcepath", "./src/test/java", "-subpackages", "springfox.javadoc", "springfox.javadoc", "-classdir", BUILD_PROPERTY_FILE_LOCATION }; Main.execute( "SwaggerPropertiesDoclet", new PrintWriter(err), new PrintWriter(warn), new PrintWriter(notice), SwaggerPropertiesDoclet.class.getName(), args); Properties props = generatedProperties(); assertEquals("test method", props.getProperty("/test/test.GET.notes")); assertEquals("dummy value", props.getProperty("/test/test.GET.return")); assertEquals("dummy param", props.getProperty("/test/test.GET.param.param")); assertEquals("without value or path", props.getProperty("/test.POST.notes")); assertEquals("retval", props.getProperty("/test.POST.return")); assertEquals("param", props.getProperty("/test.POST.param.bar")); }
Example 14
Source File: OutputRedirect.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
static void doTest() { ByteArrayOutputStream redirectedOutput = new ByteArrayOutputStream(); PrintStream originalOutput = System.out; // redirect System.out to a buffer System.setOut(new PrintStream(redirectedOutput)); PrintWriter sink = new PrintWriter(new ByteArrayOutputStream()); // execute javadoc int result = Main.execute("javadoc", sink, sink, sink, "com.sun.tools.doclets.standard.Standard", new String[] {"p"} ); // test whether javadoc did any output to System.out if (redirectedOutput.toByteArray().length > 0) { originalOutput.println("Test failed; here's what javadoc wrote on its standard output:"); originalOutput.println(redirectedOutput.toString()); throw new Error("javadoc output wasn\'t properly redirected"); } else if (result != 0) { throw new Error("javadoc run failed"); } else { originalOutput.println("OK, good"); } }
Example 15
Source File: OutputRedirect.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
static void doTest() { ByteArrayOutputStream redirectedOutput = new ByteArrayOutputStream(); PrintStream originalOutput = System.out; // redirect System.out to a buffer System.setOut(new PrintStream(redirectedOutput)); PrintWriter sink = new PrintWriter(new ByteArrayOutputStream()); // execute javadoc int result = Main.execute("javadoc", sink, sink, sink, "com.sun.tools.doclets.standard.Standard", new String[] {"p"} ); // test whether javadoc did any output to System.out if (redirectedOutput.toByteArray().length > 0) { originalOutput.println("Test failed; here's what javadoc wrote on its standard output:"); originalOutput.println(redirectedOutput.toString()); throw new Error("javadoc output wasn\'t properly redirected"); } else if (result != 0) { throw new Error("javadoc run failed"); } else { originalOutput.println("OK, good"); } }
Example 16
Source File: CompletionError.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
public static void main(String[] args) throws Exception { JavaCompiler compiler = ToolProvider.getSystemJavaCompiler(); String[] templateParts = template.split("#"); int sources = templateParts.length / 2; for (int source = 0; source < sources; source++) { StringBuilder testSource = new StringBuilder(); for (int i = 0; i < templateParts.length; i += 2) { testSource.append(templateParts[i]); if (i == 2 * source) { testSource.append(templateParts[i + 1]); } } test = 0; testsDone = false; while (!testsDone) { List<JavaSource> fileObjects = Arrays.asList(new JavaSource("CompletionErrorAuxiliary", testSource.toString()), new JavaSource("CompletionErrorMissing", "public class CompletionErrorMissing {}"), new JavaSource("CompletionErrorIntfMissing", "public interface CompletionErrorIntfMissing {}"), new JavaSource("CompletionErrorExcMissing", "public class CompletionErrorExcMissing extends Exception {}")); Boolean result = compiler.getTask(null, null, null, Arrays.asList("-d", "."), null, fileObjects).call(); if (!result) throw new Error(); for (String delete : new String[] {"CompletionErrorMissing.class", "CompletionErrorIntfMissing.class", "CompletionErrorExcMissing.class"}) { Files.delete(Paths.get(delete)); } // run javadoc: if (Main.execute("javadoc", "CompletionError", CompletionError.class.getClassLoader(), "-classpath", ".", System.getProperty("test.src", ".") + File.separatorChar + "CompletionError.java") != 0) throw new Error(); } } }
Example 17
Source File: SourceInterpreter.java From halo-docs with Apache License 2.0 | 4 votes |
private static RootDoc build() { RootDoc doc = rootDoc != null ? rootDoc.get() : null; if (doc != null) { return doc; } // double check synchronized (lock) { PrintWriter error = null; PrintWriter warn = null; PrintWriter notice = null; try { error = new PrintWriter(new FileOutputStream(new File(srcPath, "errors.log"), true)); warn = new PrintWriter(new FileOutputStream(new File(srcPath, "warns.log"), true)); notice = new PrintWriter(new FileOutputStream(new File(srcPath, "notices.log"), true)); doc = rootDoc != null ? rootDoc.get() : null; if (doc != null) return doc; logger.info("start building root doc soft reference, if building frequently you should increase the JVM memories!"); Main.execute( "httpdoc", error, warn, notice, "javadoc", Javadoc.class.getClassLoader(), "-doclet", Javadoc.class.getName(), "-verbose", "-encoding", "utf-8", "-sourcepath", srcPath, "@" + pkgPath ); doc = rootDoc != null ? rootDoc.get() : null; logger.info("end building root doc found " + (doc != null && doc.classes() != null ? doc.classes().length : 0) + " class(es)"); logger.info("more logs is located in directory: " + srcPath); } catch (IOException e) { logger.error("error building httpdoc", e); } finally { IoKit.close(error); IoKit.close(warn); IoKit.close(notice); } } return doc; }
Example 18
Source File: SourceInterpreter.java From httpdoc with Apache License 2.0 | 4 votes |
private static RootDoc build() { RootDoc doc = rootDoc != null ? rootDoc.get() : null; if (doc != null || hasError) { return doc; } // double check synchronized (lock) { PrintWriter error = null; PrintWriter warn = null; PrintWriter notice = null; try { error = new PrintWriter(new FileOutputStream(new File(srcPath, "errors.log"), true)); warn = new PrintWriter(new FileOutputStream(new File(srcPath, "warns.log"), true)); notice = new PrintWriter(new FileOutputStream(new File(srcPath, "notices.log"), true)); doc = rootDoc != null ? rootDoc.get() : null; if (doc != null) return doc; logger.info("start building root doc soft reference, if building frequently you should increase the JVM memories!"); Main.execute( "httpdoc", error, warn, notice, "javadoc", Javadoc.class.getClassLoader(), "-doclet", Javadoc.class.getName(), "-verbose", "-encoding", "utf-8", "-sourcepath", srcPath, "@" + pkgPath ); // 如果获取不了 if (rootDoc == null) { hasError = true; } doc = rootDoc != null ? rootDoc.get() : null; logger.info("end building root doc found " + (doc != null && doc.classes() != null ? doc.classes().length : 0) + " class(es)"); logger.info("more logs is located in directory: " + srcPath); } catch (IOException e) { logger.error("error building httpdoc", e); } finally { IOKit.close(error); IOKit.close(warn); IOKit.close(notice); } } return doc; }
Example 19
Source File: ExcludeDoclet.java From JPPF with Apache License 2.0 | 4 votes |
/** * Entry point for this doclet. * @param args the command line options. */ public static void main(final String[] args) { String name = ExcludeDoclet.class.getName(); Main.execute(name, name, args); }
Example 20
Source File: ExcludeDoclet.java From Tehreer-Android with Apache License 2.0 | 4 votes |
public static void main(String[] args) { Main.execute(ExcludeDoclet.class.getName(), args); }