Search in sources :

Example 1 with SourceTransformTaskConfig

use of org.gradle.language.base.internal.SourceTransformTaskConfig in project gradle by gradle.

the class BinarySourceTransformations method createTasksFor.

public void createTasksFor(BinarySpecInternal binary) {
    Set<LanguageSourceSetInternal> sourceSetsToCompile = getSourcesToCompile(binary);
    for (LanguageTransform<?, ?> languageTransform : prioritizedTransforms) {
        if (!languageTransform.applyToBinary(binary)) {
            continue;
        }
        LanguageSourceSetInternal sourceSetToCompile;
        while ((sourceSetToCompile = findSourceFor(languageTransform, sourceSetsToCompile)) != null) {
            sourceSetsToCompile.remove(sourceSetToCompile);
            final SourceTransformTaskConfig taskConfig = languageTransform.getTransformTask();
            String taskName = getTransformTaskName(languageTransform, taskConfig, binary, sourceSetToCompile);
            Task task = tasks.create(taskName, taskConfig.getTaskType());
            taskConfig.configureTask(task, binary, sourceSetToCompile, serviceRegistry);
            task.dependsOn(sourceSetToCompile);
            binary.getTasks().add(task);
            if (binary.hasCodependentSources() && taskConfig instanceof JointCompileTaskConfig) {
                JointCompileTaskConfig jointCompileTaskConfig = (JointCompileTaskConfig) taskConfig;
                Iterator<LanguageSourceSetInternal> candidateSourceSets = sourceSetsToCompile.iterator();
                while (candidateSourceSets.hasNext()) {
                    LanguageSourceSetInternal candidate = candidateSourceSets.next();
                    if (jointCompileTaskConfig.canTransform(candidate)) {
                        jointCompileTaskConfig.configureAdditionalTransform(task, candidate);
                        candidateSourceSets.remove();
                    }
                }
            }
        }
    }
// Should really fail here if sourcesToCompile is not empty: no transform for this source set in this binary
}
Also used : LanguageSourceSetInternal(org.gradle.language.base.internal.LanguageSourceSetInternal) Task(org.gradle.api.Task) SourceTransformTaskConfig(org.gradle.language.base.internal.SourceTransformTaskConfig) JointCompileTaskConfig(org.gradle.language.base.internal.JointCompileTaskConfig)

Aggregations

Task (org.gradle.api.Task)1 JointCompileTaskConfig (org.gradle.language.base.internal.JointCompileTaskConfig)1 LanguageSourceSetInternal (org.gradle.language.base.internal.LanguageSourceSetInternal)1 SourceTransformTaskConfig (org.gradle.language.base.internal.SourceTransformTaskConfig)1