Search in sources :

Example 1 with BuildLayoutFactory

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

the class DistributionFactory method getDefaultDistribution.

/**
 * Returns the default distribution to use for the specified project.
 */
public Distribution getDefaultDistribution(File projectDir, boolean searchUpwards) {
    BuildLayout layout = new BuildLayoutFactory().getLayoutFor(projectDir, searchUpwards);
    WrapperExecutor wrapper = WrapperExecutor.forProjectDirectory(layout.getRootDirectory());
    if (wrapper.getDistribution() != null) {
        return new ZippedDistribution(wrapper.getConfiguration(), distributionBaseDir, clock);
    }
    return getDownloadedDistribution(GradleVersion.current().getVersion());
}
Also used : WrapperExecutor(org.gradle.wrapper.WrapperExecutor) BuildLayoutFactory(org.gradle.initialization.layout.BuildLayoutFactory) BuildLayout(org.gradle.initialization.layout.BuildLayout)

Example 2 with BuildLayoutFactory

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

the class InProcessGradleExecuter method executeBuild.

private BuildResult executeBuild(GradleInvocation invocation, final StandardOutputListener outputListener, BuildListenerImpl listener) {
    // Augment the environment for the execution
    System.setIn(connectStdIn());
    processEnvironment.maybeSetProcessDir(getWorkingDir());
    for (Map.Entry<String, String> entry : invocation.environmentVars.entrySet()) {
        processEnvironment.maybeSetEnvironmentVariable(entry.getKey(), entry.getValue());
    }
    Map<String, String> implicitJvmSystemProperties = getImplicitJvmSystemProperties();
    System.getProperties().putAll(implicitJvmSystemProperties);
    resetTempDirLocation();
    // TODO: Fix tests that rely on this being set before we process arguments like this...
    StartParameterInternal startParameter = new StartParameterInternal();
    startParameter.setCurrentDir(getWorkingDir());
    // TODO: Reuse more of CommandlineActionFactory
    CommandLineParser parser = new CommandLineParser();
    BuildLayoutFactory buildLayoutFactory = new BuildLayoutFactory();
    ParametersConverter parametersConverter = new ParametersConverter(buildLayoutFactory);
    parametersConverter.configure(parser);
    final Parameters parameters = new Parameters(startParameter);
    parametersConverter.convert(parser.parse(getAllArgs()), parameters);
    BuildActionExecuter<BuildActionParameters> actionExecuter = GLOBAL_SERVICES.get(BuildActionExecuter.class);
    ListenerManager listenerManager = GLOBAL_SERVICES.get(ListenerManager.class);
    listenerManager.addListener(listener);
    try {
        // TODO: Reuse more of BuildActionsFactory
        BuildAction action = new ExecuteBuildAction(startParameter);
        BuildActionParameters buildActionParameters = createBuildActionParameters(startParameter);
        BuildRequestContext buildRequestContext = createBuildRequestContext();
        LoggingManagerInternal loggingManager = createLoggingManager(startParameter, outputListener);
        loggingManager.start();
        try {
            startMeasurement();
            try {
                actionExecuter.execute(action, buildRequestContext, buildActionParameters, GLOBAL_SERVICES);
            } finally {
                stopMeasurement();
            }
        } finally {
            loggingManager.stop();
        }
        return new BuildResult(null, null);
    } catch (ReportedException e) {
        return new BuildResult(null, e.getCause());
    } finally {
        listenerManager.removeListener(listener);
    }
}
Also used : LoggingManagerInternal(org.gradle.internal.logging.LoggingManagerInternal) Parameters(org.gradle.launcher.cli.Parameters) DefaultBuildActionParameters(org.gradle.launcher.exec.DefaultBuildActionParameters) BuildActionParameters(org.gradle.launcher.exec.BuildActionParameters) DefaultBuildActionParameters(org.gradle.launcher.exec.DefaultBuildActionParameters) BuildActionParameters(org.gradle.launcher.exec.BuildActionParameters) ExecuteBuildAction(org.gradle.launcher.cli.action.ExecuteBuildAction) Matchers.containsString(org.hamcrest.Matchers.containsString) BuildLayoutFactory(org.gradle.initialization.layout.BuildLayoutFactory) DefaultBuildRequestContext(org.gradle.initialization.DefaultBuildRequestContext) BuildRequestContext(org.gradle.initialization.BuildRequestContext) BuildResult(org.gradle.BuildResult) ParametersConverter(org.gradle.launcher.cli.ParametersConverter) StartParameterInternal(org.gradle.api.internal.StartParameterInternal) CommandLineParser(org.gradle.cli.CommandLineParser) Map(java.util.Map) HashMap(java.util.HashMap) ExecuteBuildAction(org.gradle.launcher.cli.action.ExecuteBuildAction) BuildAction(org.gradle.internal.invocation.BuildAction) ListenerManager(org.gradle.internal.event.ListenerManager) ReportedException(org.gradle.initialization.ReportedException)

Aggregations

BuildLayoutFactory (org.gradle.initialization.layout.BuildLayoutFactory)2 HashMap (java.util.HashMap)1 Map (java.util.Map)1 BuildResult (org.gradle.BuildResult)1 StartParameterInternal (org.gradle.api.internal.StartParameterInternal)1 CommandLineParser (org.gradle.cli.CommandLineParser)1 BuildRequestContext (org.gradle.initialization.BuildRequestContext)1 DefaultBuildRequestContext (org.gradle.initialization.DefaultBuildRequestContext)1 ReportedException (org.gradle.initialization.ReportedException)1 BuildLayout (org.gradle.initialization.layout.BuildLayout)1 ListenerManager (org.gradle.internal.event.ListenerManager)1 BuildAction (org.gradle.internal.invocation.BuildAction)1 LoggingManagerInternal (org.gradle.internal.logging.LoggingManagerInternal)1 Parameters (org.gradle.launcher.cli.Parameters)1 ParametersConverter (org.gradle.launcher.cli.ParametersConverter)1 ExecuteBuildAction (org.gradle.launcher.cli.action.ExecuteBuildAction)1 BuildActionParameters (org.gradle.launcher.exec.BuildActionParameters)1 DefaultBuildActionParameters (org.gradle.launcher.exec.DefaultBuildActionParameters)1 WrapperExecutor (org.gradle.wrapper.WrapperExecutor)1 Matchers.containsString (org.hamcrest.Matchers.containsString)1