private void configureGroovydoc(final Project project) { Groovydoc groovyDoc = project.getTasks().create(GROOVYDOC_TASK_NAME, Groovydoc.class); groovyDoc.setDescription("Generates Groovydoc API documentation for the main source code."); groovyDoc.setGroup(JavaBasePlugin.DOCUMENTATION_GROUP); JavaPluginConvention convention = project.getConvention().getPlugin(JavaPluginConvention.class); SourceSet sourceSet = convention.getSourceSets().getByName(SourceSet.MAIN_SOURCE_SET_NAME); groovyDoc.setClasspath(sourceSet.getOutput().plus(sourceSet.getCompileClasspath())); GroovySourceSet groovySourceSet = new DslObject(sourceSet).getConvention().getPlugin(GroovySourceSet.class); groovyDoc.setSource(groovySourceSet.getGroovy()); }
/** If the user hasn't specified the files yet, we'll assume he/she means all of the groovy files. */ @Override protected void setupTask(SpotlessTask task) { if (target == null) { JavaPluginConvention convention = getProject().getConvention().getPlugin(JavaPluginConvention.class); if (convention == null || !getProject().getPlugins().hasPlugin(GroovyBasePlugin.class)) { throw new GradleException("You must apply the groovy plugin before the spotless plugin if you are using the groovy extension."); } //Add all Groovy files (may contain Java files as well) FileCollection union = getProject().files(); for (SourceSet sourceSet : convention.getSourceSets()) { GroovySourceSet groovySourceSet = new DslObject(sourceSet).getConvention().getPlugin(GroovySourceSet.class); if (excludeJava) { union = union.plus(groovySourceSet.getAllGroovy()); } else { union = union.plus(groovySourceSet.getGroovy()); } } target = union; } else if (excludeJava) { throw new IllegalArgumentException("'excludeJava' is not supported in combination with a custom 'target'."); } // LicenseHeaderStep completely blows apart package-info.java/groovy - this common-sense check // ensures that it skips both. See https://github.com/diffplug/spotless/issues/1 steps.replaceAll(step -> { if (LicenseHeaderStep.name().equals(step.getName())) { return step.filterByFile(SerializableFileFilter.skipFilesNamed("package-info.java", "package-info.groovy")); } else { return step; } }); super.setupTask(task); }
public GroovySourceSet groovy(Closure configureClosure) { return groovy(ClosureBackedAction.of(configureClosure)); }
@Override public GroovySourceSet groovy(Action<? super SourceDirectorySet> configureAction) { configureAction.execute(getGroovy()); return this; }
public GroovySourceSet groovy(Closure configureClosure) { ConfigureUtil.configure(configureClosure, getGroovy()); return this; }