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);
}
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());
}
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);
}
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;
}
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;
}
Aggregations