Search in sources :

Example 1 with BuildLayoutConfiguration

use of org.gradle.initialization.layout.BuildLayoutConfiguration in project gradle by gradle.

the class BuildSessionScopeServices method createCacheLayout.

ProjectCacheDir createCacheLayout(StartParameter startParameter, BuildLayoutFactory buildLayoutFactory) {
    BuildLayout buildLayout = buildLayoutFactory.getLayoutFor(new BuildLayoutConfiguration(startParameter));
    File cacheDir = startParameter.getProjectCacheDir() != null ? startParameter.getProjectCacheDir() : new File(buildLayout.getRootDirectory(), ".gradle");
    return new ProjectCacheDir(cacheDir);
}
Also used : BuildLayoutConfiguration(org.gradle.initialization.layout.BuildLayoutConfiguration) File(java.io.File) BuildLayout(org.gradle.initialization.layout.BuildLayout) ProjectCacheDir(org.gradle.initialization.layout.ProjectCacheDir)

Example 2 with BuildLayoutConfiguration

use of org.gradle.initialization.layout.BuildLayoutConfiguration in project gradle by gradle.

the class BuildLayoutValidator method validate.

public void validate(StartParameterInternal startParameter) {
    BuildLayout buildLayout = buildLayoutFactory.getLayoutFor(new BuildLayoutConfiguration(startParameter));
    if (!buildLayout.isBuildDefinitionMissing()) {
        // All good
        return;
    }
    for (BuiltInCommand command : builtInCommands) {
        if (command.commandLineMatches(startParameter.getTaskNames())) {
            // Allow missing settings and build scripts when running a built-in command
            return;
        }
    }
    StringBuilder message = new StringBuilder();
    message.append("Directory '");
    message.append(startParameter.getCurrentDir());
    message.append("' does not contain a Gradle build.\n\n");
    message.append("A Gradle build should contain a 'settings.gradle' or 'settings.gradle.kts' file in its root directory. ");
    message.append("It may also contain a 'build.gradle' or 'build.gradle.kts' file.\n\n");
    message.append("To create a new Gradle build in this directory run '");
    clientMetaData.describeCommand(message, "init");
    message.append("'\n\n");
    message.append("For more detail on the 'init' task see ");
    message.append(documentationRegistry.getDocumentationFor("build_init_plugin"));
    message.append("\n\n");
    message.append("For more detail on creating a Gradle build see ");
    // this is the "build script basics" chapter, we're missing some kind of "how to write a Gradle build chapter"
    message.append(documentationRegistry.getDocumentationFor("tutorial_using_tasks"));
    throw new BuildLayoutException(message.toString());
}
Also used : BuildLayoutConfiguration(org.gradle.initialization.layout.BuildLayoutConfiguration) BuiltInCommand(org.gradle.configuration.project.BuiltInCommand) BuildLayout(org.gradle.initialization.layout.BuildLayout)

Example 3 with BuildLayoutConfiguration

use of org.gradle.initialization.layout.BuildLayoutConfiguration in project gradle by gradle.

the class GradlePropertiesHandlingSettingsLoader method findAndLoadSettings.

@Override
public SettingsInternal findAndLoadSettings(GradleInternal gradle) {
    SettingsLocation settingsLocation = buildLayoutFactory.getLayoutFor(new BuildLayoutConfiguration(gradle.getStartParameter()));
    gradlePropertiesController.loadGradlePropertiesFrom(settingsLocation.getSettingsDir());
    return delegate.findAndLoadSettings(gradle);
}
Also used : BuildLayoutConfiguration(org.gradle.initialization.layout.BuildLayoutConfiguration)

Example 4 with BuildLayoutConfiguration

use of org.gradle.initialization.layout.BuildLayoutConfiguration in project gradle by gradle.

the class DefaultSettingsLoader method findAndLoadSettings.

@Override
public SettingsInternal findAndLoadSettings(GradleInternal gradle) {
    StartParameter startParameter = gradle.getStartParameter();
    SettingsLocation settingsLocation = buildLayoutFactory.getLayoutFor(new BuildLayoutConfiguration(startParameter));
    SettingsInternal settings = findSettingsAndLoadIfAppropriate(gradle, startParameter, settingsLocation, gradle.getClassLoaderScope());
    ProjectSpec spec = ProjectSpecs.forStartParameter(startParameter, settings);
    if (useEmptySettings(spec, settings, startParameter)) {
        settings = createEmptySettings(gradle, startParameter, settings.getClassLoaderScope());
    }
    setDefaultProject(spec, settings);
    return settings;
}
Also used : SettingsInternal(org.gradle.api.internal.SettingsInternal) StartParameter(org.gradle.StartParameter) BuildLayoutConfiguration(org.gradle.initialization.layout.BuildLayoutConfiguration)

Example 5 with BuildLayoutConfiguration

use of org.gradle.initialization.layout.BuildLayoutConfiguration in project gradle by gradle.

the class DefaultSettingsLoader method createEmptySettings.

// StartParameter.setSettingsFile() and StartParameter.getBuildFile()
@SuppressWarnings("deprecation")
private SettingsInternal createEmptySettings(GradleInternal gradle, StartParameter startParameter, ClassLoaderScope classLoaderScope) {
    StartParameterInternal noSearchParameter = (StartParameterInternal) startParameter.newInstance();
    noSearchParameter.setSettingsFile(null);
    noSearchParameter.useEmptySettings();
    noSearchParameter.doNotSearchUpwards();
    BuildLayout layout = buildLayoutFactory.getLayoutFor(new BuildLayoutConfiguration(noSearchParameter));
    SettingsInternal settings = findSettingsAndLoadIfAppropriate(gradle, noSearchParameter, layout, classLoaderScope);
    // Set explicit build file, if required
    @SuppressWarnings("deprecation") File customBuildFile = noSearchParameter.getBuildFile();
    if (customBuildFile != null) {
        ProjectDescriptor rootProject = settings.getRootProject();
        rootProject.setBuildFileName(noSearchParameter.getBuildFile().getName());
    }
    return settings;
}
Also used : SettingsInternal(org.gradle.api.internal.SettingsInternal) ProjectDescriptor(org.gradle.api.initialization.ProjectDescriptor) BuildLayoutConfiguration(org.gradle.initialization.layout.BuildLayoutConfiguration) StartParameterInternal(org.gradle.api.internal.StartParameterInternal) File(java.io.File) BuildLayout(org.gradle.initialization.layout.BuildLayout)

Aggregations

BuildLayoutConfiguration (org.gradle.initialization.layout.BuildLayoutConfiguration)5 BuildLayout (org.gradle.initialization.layout.BuildLayout)3 File (java.io.File)2 SettingsInternal (org.gradle.api.internal.SettingsInternal)2 StartParameter (org.gradle.StartParameter)1 ProjectDescriptor (org.gradle.api.initialization.ProjectDescriptor)1 StartParameterInternal (org.gradle.api.internal.StartParameterInternal)1 BuiltInCommand (org.gradle.configuration.project.BuiltInCommand)1 ProjectCacheDir (org.gradle.initialization.layout.ProjectCacheDir)1