use of org.gradle.StartParameter in project gradle by gradle.
the class SetupLoggingActionExecuter method execute.
@Override
public BuildActionResult execute(BuildAction action, BuildActionParameters actionParameters, BuildRequestContext requestContext) {
StartParameter startParameter = action.getStartParameter();
loggingManager.setLevelInternal(startParameter.getLogLevel());
loggingManager.enableUserStandardOutputListeners();
loggingManager.start();
try {
return delegate.execute(action, actionParameters, requestContext);
} finally {
loggingManager.stop();
}
}
use of org.gradle.StartParameter in project gradle by gradle.
the class BuildLogger method buildStarted.
public void buildStarted(Gradle gradle) {
StartParameter startParameter = gradle.getStartParameter();
logger.info("Starting Build");
if (logger.isDebugEnabled()) {
logger.debug("Gradle user home: {}", startParameter.getGradleUserHomeDir());
logger.debug("Current dir: {}", startParameter.getCurrentDir());
logger.debug("Settings file: {}", startParameter.getSettingsFile());
logger.debug("Build file: {}", startParameter.getBuildFile());
}
}
use of org.gradle.StartParameter in project gradle by gradle.
the class DefaultGradleLauncherFactory method doNewInstance.
private DefaultGradleLauncher doNewInstance(BuildDefinition buildDefinition, @Nullable GradleLauncher parent, BuildCancellationToken cancellationToken, BuildRequestMetaData requestMetaData, BuildEventConsumer buildEventConsumer, final BuildTreeScopeServices buildTreeScopeServices, List<?> servicesToStop) {
BuildScopeServices serviceRegistry = new BuildScopeServices(buildTreeScopeServices);
serviceRegistry.add(BuildDefinition.class, buildDefinition);
serviceRegistry.add(BuildRequestMetaData.class, requestMetaData);
serviceRegistry.add(BuildClientMetaData.class, requestMetaData.getClient());
serviceRegistry.add(BuildEventConsumer.class, buildEventConsumer);
serviceRegistry.add(BuildCancellationToken.class, cancellationToken);
serviceRegistry.add(BuildIdentity.class, new DefaultBuildIdentity(buildDefinition, parent == null));
NestedBuildFactoryImpl nestedBuildFactory = new NestedBuildFactoryImpl(buildTreeScopeServices);
serviceRegistry.add(NestedBuildFactory.class, nestedBuildFactory);
StartParameter startParameter = buildDefinition.getStartParameter();
ListenerManager listenerManager = serviceRegistry.get(ListenerManager.class);
LoggerProvider loggerProvider = (parent == null) ? buildProgressLogger : LoggerProvider.NO_OP;
listenerManager.useLogger(new TaskExecutionLogger(serviceRegistry.get(ProgressLoggerFactory.class), loggerProvider));
if (parent == null) {
BuildStartedTime buildStartedTime = serviceRegistry.get(BuildStartedTime.class);
Clock clock = serviceRegistry.get(Clock.class);
listenerManager.useLogger(new BuildLogger(Logging.getLogger(BuildLogger.class), serviceRegistry.get(StyledTextOutputFactory.class), startParameter, requestMetaData, buildStartedTime, clock));
}
listenerManager.addListener(serviceRegistry.get(TaskExecutionStatisticsEventAdapter.class));
listenerManager.addListener(new TaskExecutionStatisticsReporter(serviceRegistry.get(StyledTextOutputFactory.class)));
listenerManager.addListener(serviceRegistry.get(ProfileEventAdapter.class));
if (startParameter.isProfile()) {
listenerManager.addListener(new ReportGeneratingProfileListener(serviceRegistry.get(StyledTextOutputFactory.class)));
}
ScriptUsageLocationReporter usageLocationReporter = new ScriptUsageLocationReporter();
listenerManager.addListener(usageLocationReporter);
ShowStacktrace showStacktrace = startParameter.getShowStacktrace();
switch(showStacktrace) {
case ALWAYS:
case ALWAYS_FULL:
LoggingDeprecatedFeatureHandler.setTraceLoggingEnabled(true);
break;
default:
LoggingDeprecatedFeatureHandler.setTraceLoggingEnabled(false);
}
DeprecationLogger.init(usageLocationReporter, startParameter.getWarningMode());
SettingsLoaderFactory settingsLoaderFactory = serviceRegistry.get(SettingsLoaderFactory.class);
SettingsLoader settingsLoader = parent != null ? settingsLoaderFactory.forNestedBuild() : settingsLoaderFactory.forTopLevelBuild();
GradleInternal parentBuild = parent == null ? null : parent.getGradle();
GradleInternal gradle = serviceRegistry.get(Instantiator.class).newInstance(DefaultGradle.class, parentBuild, startParameter, serviceRegistry.get(ServiceRegistryFactory.class));
DefaultGradleLauncher gradleLauncher = new DefaultGradleLauncher(gradle, serviceRegistry.get(InitScriptHandler.class), settingsLoader, serviceRegistry.get(BuildLoader.class), serviceRegistry.get(BuildConfigurer.class), serviceRegistry.get(ExceptionAnalyser.class), gradle.getBuildListenerBroadcaster(), listenerManager.getBroadcaster(ModelConfigurationListener.class), listenerManager.getBroadcaster(BuildCompletionListener.class), serviceRegistry.get(BuildOperationExecutor.class), gradle.getServices().get(BuildConfigurationActionExecuter.class), gradle.getServices().get(BuildExecuter.class), serviceRegistry, servicesToStop);
nestedBuildFactory.setParent(gradleLauncher);
return gradleLauncher;
}
use of org.gradle.StartParameter in project gradle by gradle.
the class BuildSourceBuilder method buildGradleLauncher.
private GradleLauncher buildGradleLauncher(BuildDefinition buildDefinition) {
// TODO: Migrate buildSrc builds to be more similar to other "included" builds.
GradleLauncher gradleLauncher = nestedBuildFactory.nestedInstance(buildDefinition);
StartParameter startParameter = buildDefinition.getStartParameter();
GradleInternal build = gradleLauncher.getGradle();
if (build.getParent().findIdentityPath() == null) {
// When nested inside a nested build, we need to synthesize a path for this build, as the root project is not yet known for the parent build
// Use the directory structure to do this. This means that the buildSrc build and its containing build may end up with different paths
Path path = build.getParent().getParent().getIdentityPath().child(startParameter.getCurrentDir().getParentFile().getName()).child(startParameter.getCurrentDir().getName());
build.setIdentityPath(path);
}
return gradleLauncher;
}
use of org.gradle.StartParameter in project gradle by gradle.
the class BuildSourceBuilder method createBuildSourceClasspath.
private ClassPath createBuildSourceClasspath(final GradleInternal gradle, File buildSrcDir, final StartParameter containingBuildParameters) {
if (!buildSrcDir.isDirectory()) {
LOGGER.debug("Gradle source dir does not exist. We leave.");
return ClassPath.EMPTY;
}
final StartParameter buildSrcStartParameter = containingBuildParameters.newBuild();
buildSrcStartParameter.setCurrentDir(buildSrcDir);
buildSrcStartParameter.setProjectProperties(containingBuildParameters.getProjectProperties());
buildSrcStartParameter.setSearchUpwards(false);
buildSrcStartParameter.setProfile(containingBuildParameters.isProfile());
final BuildDefinition buildDefinition = BuildDefinition.fromStartParameterForBuild(buildSrcStartParameter, buildSrcDir, DefaultPluginRequests.EMPTY);
assert buildSrcStartParameter.getBuildFile() == null;
return buildOperationExecutor.call(new CallableBuildOperation<ClassPath>() {
@Override
public ClassPath call(BuildOperationContext context) {
ClassPath classPath = buildBuildSrc(buildDefinition);
context.setResult(BUILD_BUILDSRC_RESULT);
return classPath;
}
@Override
public BuildOperationDescriptor.Builder description() {
return BuildOperationDescriptor.displayName("Build buildSrc").progressDisplayName("Building buildSrc").details(new BuildBuildSrcBuildOperationType.Details() {
@Override
public String getBuildPath() {
return gradle.getIdentityPath().toString();
}
});
}
});
}
Aggregations