private void configureSourceSetDefaults(final JavaBasePlugin javaBasePlugin) { project.getConvention().getPlugin(JavaPluginConvention.class).getSourceSets().all(new Action<SourceSet>() { public void execute(SourceSet sourceSet) { final DefaultGroovySourceSet groovySourceSet = new DefaultGroovySourceSet(((DefaultSourceSet) sourceSet).getDisplayName(), sourceDirectorySetFactory); new DslObject(sourceSet).getConvention().getPlugins().put("groovy", groovySourceSet); groovySourceSet.getGroovy().srcDir("src/" + sourceSet.getName() + "/groovy"); sourceSet.getResources().getFilter().exclude(new Spec<FileTreeElement>() { public boolean isSatisfiedBy(FileTreeElement element) { return groovySourceSet.getGroovy().contains(element.getFile()); } }); sourceSet.getAllJava().source(groovySourceSet.getGroovy()); sourceSet.getAllSource().source(groovySourceSet.getGroovy()); String compileTaskName = sourceSet.getCompileTaskName("groovy"); GroovyCompile compile = project.getTasks().create(compileTaskName, GroovyCompile.class); javaBasePlugin.configureForSourceSet(sourceSet, compile); compile.dependsOn(sourceSet.getCompileJavaTaskName()); compile.setDescription("Compiles the " + sourceSet.getName() + " Groovy source."); compile.setSource(groovySourceSet.getGroovy()); project.getTasks().getByName(sourceSet.getClassesTaskName()).dependsOn(compileTaskName); } }); }
private void configureSourceSetDefaults(final JavaBasePlugin javaBasePlugin) { project.getConvention().getPlugin(JavaPluginConvention.class).getSourceSets().all(new Action<SourceSet>() { public void execute(SourceSet sourceSet) { final DefaultGroovySourceSet groovySourceSet = new DefaultGroovySourceSet(((DefaultSourceSet) sourceSet).getDisplayName(), fileResolver); new DslObject(sourceSet).getConvention().getPlugins().put("groovy", groovySourceSet); groovySourceSet.getGroovy().srcDir(String.format("src/%s/groovy", sourceSet.getName())); sourceSet.getResources().getFilter().exclude(new Spec<FileTreeElement>() { public boolean isSatisfiedBy(FileTreeElement element) { return groovySourceSet.getGroovy().contains(element.getFile()); } }); sourceSet.getAllJava().source(groovySourceSet.getGroovy()); sourceSet.getAllSource().source(groovySourceSet.getGroovy()); String compileTaskName = sourceSet.getCompileTaskName("groovy"); GroovyCompile compile = project.getTasks().create(compileTaskName, GroovyCompile.class); javaBasePlugin.configureForSourceSet(sourceSet, compile); compile.dependsOn(sourceSet.getCompileJavaTaskName()); compile.setDescription(String.format("Compiles the %s Groovy source.", sourceSet.getName())); compile.setSource(groovySourceSet.getGroovy()); project.getTasks().getByName(sourceSet.getClassesTaskName()).dependsOn(compileTaskName); } }); }
private void configureCompileDefaults() { project.getTasks().withType(GroovyCompile.class, new Action<GroovyCompile>() { public void execute(final GroovyCompile compile) { compile.getConventionMapping().map("groovyClasspath", new Callable<Object>() { public Object call() throws Exception { return groovyRuntime.inferGroovyClasspath(compile.getClasspath()); } }); } }); }