org.gradle.api.plugins.GroovyBasePlugin Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of gradle-api Show documentation
Show all versions of gradle-api Show documentation
Gradle 6.9.1 API redistribution.
/*
* Copyright 2009 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.gradle.api.plugins;
import org.gradle.api.Action;
import org.gradle.api.Plugin;
import org.gradle.api.Project;
import org.gradle.api.file.ConfigurableFileCollection;
import org.gradle.api.file.FileCollection;
import org.gradle.api.file.FileTreeElement;
import org.gradle.api.internal.classpath.ModuleRegistry;
import org.gradle.api.internal.file.SourceDirectorySetFactory;
import org.gradle.api.internal.plugins.DslObject;
import org.gradle.api.internal.tasks.DefaultGroovySourceSet;
import org.gradle.api.internal.tasks.DefaultSourceSet;
import org.gradle.api.reporting.ReportingExtension;
import org.gradle.api.specs.Spec;
import org.gradle.api.tasks.GroovyRuntime;
import org.gradle.api.tasks.SourceSet;
import org.gradle.api.tasks.compile.GroovyCompile;
import org.gradle.api.tasks.javadoc.Groovydoc;
import javax.inject.Inject;
import java.io.File;
import java.util.concurrent.Callable;
/**
* Extends {@link org.gradle.api.plugins.JavaBasePlugin} to provide support for compiling and documenting Groovy
* source files.
*/
public class GroovyBasePlugin implements Plugin {
public static final String GROOVY_RUNTIME_EXTENSION_NAME = "groovyRuntime";
private final SourceDirectorySetFactory sourceDirectorySetFactory;
private final ModuleRegistry moduleRegistry;
private Project project;
private GroovyRuntime groovyRuntime;
@Inject
public GroovyBasePlugin(SourceDirectorySetFactory sourceDirectorySetFactory, ModuleRegistry moduleRegistry) {
this.sourceDirectorySetFactory = sourceDirectorySetFactory;
this.moduleRegistry = moduleRegistry;
}
public void apply(Project project) {
this.project = project;
project.getPluginManager().apply(JavaBasePlugin.class);
JavaBasePlugin javaBasePlugin = project.getPlugins().getPlugin(JavaBasePlugin.class);
configureGroovyRuntimeExtension();
configureCompileDefaults();
configureSourceSetDefaults(javaBasePlugin);
configureGroovydoc();
}
private void configureGroovyRuntimeExtension() {
groovyRuntime = project.getExtensions().create(GROOVY_RUNTIME_EXTENSION_NAME, GroovyRuntime.class, project);
}
private void configureCompileDefaults() {
project.getTasks().withType(GroovyCompile.class, new Action() {
public void execute(final GroovyCompile compile) {
compile.getConventionMapping().map("groovyClasspath", new Callable
© 2015 - 2025 Weber Informatics LLC | Privacy Policy