static WorkResult execute(ScalaJavaJointCompileSpec spec) { LOGGER.info("Compiling with Zinc Scala compiler."); xsbti.Logger logger = new SbtLoggerAdapter(); com.typesafe.zinc.Compiler compiler = createCompiler(spec.getScalaClasspath(), spec.getZincClasspath(), logger); List<String> scalacOptions = new ScalaCompilerArgumentsGenerator().generate(spec); List<String> javacOptions = new JavaCompilerArgumentsBuilder(spec).includeClasspath(false).build(); Inputs inputs = Inputs.create(ImmutableList.copyOf(spec.getClasspath()), ImmutableList.copyOf(spec.getSource()), spec.getDestinationDir(), scalacOptions, javacOptions, spec.getScalaCompileOptions().getIncrementalOptions().getAnalysisFile(), spec.getAnalysisMap(), "mixed", getIncOptions(), true); if (LOGGER.isDebugEnabled()) { Inputs.debug(inputs, logger); } try { compiler.compile(inputs, logger); } catch (xsbti.CompileFailed e) { throw new CompilationFailedException(e); } return new SimpleWorkResult(true); }
static WorkResult execute(final Iterable<File> scalaClasspath, final Iterable<File> zincClasspath, File gradleUserHome, final ScalaJavaJointCompileSpec spec) { LOGGER.info("Compiling with Zinc Scala compiler."); final xsbti.Logger logger = new SbtLoggerAdapter(); com.typesafe.zinc.Compiler compiler = ZincScalaCompilerFactory.createParallelSafeCompiler(scalaClasspath, zincClasspath, logger, gradleUserHome); List<String> scalacOptions = new ZincScalaCompilerArgumentsGenerator().generate(spec); List<String> javacOptions = new JavaCompilerArgumentsBuilder(spec).includeClasspath(false).build(); Inputs inputs = Inputs.create(ImmutableList.copyOf(spec.getClasspath()), ImmutableList.copyOf(spec.getSource()), spec.getDestinationDir(), scalacOptions, javacOptions, spec.getScalaCompileOptions().getIncrementalOptions().getAnalysisFile(), spec.getAnalysisMap(), "mixed", getIncOptions(), true); if (LOGGER.isDebugEnabled()) { Inputs.debug(inputs, logger); } if (spec.getScalaCompileOptions().isForce()) { GFileUtils.deleteDirectory(spec.getDestinationDir()); } try { compiler.compile(inputs, logger); } catch (xsbti.CompileFailed e) { throw new CompilationFailedException(e); } return new SimpleWorkResult(true); }
private WorkResult delegateAndHandleErrors(ScalaJavaJointCompileSpec spec) { try { return delegate.execute(spec); } catch (CompilationFailedException e) { if (spec.getScalaCompileOptions().isFailOnError()) { throw e; } LOGGER.debug("Ignoring compilation failure."); return new SimpleWorkResult(false); } }
public WorkResult execute(JavaCompileSpec spec) { LOGGER.info("Compiling with JDK Java compiler API."); JavaCompiler.CompilationTask task = createCompileTask(spec); boolean success = task.call(); if (!success) { throw new CompilationFailedException(); } return new SimpleWorkResult(true); }