use of org.gradle.StartParameter in project gradle by gradle.
the class SetupLoggingActionExecuter method execute.
@Override
public Object execute(BuildAction action, BuildRequestContext requestContext, BuildActionParameters actionParameters, ServiceRegistry contextServices) {
StartParameter startParameter = action.getStartParameter();
loggingManager.setLevelInternal(startParameter.getLogLevel());
loggingManager.start();
try {
return delegate.execute(action, requestContext, actionParameters, contextServices);
} finally {
loggingManager.stop();
}
}
use of org.gradle.StartParameter in project build-info by JFrogDev.
the class GradleArtifactoryClientConfigUpdater method update.
/**
* Returns a configuration handler object out of a Gradle project. This method will aggregate the properties in our
* defined hierarchy. First search for the property as a system property, if found return it.
* Second search for the property in the Gradle {@link org.gradle.StartParameter#getProjectProperties} container
* and if found there, then return it. Third search for the property in {@link
* org.gradle.api.Project#property(String)}
* if not found, search upwards in the project hierarchy until
* reach the root project. if not found at all in this hierarchy return null
*
* @param project the gradle project with properties for build info client configuration (Usually in start parameter
* from CI Server)
*/
public static void update(ArtifactoryClientConfiguration config, Project project) {
Properties props = new Properties();
// First aggregate properties from parent to child
fillProperties(project, props);
// Then start parameters
StartParameter startParameter = project.getGradle().getStartParameter();
Map<String, String> startProps = startParameter.getProjectProperties();
props.putAll(BuildInfoExtractorUtils.filterStringEntries(startProps));
// Then System properties
Properties mergedProps = BuildInfoExtractorUtils.mergePropertiesWithSystemAndPropertyFile(props, config.info.getLog());
// Then special buildInfo properties
Properties buildInfoProperties = BuildInfoExtractorUtils.filterDynamicProperties(mergedProps, BUILD_INFO_PROP_PREDICATE);
buildInfoProperties = BuildInfoExtractorUtils.stripPrefixFromProperties(buildInfoProperties, BUILD_INFO_PROP_PREFIX);
mergedProps.putAll(buildInfoProperties);
// Add the collected properties to the Artifactory client configuration.
// In case the build name and build number have already been added to the configuration
// from inside the gradle script, we do not want to override them by the values sent from
// the CI server plugin.
String prefix = BuildInfoProperties.BUILD_INFO_PREFIX;
Set<String> excludeIfExist = Sets.newHashSet(prefix + BuildInfoFields.BUILD_NUMBER, prefix + BuildInfoFields.BUILD_NAME, prefix + BuildInfoFields.BUILD_STARTED);
config.fillFromProperties(mergedProps, excludeIfExist);
// After props are set, apply missing project props (not set by CI-plugin generated props)
setMissingBuildAttributes(config, project);
}
use of org.gradle.StartParameter 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.StartParameter in project gradle by gradle.
the class RunBuildDependenciesTaskBuilder method buildAll.
@Override
public RunClosedProjectBuildDependencies buildAll(String modelName, EclipseRuntime eclipseRuntime, Project project) {
this.projectOpenStatus = eclipseRuntime.getWorkspace().getProjects().stream().collect(Collectors.toMap(EclipseWorkspaceProject::getName, EclipseModelBuilder::isProjectOpen, (a, b) -> a | b));
List<TaskDependency> buildDependencies = populate(project.getRootProject());
if (!buildDependencies.isEmpty()) {
Gradle rootGradle = getRootGradle(project.getGradle());
Project rootProject = rootGradle.getRootProject();
StartParameter startParameter = rootGradle.getStartParameter();
List<String> taskPaths = new ArrayList<>(startParameter.getTaskNames());
String parentTaskName = parentTaskName(rootProject, "eclipseClosedDependencies");
Task task = rootProject.task(parentTaskName);
task.dependsOn(buildDependencies.toArray(new Object[0]));
taskPaths.add(parentTaskName);
startParameter.setTaskNames(taskPaths);
}
return DefaultRunClosedProjectBuildDependencies.INSTANCE;
}
use of org.gradle.StartParameter in project gradle by gradle.
the class RunEclipseTasksBuilder method buildAll.
@Override
public Object buildAll(String modelName, Project project) {
StartParameter startParameter = project.getGradle().getStartParameter();
List<String> taskPaths = new ArrayList<String>();
taskPaths.addAll(startParameter.getTaskNames());
boolean isSyncModel = isSyncModel(modelName);
boolean isAutoBuildModel = isAutoBuildModel(modelName);
for (Project p : project.getAllprojects()) {
EclipseModel model = p.getExtensions().findByType(EclipseModel.class);
if (model != null) {
if (isSyncModel) {
for (Task t : model.getSynchronizationTasks().getDependencies(null)) {
taskPaths.add(t.getPath());
}
}
if (isAutoBuildModel) {
for (Task t : model.getAutoBuildTasks().getDependencies(null)) {
taskPaths.add(t.getPath());
}
}
}
}
if (taskPaths.isEmpty()) {
// If no tasks is specified then the default tasks will be executed.
// To work around this, we assign a new empty task for execution.
String placeHolderTaskName = placeHolderTaskName(project, "nothing");
project.task(placeHolderTaskName);
taskPaths.add(placeHolderTaskName);
}
project.getGradle().getStartParameter().setTaskNames(taskPaths);
return null;
}
Aggregations