Java 类org.gradle.api.tasks.scala.ScalaCompile 实例源码

项目:Reer    文件:ScalaBasePlugin.java   
private static void configureCompileDefaults(final Project project, final ScalaRuntime scalaRuntime) {
    project.getTasks().withType(ScalaCompile.class, new Action<ScalaCompile>() {
        @Override
        public void execute(final ScalaCompile compile) {
            compile.getConventionMapping().map("scalaClasspath", new Callable<FileCollection>() {
                @Override
                public FileCollection call() throws Exception {
                    return scalaRuntime.inferScalaClasspath(compile.getClasspath());
                }
            });
            compile.getConventionMapping().map("zincClasspath", new Callable<Configuration>() {
                @Override
                public Configuration call() throws Exception {
                    Configuration config = project.getConfigurations().getAt(ZINC_CONFIGURATION_NAME);
                    if (config.getDependencies().isEmpty()) {
                        project.getDependencies().add("zinc", "com.typesafe.zinc:zinc:" + DefaultScalaToolProvider.DEFAULT_ZINC_VERSION);
                    }
                    return config;
                }
            });
        }
    });
}
项目:intellij-ce-playground    文件:ScalaModelBuilderImpl.java   
@Override
public Object buildAll(String modelName, Project project) {
  final ScalaPlugin scalaPlugin = project.getPlugins().findPlugin(ScalaPlugin.class);
  if (scalaPlugin == null) return null;

  final ScalaModelImpl scalaModel = new ScalaModelImpl();

  for (Task task : project.getTasks()) {
    if (task instanceof ScalaCompile && COMPILE_SCALA_TASK.equals(task.getName())) {
      ScalaCompile scalaCompile = (ScalaCompile)task;
      scalaModel.setScalaClasspath(scalaCompile.getScalaClasspath().getFiles());
      scalaModel.setZincClasspath(scalaCompile.getZincClasspath().getFiles());
      scalaModel.setScalaCompileOptions(create(scalaCompile.getScalaCompileOptions()));
      scalaModel.setTargetCompatibility(scalaCompile.getTargetCompatibility());
      scalaModel.setSourceCompatibility(scalaCompile.getSourceCompatibility());
      break;
    }
  }

  return scalaModel;
}
项目:Reer    文件:ScalaBasePlugin.java   
private static void configureScalaCompile(final Project project, JavaBasePlugin javaPlugin, final SourceSet sourceSet) {
    String taskName = sourceSet.getCompileTaskName("scala");
    final ScalaCompile scalaCompile = project.getTasks().create(taskName, ScalaCompile.class);
    scalaCompile.dependsOn(sourceSet.getCompileJavaTaskName());
    javaPlugin.configureForSourceSet(sourceSet, scalaCompile);
    Convention scalaConvention = (Convention) InvokerHelper.getProperty(sourceSet, "convention");
    ScalaSourceSet scalaSourceSet = scalaConvention.findPlugin(ScalaSourceSet.class);
    scalaCompile.setDescription("Compiles the " + scalaSourceSet.getScala() + ".");
    scalaCompile.setSource(scalaSourceSet.getScala());
    project.getTasks().getByName(sourceSet.getClassesTaskName()).dependsOn(taskName);

    // cannot use convention mapping because the resulting object won't be serializable
    // cannot compute at task execution time because we need association with source set
    project.getGradle().addBuildListener(new BuildAdapter() {
        @Override
        public void projectsEvaluated(Gradle gradle) {
            IncrementalCompileOptions incrementalOptions = scalaCompile.getScalaCompileOptions().getIncrementalOptions();
            if (incrementalOptions.getAnalysisFile() == null) {
                String analysisFilePath = project.getBuildDir().getPath() + "/tmp/scala/compilerAnalysis/" + scalaCompile.getName() + ".analysis";
                incrementalOptions.setAnalysisFile(new File(analysisFilePath));
            }

            if (incrementalOptions.getPublishedCode() == null) {
                Jar jarTask = (Jar) project.getTasks().findByName(sourceSet.getJarTaskName());
                incrementalOptions.setPublishedCode(jarTask == null ? null : jarTask.getArchivePath());
            }
        }
    });
}