/** * Creates a dummy output directory without compiling the module. Either this method or {@link * #precompile} should be called first. */ synchronized Job.Result initWithoutPrecompile(TreeLogger logger) throws UnableToCompleteException { long startTime = System.currentTimeMillis(); CompileDir compileDir = outboxDir.makeCompileDir(logger); TreeLogger compileLogger = makeCompileLogger(compileDir, logger); ModuleDef module; try { module = loadModule(compileLogger); logger.log(TreeLogger.INFO, "Loading Java files in " + inputModuleName + "."); CompilerOptions loadOptions = new CompilerOptionsImpl(compileDir, inputModuleName, options); compilerContext = compilerContextBuilder.options(loadOptions).unitCache(unitCache).build(); // Loads and parses all the Java files in the GWT application using the JDT. // (This is warmup to make compiling faster later; we stop at this point to avoid // needing to know the binding properties.) module.getCompilationState(compileLogger, compilerContext); setUpCompileDir(compileDir, module, compileLogger); if (launcherDir != null) { launcherDir.update(module, compileDir, compileLogger); } outputModuleName.set(module.getName()); } finally { // Make the compile log available no matter what happens. lastBuild.set(compileDir); } long elapsedTime = System.currentTimeMillis() - startTime; compileLogger.log(TreeLogger.Type.INFO, "Module setup completed in " + elapsedTime + " ms"); return new Result(compileDir, module.getName(), null); }
/** * Calls the GWT compiler with the appropriate settings. Side-effect: a MinimalRebuildCache for * the current binding properties will be found or created. * * @param job used for reporting progress. (Its result will not be set.) * @return a non-error Job.Result if successful. * @throws UnableToCompleteException for compile failures. */ private Job.Result compile(Job job) throws UnableToCompleteException { assert job.wasSubmitted(); if (compilesDone == 0) { System.setProperty("java.awt.headless", "true"); if (System.getProperty("gwt.speedtracerlog") == null) { System.setProperty( "gwt.speedtracerlog", outboxDir.getSpeedTracerLogFile().getAbsolutePath()); } compilerContext = compilerContextBuilder.unitCache(unitCache).build(); } long startTime = System.currentTimeMillis(); int compileId = ++compilesDone; CompileDir compileDir = outboxDir.makeCompileDir(job.getLogger()); TreeLogger compileLogger = makeCompileLogger(compileDir, job.getLogger()); try { job.onStarted(compileId, compileDir); boolean success = doCompile(compileLogger, compileDir, job); if (!success) { compileLogger.log(TreeLogger.Type.ERROR, "Compiler returned false"); throw new UnableToCompleteException(); } } finally { // Make the error log available no matter what happens lastBuild.set(compileDir); } long elapsedTime = System.currentTimeMillis() - startTime; compileLogger.log( TreeLogger.Type.INFO, String.format("%.3fs total -- Compile completed", elapsedTime / 1000d)); return new Result(publishedCompileDir, outputModuleName.get(), null); }