Search in sources :

Example 1 with DefaultGroovyJavaJointCompileSpec

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

the class GroovyCompile method createSpec.

private GroovyJavaJointCompileSpec createSpec() {
    validateConfiguration();
    DefaultGroovyJavaJointCompileSpec spec = new DefaultGroovyJavaJointCompileSpecFactory(compileOptions, getToolchain()).create();
    assert spec != null;
    FileTreeInternal stableSourcesAsFileTree = (FileTreeInternal) getStableSources().getAsFileTree();
    List<File> sourceRoots = CompilationSourceDirs.inferSourceRoots(stableSourcesAsFileTree);
    spec.setSourcesRoots(sourceRoots);
    spec.setSourceFiles(stableSourcesAsFileTree);
    spec.setDestinationDir(getDestinationDirectory().getAsFile().get());
    spec.setWorkingDir(getProjectLayout().getProjectDirectory().getAsFile());
    spec.setTempDir(getTemporaryDir());
    spec.setCompileClasspath(ImmutableList.copyOf(determineGroovyCompileClasspath()));
    configureCompatibilityOptions(spec);
    spec.setAnnotationProcessorPath(Lists.newArrayList(compileOptions.getAnnotationProcessorPath() == null ? getProjectLayout().files() : compileOptions.getAnnotationProcessorPath()));
    spec.setGroovyClasspath(Lists.newArrayList(getGroovyClasspath()));
    spec.setCompileOptions(compileOptions);
    spec.setGroovyCompileOptions(new MinimalGroovyCompileOptions(groovyCompileOptions));
    spec.getCompileOptions().setSupportsCompilerApi(true);
    if (getOptions().isIncremental()) {
        validateIncrementalCompilationOptions(sourceRoots, spec.annotationProcessingConfigured());
        spec.getCompileOptions().setPreviousCompilationDataFile(getPreviousCompilationData());
    }
    if (spec.getGroovyCompileOptions().getStubDir() == null) {
        File dir = new File(getTemporaryDir(), "groovy-java-stubs");
        GFileUtils.mkdirs(dir);
        spec.getGroovyCompileOptions().setStubDir(dir);
    }
    configureExecutable(spec.getCompileOptions().getForkOptions());
    return spec;
}
Also used : DefaultGroovyJavaJointCompileSpec(org.gradle.api.internal.tasks.compile.DefaultGroovyJavaJointCompileSpec) MinimalGroovyCompileOptions(org.gradle.api.internal.tasks.compile.MinimalGroovyCompileOptions) DefaultGroovyJavaJointCompileSpecFactory(org.gradle.api.internal.tasks.compile.DefaultGroovyJavaJointCompileSpecFactory) OutputFile(org.gradle.api.tasks.OutputFile) File(java.io.File) FileTreeInternal(org.gradle.api.internal.file.FileTreeInternal)

Example 2 with DefaultGroovyJavaJointCompileSpec

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

the class GroovyCompile method compile.

@Override
@TaskAction
protected void compile() {
    checkGroovyClasspathIsNonEmpty();
    DefaultGroovyJavaJointCompileSpec spec = createSpec();
    WorkResult result = getCompiler(spec).execute(spec);
    setDidWork(result.getDidWork());
}
Also used : DefaultGroovyJavaJointCompileSpec(org.gradle.api.internal.tasks.compile.DefaultGroovyJavaJointCompileSpec) WorkResult(org.gradle.api.tasks.WorkResult) TaskAction(org.gradle.api.tasks.TaskAction)

Aggregations

DefaultGroovyJavaJointCompileSpec (org.gradle.api.internal.tasks.compile.DefaultGroovyJavaJointCompileSpec)2 File (java.io.File)1 FileTreeInternal (org.gradle.api.internal.file.FileTreeInternal)1 DefaultGroovyJavaJointCompileSpecFactory (org.gradle.api.internal.tasks.compile.DefaultGroovyJavaJointCompileSpecFactory)1 MinimalGroovyCompileOptions (org.gradle.api.internal.tasks.compile.MinimalGroovyCompileOptions)1 OutputFile (org.gradle.api.tasks.OutputFile)1 TaskAction (org.gradle.api.tasks.TaskAction)1 WorkResult (org.gradle.api.tasks.WorkResult)1