Java Code Examples for org.gradle.language.base.FunctionalSourceSet#withType()

The following examples show how to use org.gradle.language.base.FunctionalSourceSet#withType() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
public void execute(ProjectInternal project) {
    ProjectSourceSet projectSourceSet = project.getExtensions().getByType(ProjectSourceSet.class);
    for (FunctionalSourceSet functionalSourceSet : projectSourceSet) {
        for (LanguageSourceSet languageSourceSet : functionalSourceSet) {
            // Only apply default locations when none explicitly configured
            if (languageSourceSet.getSource().getSrcDirs().isEmpty()) {
                languageSourceSet.getSource().srcDir(String.format("src/%s/%s", functionalSourceSet.getName(), languageSourceSet.getName()));
            }
        }
        for (HeaderExportingSourceSet headerSourceSet : functionalSourceSet.withType(HeaderExportingSourceSet.class)) {
            // Only apply default locations when none explicitly configured
            if (headerSourceSet.getExportedHeaders().getSrcDirs().isEmpty()) {
                headerSourceSet.getExportedHeaders().srcDir(String.format("src/%s/headers", functionalSourceSet.getName()));
            }

            headerSourceSet.getImplicitHeaders().setSrcDirs(headerSourceSet.getSource().getSrcDirs());
            headerSourceSet.getImplicitHeaders().include("**/*.h");
        }
    }
}
 
Example 2
public void execute(ProjectInternal project) {
    ProjectSourceSet projectSourceSet = project.getExtensions().getByType(ProjectSourceSet.class);
    for (FunctionalSourceSet functionalSourceSet : projectSourceSet) {
        for (LanguageSourceSet languageSourceSet : functionalSourceSet) {
            // Only apply default locations when none explicitly configured
            if (languageSourceSet.getSource().getSrcDirs().isEmpty()) {
                languageSourceSet.getSource().srcDir(String.format("src/%s/%s", functionalSourceSet.getName(), languageSourceSet.getName()));
            }
        }
        for (HeaderExportingSourceSet headerSourceSet : functionalSourceSet.withType(HeaderExportingSourceSet.class)) {
            // Only apply default locations when none explicitly configured
            if (headerSourceSet.getExportedHeaders().getSrcDirs().isEmpty()) {
                headerSourceSet.getExportedHeaders().srcDir(String.format("src/%s/headers", functionalSourceSet.getName()));
            }

            headerSourceSet.getImplicitHeaders().setSrcDirs(headerSourceSet.getSource().getSrcDirs());
            headerSourceSet.getImplicitHeaders().include("**/*.h");
        }
    }
}
 
Example 3
@Mutate
void configureGeneratedSourceSets(ProjectSourceSet sources) {
    for (FunctionalSourceSet functionalSourceSet : sources) {
        for (LanguageSourceSetInternal languageSourceSet : functionalSourceSet.withType(LanguageSourceSetInternal.class)) {
            Task generatorTask = languageSourceSet.getGeneratorTask();
            if (generatorTask != null) {
                languageSourceSet.builtBy(generatorTask);
                maybeSetSourceDir(languageSourceSet.getSource(), generatorTask, "sourceDir");
                if (languageSourceSet instanceof HeaderExportingSourceSet) {
                    maybeSetSourceDir(((HeaderExportingSourceSet) languageSourceSet).getExportedHeaders(), generatorTask, "headerDir");
                }
            }
        }
    }
}
 
Example 4
@Finalize
public void applyHeaderSourceSetConventions(ProjectSourceSet sources) {
    for (FunctionalSourceSet functionalSourceSet : sources) {
        for (HeaderExportingSourceSet headerSourceSet : functionalSourceSet.withType(HeaderExportingSourceSet.class)) {
            // Only apply default locations when none explicitly configured
            if (headerSourceSet.getExportedHeaders().getSrcDirs().isEmpty()) {
                headerSourceSet.getExportedHeaders().srcDir(String.format("src/%s/headers", functionalSourceSet.getName()));
            }

            headerSourceSet.getImplicitHeaders().setSrcDirs(headerSourceSet.getSource().getSrcDirs());
            headerSourceSet.getImplicitHeaders().include("**/*.h");
        }
    }
}
 
Example 5
public void execute(ProjectInternal project) {
    ProjectSourceSet projectSourceSet = project.getExtensions().getByType(ProjectSourceSet.class);
    for (FunctionalSourceSet functionalSourceSet : projectSourceSet) {
        for (LanguageSourceSetInternal languageSourceSet : functionalSourceSet.withType(LanguageSourceSetInternal.class)) {
            Task generatorTask = languageSourceSet.getGeneratorTask();
            if (generatorTask != null) {
                languageSourceSet.builtBy(generatorTask);
                maybeSetSourceDir(languageSourceSet.getSource(), generatorTask, "sourceDir");
                if (languageSourceSet instanceof HeaderExportingSourceSet) {
                    maybeSetSourceDir(((HeaderExportingSourceSet) languageSourceSet).getExportedHeaders(), generatorTask, "headerDir");
                }
            }
        }
    }
}
 
Example 6
@Mutate
void configureGeneratedSourceSets(ProjectSourceSet sources) {
    for (FunctionalSourceSet functionalSourceSet : sources) {
        for (LanguageSourceSetInternal languageSourceSet : functionalSourceSet.withType(LanguageSourceSetInternal.class)) {
            Task generatorTask = languageSourceSet.getGeneratorTask();
            if (generatorTask != null) {
                languageSourceSet.builtBy(generatorTask);
                maybeSetSourceDir(languageSourceSet.getSource(), generatorTask, "sourceDir");
                if (languageSourceSet instanceof HeaderExportingSourceSet) {
                    maybeSetSourceDir(((HeaderExportingSourceSet) languageSourceSet).getExportedHeaders(), generatorTask, "headerDir");
                }
            }
        }
    }
}
 
Example 7
@Finalize
public void applyHeaderSourceSetConventions(ProjectSourceSet sources) {
    for (FunctionalSourceSet functionalSourceSet : sources) {
        for (HeaderExportingSourceSet headerSourceSet : functionalSourceSet.withType(HeaderExportingSourceSet.class)) {
            // Only apply default locations when none explicitly configured
            if (headerSourceSet.getExportedHeaders().getSrcDirs().isEmpty()) {
                headerSourceSet.getExportedHeaders().srcDir(String.format("src/%s/headers", functionalSourceSet.getName()));
            }

            headerSourceSet.getImplicitHeaders().setSrcDirs(headerSourceSet.getSource().getSrcDirs());
            headerSourceSet.getImplicitHeaders().include("**/*.h");
        }
    }
}
 
Example 8
public void execute(ProjectInternal project) {
    ProjectSourceSet projectSourceSet = project.getExtensions().getByType(ProjectSourceSet.class);
    for (FunctionalSourceSet functionalSourceSet : projectSourceSet) {
        for (LanguageSourceSetInternal languageSourceSet : functionalSourceSet.withType(LanguageSourceSetInternal.class)) {
            Task generatorTask = languageSourceSet.getGeneratorTask();
            if (generatorTask != null) {
                languageSourceSet.builtBy(generatorTask);
                maybeSetSourceDir(languageSourceSet.getSource(), generatorTask, "sourceDir");
                if (languageSourceSet instanceof HeaderExportingSourceSet) {
                    maybeSetSourceDir(((HeaderExportingSourceSet) languageSourceSet).getExportedHeaders(), generatorTask, "headerDir");
                }
            }
        }
    }
}