use of org.gradle.api.tasks.SourceSet in project checkstyle-idea by jshiell.
the class CustomSourceSetCreator method configureJacocoTask.
private void configureJacocoTask(final JacocoReportBase pJacocoTask) {
pJacocoTask.setGroup(LifecycleBasePlugin.VERIFICATION_GROUP);
final SourceSetContainer sourceSets = (SourceSetContainer) project.getProperties().get("sourceSets");
final SourceSet csaccessSourceSet = sourceSets.getByName(CSACCESS_SOURCESET_NAME);
pJacocoTask.setClassDirectories(csaccessSourceSet.getOutput().getClassesDirs());
pJacocoTask.setSourceDirectories(csaccessSourceSet.getJava().getSourceDirectories());
final FileCollection execFiles = project.files(project.getTasks().withType(CsaccessTestTask.class).stream().map((final CsaccessTestTask task) -> {
//
return new File(project.getBuildDir() + "/jacoco", task.getName() + ".exec");
}).collect(Collectors.toList()));
pJacocoTask.setExecutionData(execFiles);
}
use of org.gradle.api.tasks.SourceSet in project checkstyle-idea by jshiell.
the class CustomSourceSetCreator method establishCsAccessSourceSet.
public CustomSourceSetCreator establishCsAccessSourceSet() {
final SourceSetContainer sourceSets = (SourceSetContainer) project.getProperties().get("sourceSets");
final SourceSet mainSourceSet = sourceSets.getByName(SourceSet.MAIN_SOURCE_SET_NAME);
// Create the 'csaccess' source set
final SourceSet csaccessSourceSet = sourceSets.create(CSACCESS_SOURCESET_NAME);
csaccessSourceSet.setCompileClasspath(csaccessSourceSet.getCompileClasspath().plus(mainSourceSet.getOutput()));
csaccessSourceSet.setRuntimeClasspath(csaccessSourceSet.getRuntimeClasspath().plus(mainSourceSet.getOutput()));
sourceSets.add(csaccessSourceSet);
// Derive all its configurations from 'main', so 'csaccess' code can see 'main' code
final ConfigurationContainer configurations = project.getConfigurations();
final Configuration compileConfig = configurations.getByName(mainSourceSet.getCompileConfigurationName());
final Configuration compileOnlyConfig = configurations.getByName(mainSourceSet.getCompileOnlyConfigurationName());
final Configuration compileClasspathConfig = configurations.getByName(mainSourceSet.getCompileClasspathConfigurationName());
final Configuration runtimeConfig = configurations.getByName(mainSourceSet.getRuntimeConfigurationName());
configurations.getByName(csaccessSourceSet.getCompileConfigurationName()).extendsFrom(compileConfig);
configurations.getByName(csaccessSourceSet.getCompileOnlyConfigurationName()).extendsFrom(compileOnlyConfig);
configurations.getByName(csaccessSourceSet.getCompileClasspathConfigurationName()).extendsFrom(compileClasspathConfig);
configurations.getByName(csaccessSourceSet.getRuntimeConfigurationName()).extendsFrom(runtimeConfig);
// Wire task dependencies to match the classpath dependencies (arrow means "depends on"):
// - compileTestJava -> compileCsaccessJava
// - testClasses -> csaccessClasses
// - jar -> csaccessClasses
final TaskContainer tasks = project.getTasks();
tasks.getByName(JavaPlugin.COMPILE_TEST_JAVA_TASK_NAME).dependsOn(tasks.getByName(csaccessSourceSet.getCompileJavaTaskName()));
tasks.getByName(JavaPlugin.TEST_CLASSES_TASK_NAME).dependsOn(tasks.getByName(csaccessSourceSet.getClassesTaskName()));
tasks.getByName(JavaPlugin.JAR_TASK_NAME).dependsOn(tasks.getByName(csaccessSourceSet.getClassesTaskName()));
return this;
}
use of org.gradle.api.tasks.SourceSet in project jib by google.
the class GradleSourceFilesConfigurationTest method setUp.
@Before
public void setUp() throws URISyntaxException, IOException {
Project mockProject = Mockito.mock(Project.class);
Convention mockConvention = Mockito.mock(Convention.class);
JavaPluginConvention mockJavaPluginConvention = Mockito.mock(JavaPluginConvention.class);
SourceSetContainer mockSourceSetContainer = Mockito.mock(SourceSetContainer.class);
SourceSet mockMainSourceSet = Mockito.mock(SourceSet.class);
SourceSetOutput mockMainSourceSetOutput = Mockito.mock(SourceSetOutput.class);
Set<File> classesFiles = ImmutableSet.of(Paths.get(Resources.getResource("application/classes").toURI()).toFile());
FileCollection classesFileCollection = new TestFileCollection(classesFiles);
File resourcesOutputDir = Paths.get(Resources.getResource("application/resources").toURI()).toFile();
Set<File> allFiles = new HashSet<>(classesFiles);
allFiles.add(resourcesOutputDir);
allFiles.add(Paths.get(Resources.getResource("application/dependencies/libraryB.jar").toURI()).toFile());
allFiles.add(Paths.get(Resources.getResource("application/dependencies/libraryA.jar").toURI()).toFile());
allFiles.add(Paths.get(Resources.getResource("application/dependencies/dependency-1.0.0.jar").toURI()).toFile());
FileCollection runtimeFileCollection = new TestFileCollection(allFiles);
Mockito.when(mockProject.getConvention()).thenReturn(mockConvention);
Mockito.when(mockConvention.getPlugin(JavaPluginConvention.class)).thenReturn(mockJavaPluginConvention);
Mockito.when(mockJavaPluginConvention.getSourceSets()).thenReturn(mockSourceSetContainer);
Mockito.when(mockSourceSetContainer.getByName("main")).thenReturn(mockMainSourceSet);
Mockito.when(mockMainSourceSet.getOutput()).thenReturn(mockMainSourceSetOutput);
Mockito.when(mockMainSourceSetOutput.getClassesDirs()).thenReturn(classesFileCollection);
Mockito.when(mockMainSourceSetOutput.getResourcesDir()).thenReturn(resourcesOutputDir);
Mockito.when(mockMainSourceSet.getRuntimeClasspath()).thenReturn(runtimeFileCollection);
testGradleSourceFilesConfiguration = GradleSourceFilesConfiguration.getForProject(mockProject);
}
use of org.gradle.api.tasks.SourceSet in project Entitas-Java by Rubentxu.
the class EntitasGradleProject method getSrcDirs.
@Override
public List<String> getSrcDirs() {
SourceSetContainer sourceSets = javaConvention.getSourceSets();
SourceSet mainSourceSet = sourceSets.getByName(SourceSet.MAIN_SOURCE_SET_NAME);
return mainSourceSet.getAllSource().getSrcDirs().stream().map(f -> {
try {
return f.getCanonicalPath();
} catch (IOException e) {
return "";
}
}).collect(Collectors.toList());
}
use of org.gradle.api.tasks.SourceSet in project rest.li by linkedin.
the class PegasusPlugin method buildWatchedRestModelInputDirs.
private static Set<File> buildWatchedRestModelInputDirs(Project project, SourceSet sourceSet) {
@SuppressWarnings("unchecked") Map<String, PegasusOptions> pegasusOptions = (Map<String, PegasusOptions>) project.getExtensions().getExtraProperties().get("pegasus");
File rootPath = new File(project.getProjectDir(), pegasusOptions.get(sourceSet.getName()).restModelOptions.getRestResourcesRootPath());
IdlOptions idlOptions = pegasusOptions.get(sourceSet.getName()).idlOptions;
// if idlItems exist, only watch the smaller subset
return idlOptions.getIdlItems().stream().flatMap(idlItem -> Arrays.stream(idlItem.packageNames)).map(packageName -> new File(rootPath, packageName.replace('.', '/'))).collect(Collectors.toCollection(TreeSet::new));
}
Aggregations