public List<ProjectModule> getDirectChildrenOfParent() { List<ProjectModule> ret = new ArrayList<ProjectModule>(); final List<ProjectModule> modules = getFlatListOfAllModules(config.getModules()); for (ProjectModule module : modules) { if (module.getParent() == null) { ret.add(module); } } return ret; }
public ProjectModule getModuleForDependency(Dependency dependency) { final List<ProjectModule> allModules = getFlatListOfAllModules(config.getModules()); for (ProjectModule module : allModules) { if (dependency.getGroupId().equals(module.getGroupId()) && dependency.getArtifactId().equals(module.getArtifactId())) { return module; } } return null; }
public ProjectModule getReleasableModule(ProjectModule dependency) { List<ProjectModule> dependenciesSorted = config.getModules(); for (ProjectModule sortedDependency : dependenciesSorted) { if (sortedDependency.getGroupId().equals(dependency.getGroupId()) && sortedDependency.getArtifactId().equals(dependency.getArtifactId())) { return sortedDependency; } } return null; }
public ProjectModule getModuleForIdentifier(Identifier identifier) { final List<ProjectModule> allModules = getFlatListOfAllModules(config.getModules()); for (ProjectModule module : allModules) { if (identifier.getGroupId().equals(module.getGroupId()) && identifier.getArtifactId().equals(module.getArtifactId())) { return module; } } return null; }
public ProjectModule getProjectModuleFromMavenProject(MavenProject mavenProject) throws MojoFailureException { final String parentKey = createProjectIdentifier(mavenProject); for (ProjectModule module : getFlatListOfAllModules(config.getModules())) { final String moduleKey = createProjectIdentifier(module); if (parentKey.equals(moduleKey)) { return module; } } throw new MojoFailureException("Can't find module for MavenProject: " + mavenProject); }
public List<ProjectModule> getFlatListOfAllModules() { return getFlatListOfAllModules(config.getModules()); }
@Override protected com.google.javascript.jscomp.Compiler createCompiler() { return new DossierCompiler(getErrorPrintStream(), config.getModules()); }
@VisibleForTesting static void run(String[] args, FileSystem fileSystem) { Flags flags = Flags.parse(args, fileSystem); Config config = null; try (InputStream stream = newInputStream(flags.config)) { config = Config.load(stream, fileSystem); } catch (IOException e) { e.printStackTrace(System.err); System.exit(-1); } if (flags.printConfig) { Gson gson = new GsonBuilder().setPrettyPrinting().create(); String header = " Configuration "; int len = header.length(); String pad = Strings.repeat("=", len / 2); System.err.println(pad + header + pad); System.err.println(gson.toJson(config.toJson())); System.err.println(Strings.repeat("=", 79)); System.exit(1); } Iterable<String> standardFlags = STANDARD_FLAGS; if (config.isStrict()) { standardFlags = transform( standardFlags, new Function<String, String>() { @Override public String apply(String input) { return input.replace("--jscomp_warning", "--jscomp_error"); } }); } ImmutableList<String> compilerFlags = ImmutableList.<String>builder() .addAll(transform(config.getSources(), toFlag("--js="))) .addAll(transform(config.getModules(), toFlag("--js="))) .addAll(transform(config.getExterns(), toFlag("--externs="))) .add("--language_in=" + config.getLanguage().getName()) .addAll(standardFlags) .build(); PrintStream nullStream = new PrintStream(ByteStreams.nullOutputStream()); args = compilerFlags.toArray(new String[compilerFlags.size()]); Logger log = Logger.getLogger(Main.class.getPackage().getName()); log.setLevel(Level.WARNING); log.addHandler( new Handler() { @Override public void publish(LogRecord record) { System.err.printf( "[%s][%s] %s\n", record.getLevel(), record.getLoggerName(), record.getMessage()); } @Override public void flush() {} @Override public void close() {} }); Main main = new Main(args, nullStream, System.err, config); main.runCompiler(); }
private void runCompiler() { if (!shouldRunCompiler()) { System.exit(-1); } Instant start = Instant.now(); config.getOutputStream().println("Generating documentation..."); int result = 0; try { result = doRun(); } catch (FlagUsageException e) { System.err.println(e.getMessage()); System.exit(-1); } catch (Throwable t) { t.printStackTrace(System.err); System.exit(-2); } if (result != 0) { System.exit(result); } DocWriter writer = new DocWriter( config.getOutput(), Iterables.concat(config.getSources(), config.getModules()), config.getSrcPrefix(), config.getReadme(), config.getCustomPages(), typeRegistry, config.getTypeFilter(), new Linker( config.getOutput(), config.getSrcPrefix(), config.getModulePrefix(), config.getTypeFilter(), typeRegistry), new CommentParser(config.useMarkdown())); try { writer.generateDocs(); if (config.isZipOutput()) { config.getOutput().getFileSystem().close(); } } catch (IOException e) { e.printStackTrace(System.err); System.exit(-3); } Instant stop = Instant.now(); String output = new PeriodFormatterBuilder() .appendHours() .appendSuffix("h") // I hope not... .appendSeparator(" ") .appendMinutes() .appendSuffix("m") .appendSeparator(" ") .appendSecondsWithOptionalMillis() .appendSuffix("s") .toFormatter() .print(new Period(start, stop)); config.getOutputStream().println("Finished in " + output); }