Search in sources :

Example 1 with HasCompileOptions

use of org.gradle.api.internal.tasks.compile.HasCompileOptions in project gradle by gradle.

the class DefaultJvmLanguageSourceDirectoryBuilder method build.

void build() {
    if (taskBuilder == null) {
        throw new IllegalStateException("You must specify the task which will contribute classes from this source directory");
    }
    SourceDirectorySet langSrcDir = project.getObjects().sourceDirectorySet(name, description == null ? "Sources for " + name : description);
    langSrcDir.srcDir("src/" + sourceSet.getName() + "/" + name);
    DefaultCompileTaskDetails details = createTaskDetails(langSrcDir);
    JvmPluginsHelper.configureOutputDirectoryForSourceSet(sourceSet, langSrcDir, project, details.task, details.task.map(task -> {
        if (task instanceof HasCompileOptions) {
            return ((HasCompileOptions) task).getOptions();
        }
        throw new UnsupportedOperationException("Unsupported compile task " + task.getClass().getName());
    }), Cast.uncheckedCast(details.mapping));
    if (includeInAllJava) {
        sourceSet.getAllJava().source(langSrcDir);
    }
    sourceSet.getAllSource().source(langSrcDir);
    project.getTasks().named(JavaPlugin.CLASSES_TASK_NAME).configure(classes -> classes.dependsOn(details.task));
}
Also used : JavaCompile(org.gradle.api.tasks.compile.JavaCompile) StringUtils(org.apache.commons.lang.StringUtils) Action(org.gradle.api.Action) SourceDirectorySet(org.gradle.api.file.SourceDirectorySet) JvmPluginsHelper(org.gradle.api.plugins.internal.JvmPluginsHelper) JavaPlugin(org.gradle.api.plugins.JavaPlugin) HasCompileOptions(org.gradle.api.internal.tasks.compile.HasCompileOptions) Cast(org.gradle.internal.Cast) Function(java.util.function.Function) SourceSet(org.gradle.api.tasks.SourceSet) Inject(javax.inject.Inject) Task(org.gradle.api.Task) TaskProvider(org.gradle.api.tasks.TaskProvider) DirectoryProperty(org.gradle.api.file.DirectoryProperty) ProjectInternal(org.gradle.api.internal.project.ProjectInternal) HasCompileOptions(org.gradle.api.internal.tasks.compile.HasCompileOptions) SourceDirectorySet(org.gradle.api.file.SourceDirectorySet)

Aggregations

Function (java.util.function.Function)1 Inject (javax.inject.Inject)1 StringUtils (org.apache.commons.lang.StringUtils)1 Action (org.gradle.api.Action)1 Task (org.gradle.api.Task)1 DirectoryProperty (org.gradle.api.file.DirectoryProperty)1 SourceDirectorySet (org.gradle.api.file.SourceDirectorySet)1 ProjectInternal (org.gradle.api.internal.project.ProjectInternal)1 HasCompileOptions (org.gradle.api.internal.tasks.compile.HasCompileOptions)1 JavaPlugin (org.gradle.api.plugins.JavaPlugin)1 JvmPluginsHelper (org.gradle.api.plugins.internal.JvmPluginsHelper)1 SourceSet (org.gradle.api.tasks.SourceSet)1 TaskProvider (org.gradle.api.tasks.TaskProvider)1 JavaCompile (org.gradle.api.tasks.compile.JavaCompile)1 Cast (org.gradle.internal.Cast)1