private static GenerateAvroProtocolTask configureProtocolGenerationTask(final Project project, final SourceSet sourceSet) { String taskName = sourceSet.getTaskName("generate", "avroProtocol"); GenerateAvroProtocolTask task = project.getTasks().create(taskName, GenerateAvroProtocolTask.class); 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.getConventionMapping().map("outputDir", new Callable<File>() { @Override public File call() throws Exception { return getGeneratedOutputDir(project, sourceSet, PROTOCOL_EXTENSION); } }); return task; }
String taskName = s.getTaskName("generate", "Code"); project.getTasks().create(taskName, t -> { project.getTasks().getByName(s.getCompileJavaTaskName()).dependsOn(t.getPath());
sourceSet.getAllSource().source(velocitySourceSet.getVelocity()); final String velocityTaskName = sourceSet.getTaskName("process", "Velocity"); VelocityTask velocityTask = project.getTasks().create(velocityTaskName, VelocityTask.class, new Action<VelocityTask>() { @Override
private static void processSourceSet(Project project, SourceSet sourceSet, RockerConfiguration rockerConfig) { // for each source set we will: // 1) Add a new 'rocker' property to the source set RockerSourceSetProperty rockerProperty = new RockerSourceSetProperty(project); new DslObject(sourceSet).getConvention().getPlugins().put( "rocker", rockerProperty); // 2) Create a rocker task for this sourceSet following the gradle // naming conventions final String taskName = sourceSet.getTaskName( "generate", "RockerTemplateSource"); RockerTask rockerTask = project.getTasks().create( taskName, RockerTask.class); rockerTask.setGroup("build"); rockerTask.setDescription("Generate Sources from " + sourceSet.getName() + " Rocker Templates"); rockerTask.setRockerProjectConfig(rockerConfig); // 3) Set source set and sources for task (avoids lookup when executing) rockerTask.setSourceSet(sourceSet); rockerTask.setTemplateDirs(rockerProperty.getRocker().getSrcDirs()); // 4) Make sure that the rocker task is run before compiling // Java sources project.getTasks().getByName(JavaPlugin.COMPILE_JAVA_TASK_NAME) .dependsOn(rockerTask); }
private Task createClassycleTask(final Project project, final ClassycleExtension extension, final SourceSet sourceSet) { final String taskName = sourceSet.getTaskName("classycle", null); final FileCollection classesDirs = sourceSet.getOutput().getClassesDirs(); final File reportFile = getReportingExtension(project).file("classycle_" + sourceSet.getName() + ".txt"); final Task task = project.task(taskName); task.getInputs().files(classesDirs, extension.getDefinitionFile()); task.getOutputs().file(reportFile); task.doLast(new ClassyclePlugin.ClassycleAction(classesDirs, reportFile, extension)); // the classycle task depends on the corresponding classes task final String classesTask = sourceSet.getClassesTaskName(); task.dependsOn(classesTask); if (project.getLogger().isDebugEnabled()) { final StringBuilder sb = new StringBuilder(); for (final File file : classesDirs) { sb.append(file.getAbsolutePath()).append(" "); } project.getLogger() .debug("Created classycle task: " + taskName + ", report file: " + reportFile + ", depends on: " + classesTask + " - sourceSetDirs: " + sb.toString()); } return task; }
private void configureClasspathScan(SourceSet sourceSet) { String taskName = sourceSet.getTaskName("scan", "Classpath"); File baseDir = new File(this.project.getBuildDir(), "joinfaces/" + sourceSet.getName()); ClasspathScan scanTask = this.project.getTasks().create(taskName, ClasspathScan.class); scanTask.getDestinationDir().set(baseDir); this.project.afterEvaluate(p -> { scanTask.getClasspath().from(p.getConfigurations().getByName(sourceSet.getRuntimeClasspathConfigurationName())); scanTask.getClasspath().from(p.getTasks().getByName(sourceSet.getCompileJavaTaskName())); p.getPlugins().withType(GroovyPlugin.class, groovyPlugin -> scanTask.getClasspath().from(p.getTasks().getByName(sourceSet.getCompileTaskName("groovy"))) ); p.getPlugins().withType(ScalaBasePlugin.class, scalaBasePlugin -> scanTask.getClasspath().from(p.getTasks().getByName(sourceSet.getCompileTaskName("scala"))) ); if (p.getPlugins().hasPlugin("kotlin") || p.getPlugins().hasPlugin("org.jetbrains.kotlin.jvm")) { scanTask.getClasspath().from(p.getTasks().getByName(sourceSet.getCompileTaskName("kotlin"))); } sourceSet.getOutput().dir(Collections.singletonMap("builtBy", scanTask), scanTask.getDestinationDir()); }); } }
final String taskName = sourceSet.getTaskName("classycle", null); final File reportFile = reporting.file("classycle/" + name + ".txt"); final Task task = project.task(taskName);
private static GenerateAvroJavaTask configureJavaGenerationTask(final Project project, final SourceSet sourceSet, GenerateAvroProtocolTask protoTask) { String taskName = sourceSet.getTaskName("generate", "avroJava"); GenerateAvroJavaTask task = project.getTasks().create(taskName, GenerateAvroJavaTask.class); task.setDescription(String.format("Generates %s Avro Java source files from schema/protocol definition files.",
String taskName = sourceSet.getTaskName("compile", "Sass");
project.getConfigurations().getByName(sourceSet.getAnnotationProcessorConfigurationName()).extendsFrom(lombokConfiguration); TaskProvider<Delombok> delombokTaskProvider = project.getTasks().register(sourceSet.getTaskName("delombok", ""), Delombok.class, delombok -> { delombok.setDescription("Runs delombok on the " + sourceSet.getName() + " source-set"); delombok.getTarget().set(project.getLayout().getBuildDirectory().dir("delombok/" + sourceSet.getName()));