Search in sources :

Example 1 with ProjectLayoutSetupRegistry

use of org.gradle.buildinit.plugins.internal.ProjectLayoutSetupRegistry in project gradle by gradle.

the class InitBuild method setupProjectLayout.

@TaskAction
public void setupProjectLayout() {
    final String type = getType();
    BuildInitDsl dsl = BuildInitDsl.fromName(getDsl());
    BuildInitTestFramework testFramework = BuildInitTestFramework.fromName(getTestFramework());
    final ProjectLayoutSetupRegistry projectLayoutRegistry = getProjectLayoutRegistry();
    if (!projectLayoutRegistry.supports(type)) {
        String supportedTypes = Joiner.on(", ").join(Iterables.transform(projectLayoutRegistry.getSupportedTypes(), new Function<String, String>() {

            @Override
            public String apply(String input) {
                return "'" + input + "'";
            }
        }));
        throw new GradleException("The requested build setup type '" + type + "' is not supported. Supported types: " + supportedTypes + ".");
    }
    ProjectInitDescriptor initDescriptor = projectLayoutRegistry.get(type);
    if (!testFramework.equals(BuildInitTestFramework.NONE) && !initDescriptor.supports(testFramework)) {
        throw new GradleException("The requested test framework '" + testFramework.getId() + "' is not supported in '" + type + "' setup type");
    }
    initDescriptor.generate(dsl, testFramework);
}
Also used : BuildInitDsl(org.gradle.buildinit.plugins.internal.modifiers.BuildInitDsl) ProjectLayoutSetupRegistry(org.gradle.buildinit.plugins.internal.ProjectLayoutSetupRegistry) Function(com.google.common.base.Function) GradleException(org.gradle.api.GradleException) ProjectInitDescriptor(org.gradle.buildinit.plugins.internal.ProjectInitDescriptor) BuildInitTestFramework(org.gradle.buildinit.plugins.internal.modifiers.BuildInitTestFramework) TaskAction(org.gradle.api.tasks.TaskAction)

Aggregations

Function (com.google.common.base.Function)1 GradleException (org.gradle.api.GradleException)1 TaskAction (org.gradle.api.tasks.TaskAction)1 ProjectInitDescriptor (org.gradle.buildinit.plugins.internal.ProjectInitDescriptor)1 ProjectLayoutSetupRegistry (org.gradle.buildinit.plugins.internal.ProjectLayoutSetupRegistry)1 BuildInitDsl (org.gradle.buildinit.plugins.internal.modifiers.BuildInitDsl)1 BuildInitTestFramework (org.gradle.buildinit.plugins.internal.modifiers.BuildInitTestFramework)1