Search in sources :

Example 1 with DefaultBuildEnvironment

use of org.gradle.tooling.internal.build.DefaultBuildEnvironment in project gradle by gradle.

the class BuildEnvironmentBuilder method buildAll.

@Override
public Object buildAll(String modelName, Project target) {
    File gradleUserHomeDir = target.getGradle().getGradleUserHomeDir();
    String gradleVersion = target.getGradle().getGradleVersion();
    CurrentProcess currentProcess = new CurrentProcess(fileCollectionFactory);
    File javaHome = currentProcess.getJvm().getJavaHome();
    List<String> jvmArgs = currentProcess.getJvmOptions().getAllImmutableJvmArgs();
    DefaultBuildIdentifier buildIdentifier = new DefaultBuildIdentifier(target.getRootDir());
    return new DefaultBuildEnvironment(buildIdentifier, gradleUserHomeDir, gradleVersion, javaHome, jvmArgs);
}
Also used : DefaultBuildEnvironment(org.gradle.tooling.internal.build.DefaultBuildEnvironment) DefaultBuildIdentifier(org.gradle.tooling.internal.gradle.DefaultBuildIdentifier) CurrentProcess(org.gradle.process.internal.CurrentProcess) File(java.io.File)

Example 2 with DefaultBuildEnvironment

use of org.gradle.tooling.internal.build.DefaultBuildEnvironment in project gradle by gradle.

the class ProviderConnection method run.

public Object run(String modelName, BuildCancellationToken cancellationToken, ProviderOperationParameters providerParameters) {
    List<String> tasks = providerParameters.getTasks();
    if (modelName.equals(ModelIdentifier.NULL_MODEL) && tasks == null) {
        throw new IllegalArgumentException("No model type or tasks specified.");
    }
    Parameters params = initParams(providerParameters);
    if (BuildEnvironment.class.getName().equals(modelName)) {
        // we don't really need to launch the daemon to acquire information needed for BuildEnvironment
        if (tasks != null) {
            throw new IllegalArgumentException("Cannot run tasks and fetch the build environment model.");
        }
        return new DefaultBuildEnvironment(new DefaultBuildIdentifier(providerParameters.getProjectDir()), params.buildLayout.getGradleUserHomeDir(), GradleVersion.current().getVersion(), params.daemonParams.getEffectiveJvm().getJavaHome(), params.daemonParams.getEffectiveJvmArgs());
    }
    StartParameterInternal startParameter = new ProviderStartParameterConverter().toStartParameter(providerParameters, params.buildLayout, params.properties);
    ProgressListenerConfiguration listenerConfig = ProgressListenerConfiguration.from(providerParameters, consumerVersion);
    BuildAction action = new BuildModelAction(startParameter, modelName, tasks != null, listenerConfig.clientSubscriptions);
    return run(action, cancellationToken, listenerConfig, listenerConfig.buildEventConsumer, providerParameters, params);
}
Also used : DefaultBuildEnvironment(org.gradle.tooling.internal.build.DefaultBuildEnvironment) ProviderConnectionParameters(org.gradle.tooling.internal.provider.connection.ProviderConnectionParameters) ProviderOperationParameters(org.gradle.tooling.internal.provider.connection.ProviderOperationParameters) DaemonParameters(org.gradle.launcher.daemon.configuration.DaemonParameters) BuildActionParameters(org.gradle.launcher.exec.BuildActionParameters) DefaultBuildIdentifier(org.gradle.tooling.internal.gradle.DefaultBuildIdentifier) BuildEnvironment(org.gradle.tooling.model.build.BuildEnvironment) DefaultBuildEnvironment(org.gradle.tooling.internal.build.DefaultBuildEnvironment) StartParameterInternal(org.gradle.api.internal.StartParameterInternal) ClientProvidedBuildAction(org.gradle.tooling.internal.provider.action.ClientProvidedBuildAction) BuildAction(org.gradle.internal.invocation.BuildAction) BuildModelAction(org.gradle.tooling.internal.provider.action.BuildModelAction)

Aggregations

DefaultBuildEnvironment (org.gradle.tooling.internal.build.DefaultBuildEnvironment)2 DefaultBuildIdentifier (org.gradle.tooling.internal.gradle.DefaultBuildIdentifier)2 File (java.io.File)1 StartParameterInternal (org.gradle.api.internal.StartParameterInternal)1 BuildAction (org.gradle.internal.invocation.BuildAction)1 DaemonParameters (org.gradle.launcher.daemon.configuration.DaemonParameters)1 BuildActionParameters (org.gradle.launcher.exec.BuildActionParameters)1 CurrentProcess (org.gradle.process.internal.CurrentProcess)1 BuildModelAction (org.gradle.tooling.internal.provider.action.BuildModelAction)1 ClientProvidedBuildAction (org.gradle.tooling.internal.provider.action.ClientProvidedBuildAction)1 ProviderConnectionParameters (org.gradle.tooling.internal.provider.connection.ProviderConnectionParameters)1 ProviderOperationParameters (org.gradle.tooling.internal.provider.connection.ProviderOperationParameters)1 BuildEnvironment (org.gradle.tooling.model.build.BuildEnvironment)1