use of org.gradle.tooling.GradleConnector in project android by JetBrains.
the class AndroidGradleTargetBuilder method getGradleConnector.
@NotNull
private static GradleConnector getGradleConnector(@NotNull BuilderExecutionSettings executionSettings) {
GradleConnector connector = GradleConnector.newConnector();
if (connector instanceof DefaultGradleConnector) {
DefaultGradleConnector defaultConnector = (DefaultGradleConnector) connector;
if (executionSettings.isEmbeddedModeEnabled()) {
LOG.info("Using Gradle embedded mode.");
defaultConnector.embedded(true);
}
defaultConnector.setVerboseLogging(executionSettings.isVerboseLoggingEnabled());
}
connector.forProjectDirectory(executionSettings.getProjectDir());
File gradleHomeDir = executionSettings.getGradleHomeDir();
if (gradleHomeDir != null) {
connector.useInstallation(gradleHomeDir);
}
File gradleServiceDir = executionSettings.getGradleServiceDir();
if (gradleServiceDir != null) {
connector.useGradleUserHomeDir(gradleServiceDir);
}
return connector;
}
use of org.gradle.tooling.GradleConnector in project android by JetBrains.
the class ExportSignedPackageTest method getAndroidProject.
/**
* Returns the {@link com.android.builder.model.AndroidProject} given the gradle project root.
* Note that this works only single module projects (only one build.gradle)
*/
@Nullable
private static AndroidProject getAndroidProject(String projectPath) {
File androidPlugin = new File(AndroidTestBase.getAndroidPluginHome());
File projectDir = new File(androidPlugin, BASE_PATH + projectPath);
GradleConnector connector = GradleConnector.newConnector();
connector.forProjectDirectory(projectDir);
connector.useDistribution(new DistributionLocator().getDistributionFor(GradleVersion.version("2.2.1")));
AndroidProject model = null;
ProjectConnection connection = connector.connect();
try {
model = connection.getModel(AndroidProject.class);
} finally {
connection.close();
}
return model;
}
Aggregations