コード例 #1
0
  protected Test addTaskTestIntegration(Project project, final SourceSet testIntegrationSourceSet) {

    final Test test = GradleUtil.addTask(project, TEST_INTEGRATION_TASK_NAME, Test.class);

    test.mustRunAfter(JavaPlugin.TEST_TASK_NAME);

    test.setDescription("Runs the integration tests.");
    test.setForkEvery(null);
    test.setGroup(JavaBasePlugin.VERIFICATION_GROUP);

    ConventionMapping conventionMapping = test.getConventionMapping();

    conventionMapping.map(
        "classpath",
        new Callable<FileCollection>() {

          @Override
          public FileCollection call() throws Exception {
            return testIntegrationSourceSet.getRuntimeClasspath();
          }
        });

    conventionMapping.map(
        "testClassesDir",
        new Callable<File>() {

          @Override
          public File call() throws Exception {
            SourceSetOutput sourceSetOutput = testIntegrationSourceSet.getOutput();

            return sourceSetOutput.getClassesDir();
          }
        });

    project.afterEvaluate(
        new Action<Project>() {

          @Override
          public void execute(Project project) {
            Set<String> includes = test.getIncludes();

            if (includes.isEmpty()) {
              test.setIncludes(Collections.singleton("**/*Test.class"));
            }
          }
        });

    return test;
  }
コード例 #2
0
ファイル: JacocoPlugin.java プロジェクト: Cazen/gradle
 private void addDefaultReportTask(final JacocoPluginExtension extension, final Test task) {
   final JacocoReport reportTask =
       project
           .getTasks()
           .create(
               "jacoco" + StringUtils.capitalise(task.getName()) + "Report", JacocoReport.class);
   reportTask.executionData(task);
   reportTask.sourceSets(
       project
           .getConvention()
           .getPlugin(JavaPluginConvention.class)
           .getSourceSets()
           .getByName("main"));
   ConventionMapping taskMapping = ((IConventionAware) reportTask).getConventionMapping();
   taskMapping
       .getConventionValue(reportTask.getReports(), "reports", false)
       .all(
           new Action<Report>() {
             @Override
             public void execute(final Report report) {
               ConventionMapping reportMapping =
                   ((IConventionAware) report).getConventionMapping();
               // reportMapping.map('enabled', Callables.returning(true));
               if (report.getOutputType().equals(Report.OutputType.DIRECTORY)) {
                 reportMapping.map(
                     "destination",
                     new Callable<File>() {
                       @Override
                       public File call() {
                         return new File(
                             extension.getReportsDir(), task.getName() + "/" + report.getName());
                       }
                     });
               } else {
                 reportMapping.map(
                     "destination",
                     new Callable<File>() {
                       @Override
                       public File call() {
                         return new File(
                             extension.getReportsDir(),
                             task.getName() + "/" + reportTask.getName() + "." + report.getName());
                       }
                     });
               }
             }
           });
 }
コード例 #3
0
ファイル: JavaBasePlugin.java プロジェクト: kavanista/gradle
 public void configureForSourceSet(final SourceSet sourceSet, AbstractCompile compile) {
   ConventionMapping conventionMapping;
   compile.setDescription(String.format("Compiles the %s.", sourceSet.getJava()));
   conventionMapping = compile.getConventionMapping();
   compile.setSource(sourceSet.getJava());
   conventionMapping.map(
       "classpath",
       new Callable<Object>() {
         public Object call() throws Exception {
           return sourceSet.getCompileClasspath();
         }
       });
   conventionMapping.map(
       "destinationDir",
       new Callable<Object>() {
         public Object call() throws Exception {
           return sourceSet.getOutput().getClassesDir();
         }
       });
 }
コード例 #4
0
  private void definePathsForSourceSet(
      final SourceSet sourceSet, ConventionMapping outputConventionMapping, final Project project) {
    outputConventionMapping.map(
        "classesDir",
        new Callable<Object>() {
          public Object call() throws Exception {
            String classesDirName = String.format("classes/%s", sourceSet.getName());
            return new File(project.getBuildDir(), classesDirName);
          }
        });
    outputConventionMapping.map(
        "resourcesDir",
        new Callable<Object>() {
          public Object call() throws Exception {
            String classesDirName = String.format("resources/%s", sourceSet.getName());
            return new File(project.getBuildDir(), classesDirName);
          }
        });

    sourceSet.getJava().srcDir(String.format("src/%s/java", sourceSet.getName()));
    sourceSet.getResources().srcDir(String.format("src/%s/resources", sourceSet.getName()));
  }
コード例 #5
0
 private void createCompileJavaTaskForBinary(
     final SourceSet sourceSet, final JavaSourceSet javaSourceSet, Project target) {
   JavaCompile compileTask =
       target.getTasks().create(sourceSet.getCompileJavaTaskName(), JavaCompile.class);
   compileTask.setDescription(String.format("Compiles %s.", javaSourceSet));
   compileTask.setSource(javaSourceSet.getSource());
   compileTask.dependsOn(javaSourceSet);
   ConventionMapping conventionMapping = compileTask.getConventionMapping();
   conventionMapping.map(
       "classpath",
       new Callable<Object>() {
         public Object call() throws Exception {
           return javaSourceSet.getCompileClasspath().getFiles();
         }
       });
   conventionMapping.map(
       "destinationDir",
       new Callable<Object>() {
         public Object call() throws Exception {
           return sourceSet.getOutput().getClassesDir();
         }
       });
 }