use of org.gradle.configuration.project.BuiltInCommand in project gradle by gradle.
the class DefaultTasksBuildExecutionAction method configure.
@Override
public void configure(BuildExecutionContext context) {
StartParameter startParameter = context.getGradle().getStartParameter();
for (TaskExecutionRequest request : startParameter.getTaskRequests()) {
if (!request.getArgs().isEmpty()) {
context.proceed();
return;
}
}
// Gather the default tasks from this first group project
ProjectInternal project = context.getGradle().getDefaultProject();
// so that we don't miss out default tasks
projectConfigurer.configure(project);
List<String> defaultTasks = project.getDefaultTasks();
if (defaultTasks.size() == 0) {
defaultTasks = new ArrayList<>();
for (BuiltInCommand command : builtInCommands) {
defaultTasks.addAll(command.asDefaultTask());
}
LOGGER.info("No tasks specified. Using default task {}", GUtil.toString(defaultTasks));
} else {
LOGGER.info("No tasks specified. Using project default tasks {}", GUtil.toString(defaultTasks));
}
startParameter.setTaskNames(defaultTasks);
context.proceed();
}
use of org.gradle.configuration.project.BuiltInCommand 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());
}
Aggregations