Java Code Examples for org.gradle.api.tasks.SourceSet#getTaskName()
The following examples show how to use
org.gradle.api.tasks.SourceSet#getTaskName() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AvroPlugin.java From gradle-avro-plugin with Apache License 2.0 | 6 votes |
private static TaskProvider<GenerateAvroJavaTask> configureJavaGenerationTask(final Project project, final SourceSet sourceSet, TaskProvider<GenerateAvroProtocolTask> protoTaskProvider) { String taskName = sourceSet.getTaskName("generate", "avroJava"); TaskProvider<GenerateAvroJavaTask> javaTaskProvider = project.getTasks().register(taskName, GenerateAvroJavaTask.class, task -> { task.setDescription(String.format("Generates %s Avro Java source files from schema/protocol definition files.", sourceSet.getName())); task.setGroup(GROUP_SOURCE_GENERATION); task.source(getAvroSourceDir(project, sourceSet)); task.source(protoTaskProvider); task.include("**/*." + SCHEMA_EXTENSION, "**/*." + PROTOCOL_EXTENSION); task.getOutputDir().convention(getGeneratedOutputDir(project, sourceSet, JAVA_EXTENSION)); sourceSet.getJava().srcDir(task.getOutputDir()); JavaCompile compileJavaTask = project.getTasks().named(sourceSet.getCompileJavaTaskName(), JavaCompile.class).get(); task.getOutputCharacterEncoding().convention(project.provider(() -> Optional.ofNullable(compileJavaTask.getOptions().getEncoding()).orElse(Charset.defaultCharset().name()))); }); project.getTasks().named(sourceSet.getCompileJavaTaskName(), JavaCompile.class, compileJavaTask -> { compileJavaTask.source(javaTaskProvider); }); return javaTaskProvider; }
Example 2
Source File: TransportPlugin.java From transport with BSD 2-Clause "Simplified" License | 5 votes |
/** * Creates and configures a task to generate UDF wrappers for a given platform */ private TaskProvider<GenerateWrappersTask> configureGenerateWrappersTask(Project project, Platform platform, SourceSet inputSourceSet, SourceSet outputSourceSet) { /* Creates a generateWrapper task for a given platform. E.g For the Presto platform, task generatePrestoWrappers { generatorClass = 'com.linkedin.transport.codegen.PrestoWrapperGenerator' inputClassesDirs = sourceSets.main.output.classesDirs sourcesOutputDir = sourceSets.presto.java.srcDirs[0] resourcesOutputDir = sourceSets.presto.resources.srcDirs[0] dependsOn classes } prestoClasses.dependsOn(generatePrestoWrappers) */ String taskName = outputSourceSet.getTaskName("generate", "Wrappers"); File sourcesOutputDir = getSourceDirectorySet(outputSourceSet, platform.getLanguage()).getSrcDirs().iterator().next(); File resourcesOutputDir = outputSourceSet.getResources().getSrcDirs().iterator().next(); TaskProvider<GenerateWrappersTask> generateWrappersTask = project.getTasks().register(taskName, GenerateWrappersTask.class, task -> { task.setDescription("Generates Transport UDF wrappers for " + platform.getName()); task.getGeneratorClass().set(platform.getWrapperGeneratorClass().getName()); task.getInputClassesDirs().set(inputSourceSet.getOutput().getClassesDirs()); task.getSourcesOutputDir().set(sourcesOutputDir); task.getResourcesOutputDir().set(resourcesOutputDir); task.dependsOn(project.getTasks().named(inputSourceSet.getClassesTaskName())); }); project.getTasks() .named(outputSourceSet.getCompileTaskName(platform.getLanguage().toString())) .configure(task -> task.dependsOn(generateWrappersTask)); return generateWrappersTask; }
Example 3
Source File: SpringJavaFormatPlugin.java From spring-javaformat with Apache License 2.0 | 5 votes |
private <T extends FormatterTask> T addSourceTask(SourceSet sourceSet, Class<T> taskType, String name, String desc) { String taskName = sourceSet.getTaskName(name, null); T task = this.project.getTasks().create(taskName, taskType); task.setDescription(desc + " for " + sourceSet.getName()); task.setSource(sourceSet.getAllJava()); return task; }
Example 4
Source File: CodeGeneratorPlugin.java From gradle-plugins with MIT License | 5 votes |
@Override public void apply(Project project) { CodeGeneratorConfiguration codeGenerator = project.getExtensions().create("codeGenerator", CodeGeneratorConfiguration.class, project.getObjects()); Configuration codeGeneratorConfiguration = project.getConfigurations().create("codeGenerator"); JavaPluginConvention plugin = project.getConvention().getPlugin(JavaPluginConvention.class); for (SourceSet sourceSet : plugin.getSourceSets()) { String outputDir = project.getBuildDir() + "/generated-src/generator/" + sourceSet.getName(); File outputDirFile = new File(outputDir); project.getLogger().debug("Using output dir {}", outputDir); File inputDir = new File(project.getProjectDir() + "/src/code-generator/" + sourceSet.getName()); sourceSet.getJava().srcDir(inputDir); sourceSet.getJava().srcDir(outputDirFile); project.getLogger().debug("Using input dir {}", inputDir); String taskName = sourceSet.getTaskName("generate", "Code"); TaskProvider<GenerateCodeTask> generate = project.getTasks().register(taskName, GenerateCodeTask.class, s -> { s.setGroup("generate"); s.getOutputDir().set(outputDirFile); if(inputDir.isDirectory()) { s.getInputDir().set(inputDir); } s.getSourceSet().set(sourceSet.getName()); s.getCodeGeneratorClasspath().from(codeGeneratorConfiguration); s.getConfigurationValues().set(codeGenerator.getConfigurationValues()); s.dependsOn(codeGeneratorConfiguration); }); project.getTasks().named(sourceSet.getCompileJavaTaskName(), t -> t.dependsOn(generate)); } }
Example 5
Source File: ClasspathScanPlugin.java From joinfaces with Apache License 2.0 | 5 votes |
private void configureClasspathScan(SourceSet sourceSet) { String taskName = sourceSet.getTaskName("scanJoinfaces", "Classpath"); TaskProvider<ClasspathScan> scanTaskProvider = this.project.getTasks().register(taskName, ClasspathScan.class, scanTask -> { scanTask.getDestinationDir().set(this.project.getLayout().getBuildDirectory().dir("joinfaces/" + sourceSet.getName())); scanTask.getClasspath().from((Callable<FileCollection>) () -> this.project.getConfigurations().getByName(sourceSet.getRuntimeClasspathConfigurationName())); scanTask.getClasspath().from(this.project.getTasks().named(sourceSet.getCompileJavaTaskName())); }); this.project.getPlugins().withType(GroovyPlugin.class, groovyPlugin -> scanTaskProvider.configure(scanTask -> scanTask.getClasspath().from(this.project.getTasks().named(sourceSet.getCompileTaskName("groovy"))) ) ); this.project.getPlugins().withType(ScalaBasePlugin.class, scalaBasePlugin -> scanTaskProvider.configure(scanTask -> scanTask.getClasspath().from(this.project.getTasks().named(sourceSet.getCompileTaskName("scala"))) ) ); this.project.getPlugins().withId("kotlin", kotlinPlugin -> scanTaskProvider.configure(scanTask -> scanTask.getClasspath().from(this.project.getTasks().named(sourceSet.getCompileTaskName("kotlin"))) ) ); this.project.getPlugins().withId("org.jetbrains.kotlin.jvm", kotlinPlugin -> scanTaskProvider.configure(scanTask -> scanTask.getClasspath().from(this.project.getTasks().named(sourceSet.getCompileTaskName("kotlin"))) ) ); sourceSet.getOutput().dir(Collections.singletonMap("builtBy", scanTaskProvider), scanTaskProvider.flatMap(ClasspathScan::getDestinationDir)); }
Example 6
Source File: CodeGeneratorPlugin.java From gradle-plugins with MIT License | 5 votes |
@Override public void apply(Project project) { CodeGeneratorConfiguration codeGenerator = project.getExtensions().create("codeGenerator", CodeGeneratorConfiguration.class, project.getObjects()); Configuration codeGeneratorConfiguration = project.getConfigurations().create("codeGenerator"); JavaPluginConvention plugin = project.getConvention().getPlugin(JavaPluginConvention.class); for (SourceSet sourceSet : plugin.getSourceSets()) { String outputDir = project.getBuildDir() + "/generated-src/generator/" + sourceSet.getName(); File outputDirFile = new File(outputDir); project.getLogger().debug("Using output dir {}", outputDir); File inputDir = new File(project.getProjectDir() + "/src/code-generator/" + sourceSet.getName()); sourceSet.getJava().srcDir(inputDir); sourceSet.getJava().srcDir(outputDirFile); project.getLogger().debug("Using input dir {}", inputDir); String taskName = sourceSet.getTaskName("generate", "Code"); TaskProvider<GenerateCodeTask> generate = project.getTasks().register(taskName, GenerateCodeTask.class, s -> { s.setGroup("generate"); s.getOutputDir().set(outputDirFile); if(inputDir.isDirectory()) { s.getInputDir().set(inputDir); } s.getSourceSet().set(sourceSet.getName()); s.getCodeGeneratorClasspath().from(codeGeneratorConfiguration); s.getConfigurationValues().set(codeGenerator.getConfigurationValues()); s.dependsOn(codeGeneratorConfiguration); }); project.getTasks().named(sourceSet.getCompileJavaTaskName(), t -> t.dependsOn(generate)); } }
Example 7
Source File: AvroPlugin.java From gradle-avro-plugin with Apache License 2.0 | 5 votes |
private static TaskProvider<GenerateAvroProtocolTask> configureProtocolGenerationTask(final Project project, final SourceSet sourceSet) { String taskName = sourceSet.getTaskName("generate", "avroProtocol"); return project.getTasks().register(taskName, GenerateAvroProtocolTask.class, task -> { task.setDescription( String.format("Generates %s Avro protocol definition files from IDL files.", sourceSet.getName())); task.setGroup(GROUP_SOURCE_GENERATION); task.source(getAvroSourceDir(project, sourceSet)); task.include("**/*." + IDL_EXTENSION); task.setClasspath(project.getConfigurations().getByName(RUNTIME_CLASSPATH_CONFIGURATION_NAME)); task.getOutputDir().convention(getGeneratedOutputDir(project, sourceSet, PROTOCOL_EXTENSION)); }); }
Example 8
Source File: DefaultWeavingSourceSet.java From gradle-plugins with MIT License | 4 votes |
public DefaultWeavingSourceSet(SourceSet sourceSet) { aspectConfigurationName = sourceSet.getTaskName("", "aspect"); inpathConfigurationName = sourceSet.getTaskName("", "inpath"); }
Example 9
Source File: DefaultWeavingSourceSet.java From gradle-plugins with MIT License | 4 votes |
public DefaultWeavingSourceSet(SourceSet sourceSet) { aspectConfigurationName = sourceSet.getTaskName("", "aspect"); inpathConfigurationName = sourceSet.getTaskName("", "inpath"); }