protected SourceSet addSourceSetTestIntegration(Project project) {
    SourceSet testIntegrationSourceSet =
        GradleUtil.addSourceSet(project, TEST_INTEGRATION_SOURCE_SET_NAME);

    Configuration testIntegrationCompileConfiguration =
        GradleUtil.getConfiguration(
            project, testIntegrationSourceSet.getCompileConfigurationName());

    Configuration testCompileConfiguration =
        GradleUtil.getConfiguration(project, JavaPlugin.TEST_COMPILE_CONFIGURATION_NAME);

    testIntegrationCompileConfiguration.extendsFrom(testCompileConfiguration);

    Configuration testIntegrationRuntimeConfiguration =
        GradleUtil.getConfiguration(
            project, testIntegrationSourceSet.getRuntimeConfigurationName());

    Configuration testRuntimeConfiguration =
        GradleUtil.getConfiguration(project, JavaPlugin.TEST_RUNTIME_CONFIGURATION_NAME);

    testIntegrationRuntimeConfiguration.extendsFrom(
        testRuntimeConfiguration, testIntegrationCompileConfiguration);

    SourceSet mainSourceSet = GradleUtil.getSourceSet(project, SourceSet.MAIN_SOURCE_SET_NAME);

    FileCollection compileClasspath = testIntegrationSourceSet.getCompileClasspath();

    testIntegrationSourceSet.setCompileClasspath(compileClasspath.plus(mainSourceSet.getOutput()));

    FileCollection runtimeClasspath = testIntegrationSourceSet.getRuntimeClasspath();

    testIntegrationSourceSet.setRuntimeClasspath(runtimeClasspath.plus(mainSourceSet.getOutput()));

    return testIntegrationSourceSet;
  }
示例#2
0
  private void defineConfigurationsForSourceSet(
      SourceSet sourceSet, ConfigurationContainer configurations) {
    Configuration compileConfiguration =
        configurations.findByName(sourceSet.getCompileConfigurationName());
    if (compileConfiguration == null) {
      compileConfiguration = configurations.create(sourceSet.getCompileConfigurationName());
    }
    compileConfiguration.setVisible(false);
    compileConfiguration.setDescription(String.format("Compile classpath for %s.", sourceSet));

    Configuration runtimeConfiguration =
        configurations.findByName(sourceSet.getRuntimeConfigurationName());
    if (runtimeConfiguration == null) {
      runtimeConfiguration = configurations.create(sourceSet.getRuntimeConfigurationName());
    }
    runtimeConfiguration.setVisible(false);
    runtimeConfiguration.extendsFrom(compileConfiguration);
    runtimeConfiguration.setDescription(String.format("Runtime classpath for %s.", sourceSet));

    sourceSet.setCompileClasspath(compileConfiguration);
    sourceSet.setRuntimeClasspath(sourceSet.getOutput().plus(runtimeConfiguration));
  }
  protected void configureEclipseClasspath(Project project, SourceSet testIntegrationSourceSet) {

    EclipseModel eclipseModel = GradleUtil.getExtension(project, EclipseModel.class);

    EclipseClasspath eclipseClasspath = eclipseModel.getClasspath();

    Collection<Configuration> plusConfigurations = eclipseClasspath.getPlusConfigurations();

    Configuration configuration =
        GradleUtil.getConfiguration(
            project, testIntegrationSourceSet.getRuntimeConfigurationName());

    plusConfigurations.add(configuration);
  }
  protected void configureIdeaModule(Project project, SourceSet testIntegrationSourceSet) {

    IdeaModel ideaModel = GradleUtil.getExtension(project, IdeaModel.class);

    IdeaModule ideaModule = ideaModel.getModule();

    Map<String, Map<String, Collection<Configuration>>> scopes = ideaModule.getScopes();

    Map<String, Collection<Configuration>> testScope = scopes.get("TEST");

    Collection<Configuration> plusConfigurations = testScope.get("plus");

    Configuration configuration =
        GradleUtil.getConfiguration(
            project, testIntegrationSourceSet.getRuntimeConfigurationName());

    plusConfigurations.add(configuration);
  }