Search in sources :

Example 41 with SourceSet

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);
}
Also used : SourceSet(org.gradle.api.tasks.SourceSet) FileCollection(org.gradle.api.file.FileCollection) SourceSetContainer(org.gradle.api.tasks.SourceSetContainer) File(java.io.File)

Example 42 with SourceSet

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;
}
Also used : SourceSet(org.gradle.api.tasks.SourceSet) TaskContainer(org.gradle.api.tasks.TaskContainer) Configuration(org.gradle.api.artifacts.Configuration) ConfigurationContainer(org.gradle.api.artifacts.ConfigurationContainer) SourceSetContainer(org.gradle.api.tasks.SourceSetContainer)

Example 43 with SourceSet

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);
}
Also used : Project(org.gradle.api.Project) SourceSet(org.gradle.api.tasks.SourceSet) JavaPluginConvention(org.gradle.api.plugins.JavaPluginConvention) Convention(org.gradle.api.plugins.Convention) JavaPluginConvention(org.gradle.api.plugins.JavaPluginConvention) AbstractFileCollection(org.gradle.api.internal.file.AbstractFileCollection) FileCollection(org.gradle.api.file.FileCollection) SourceSetContainer(org.gradle.api.tasks.SourceSetContainer) SourceSetOutput(org.gradle.api.tasks.SourceSetOutput) File(java.io.File) HashSet(java.util.HashSet) Before(org.junit.Before)

Example 44 with SourceSet

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());
}
Also used : List(java.util.List) Properties(java.util.Properties) java.io(java.io) Project(org.gradle.api.Project) JavaPluginConvention(org.gradle.api.plugins.JavaPluginConvention) SourceSetContainer(org.gradle.api.tasks.SourceSetContainer) IAppDomain(ilargia.entitas.codeGeneration.interfaces.IAppDomain) Collectors(java.util.stream.Collectors) SourceSet(org.gradle.api.tasks.SourceSet) SourceSet(org.gradle.api.tasks.SourceSet) SourceSetContainer(org.gradle.api.tasks.SourceSetContainer)

Example 45 with SourceSet

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));
}
Also used : CompatibilityLogChecker(com.linkedin.pegasus.gradle.internal.CompatibilityLogChecker) Arrays(java.util.Arrays) PublishRestModelTask(com.linkedin.pegasus.gradle.tasks.PublishRestModelTask) ValidateExtensionSchemaTask(com.linkedin.pegasus.gradle.tasks.ValidateExtensionSchemaTask) JavaPlugin(org.gradle.api.plugins.JavaPlugin) IdeaPlugin(org.gradle.plugins.ide.idea.IdeaPlugin) CheckSnapshotTask(com.linkedin.pegasus.gradle.tasks.CheckSnapshotTask) EclipsePlugin(org.gradle.plugins.ide.eclipse.EclipsePlugin) Task(org.gradle.api.Task) PublishingExtension(org.gradle.api.publish.PublishingExtension) Javadoc(org.gradle.api.tasks.javadoc.Javadoc) JavaBasePlugin(org.gradle.api.plugins.JavaBasePlugin) ConfigurationContainer(org.gradle.api.artifacts.ConfigurationContainer) TaskProvider(org.gradle.api.tasks.TaskProvider) Locale(java.util.Locale) Map(java.util.Map) TranslateSchemasTask(com.linkedin.pegasus.gradle.tasks.TranslateSchemasTask) CheckPegasusSnapshotTask(com.linkedin.pegasus.gradle.tasks.CheckPegasusSnapshotTask) Method(java.lang.reflect.Method) Path(java.nio.file.Path) GradleVersion(org.gradle.util.GradleVersion) IdeaModule(org.gradle.plugins.ide.idea.model.IdeaModule) Delete(org.gradle.api.tasks.Delete) Project(org.gradle.api.Project) Collection(java.util.Collection) ChangedFileReportTask(com.linkedin.pegasus.gradle.tasks.ChangedFileReportTask) Set(java.util.Set) IvyPublishPlugin(org.gradle.api.publish.ivy.plugins.IvyPublishPlugin) GeneratePegasusSnapshotTask(com.linkedin.pegasus.gradle.tasks.GeneratePegasusSnapshotTask) Collectors(java.util.stream.Collectors) IvyPublication(org.gradle.api.publish.ivy.IvyPublication) List(java.util.List) IdlOptions(com.linkedin.pegasus.gradle.PegasusOptions.IdlOptions) JavaPluginExtension(org.gradle.api.plugins.JavaPluginExtension) Pattern(java.util.regex.Pattern) ProcessResources(org.gradle.language.jvm.tasks.ProcessResources) GenerateRestClientTask(com.linkedin.pegasus.gradle.tasks.GenerateRestClientTask) GenerateRestModelTask(com.linkedin.pegasus.gradle.tasks.GenerateRestModelTask) HashMap(java.util.HashMap) Function(java.util.function.Function) FileCollection(org.gradle.api.file.FileCollection) TreeSet(java.util.TreeSet) ArrayList(java.util.ArrayList) SourceSet(org.gradle.api.tasks.SourceSet) HashSet(java.util.HashSet) Configuration(org.gradle.api.artifacts.Configuration) LifecycleBasePlugin(org.gradle.language.base.plugins.LifecycleBasePlugin) Sync(org.gradle.api.tasks.Sync) SourceSetContainer(org.gradle.api.tasks.SourceSetContainer) CheckRestModelTask(com.linkedin.pegasus.gradle.tasks.CheckRestModelTask) JavaCompile(org.gradle.api.tasks.compile.JavaCompile) Properties(java.util.Properties) Jar(org.gradle.api.tasks.bundling.Jar) Action(org.gradle.api.Action) Files(java.nio.file.Files) JavaPluginConvention(org.gradle.api.plugins.JavaPluginConvention) ValidateSchemaAnnotationTask(com.linkedin.pegasus.gradle.tasks.ValidateSchemaAnnotationTask) IOException(java.io.IOException) EclipseModel(org.gradle.plugins.ide.eclipse.model.EclipseModel) File(java.io.File) CheckIdlTask(com.linkedin.pegasus.gradle.tasks.CheckIdlTask) GenerateDataTemplateTask(com.linkedin.pegasus.gradle.tasks.GenerateDataTemplateTask) GenerateAvroSchemaTask(com.linkedin.pegasus.gradle.tasks.GenerateAvroSchemaTask) GradleException(org.gradle.api.GradleException) Collections(java.util.Collections) Plugin(org.gradle.api.Plugin) Copy(org.gradle.api.tasks.Copy) InputStream(java.io.InputStream) IdlOptions(com.linkedin.pegasus.gradle.PegasusOptions.IdlOptions) Map(java.util.Map) HashMap(java.util.HashMap) File(java.io.File)

Aggregations

SourceSet (org.gradle.api.tasks.SourceSet)55 File (java.io.File)28 SourceSetContainer (org.gradle.api.tasks.SourceSetContainer)24 Project (org.gradle.api.Project)20 Configuration (org.gradle.api.artifacts.Configuration)19 JavaPluginConvention (org.gradle.api.plugins.JavaPluginConvention)18 JavaCompile (org.gradle.api.tasks.compile.JavaCompile)15 ConfigurationContainer (org.gradle.api.artifacts.ConfigurationContainer)14 List (java.util.List)13 Task (org.gradle.api.Task)13 JavaPlugin (org.gradle.api.plugins.JavaPlugin)12 JavaPluginExtension (org.gradle.api.plugins.JavaPluginExtension)12 Set (java.util.Set)11 Collectors (java.util.stream.Collectors)11 Collections (java.util.Collections)10 Action (org.gradle.api.Action)10 Plugin (org.gradle.api.Plugin)10 JavaBasePlugin (org.gradle.api.plugins.JavaBasePlugin)10 Jar (org.gradle.api.tasks.bundling.Jar)10 HashSet (java.util.HashSet)9