use of com.android.tools.idea.gradle.util.LocalProperties in project android by JetBrains.
the class SdkSyncTest method assertProjectSdkSet.
private void assertProjectSdkSet() throws Exception {
myLocalProperties = new LocalProperties(myProject);
File actual = myLocalProperties.getAndroidSdkPath();
assertNotNull(actual);
assertEquals(myAndroidSdkPath.getPath(), actual.getPath());
}
use of com.android.tools.idea.gradle.util.LocalProperties in project android by JetBrains.
the class GuiTestRule method updateLocalProperties.
protected void updateLocalProperties(File projectPath) throws IOException {
LocalProperties localProperties = new LocalProperties(projectPath);
localProperties.setAndroidSdkPath(IdeSdks.getInstance().getAndroidSdkPath());
localProperties.save();
}
use of com.android.tools.idea.gradle.util.LocalProperties in project android by JetBrains.
the class SdkUpdaterConfigPanel method getSdkLocations.
@NotNull
private static Collection<File> getSdkLocations() {
File androidHome = IdeSdks.getInstance().getAndroidSdkPath();
if (androidHome != null) {
return ImmutableList.of(androidHome);
}
Set<File> locations = new HashSet<>();
// Gradle project.
for (Project project : ProjectManager.getInstance().getOpenProjects()) {
try {
LocalProperties localProperties = new LocalProperties(project);
File androidSdkPath = localProperties.getAndroidSdkPath();
if (androidSdkPath != null) {
locations.add(androidSdkPath);
continue;
}
} catch (IOException ignored) {
Logger.getInstance(SdkUpdaterConfigPanel.class).info("Unable to read local.properties file from project: " + project.getName(), ignored);
}
List<AndroidFacet> facets = ProjectFacetManager.getInstance(project).getFacets(AndroidFacet.ID);
for (AndroidFacet facet : facets) {
AndroidSdkData sdkData = facet.getConfiguration().getAndroidSdk();
if (sdkData != null) {
locations.add(sdkData.getLocation());
}
}
}
return locations;
}
use of com.android.tools.idea.gradle.util.LocalProperties in project android by JetBrains.
the class IdeSdksTest method testSetAndroidSdkPathUpdatingLocalPropertiesFile.
public void testSetAndroidSdkPathUpdatingLocalPropertiesFile() throws IOException {
LocalProperties localProperties = new LocalProperties(myProject);
localProperties.setAndroidSdkPath("");
localProperties.save();
List<Sdk> sdks = ApplicationManager.getApplication().runWriteAction((Computable<List<Sdk>>) () -> myIdeSdks.setAndroidSdkPath(myAndroidSdkPath, null));
assertOneSdkPerAvailableTarget(sdks);
localProperties = new LocalProperties(myProject);
File androidSdkPath = localProperties.getAndroidSdkPath();
assertNotNull(androidSdkPath);
assertEquals(myAndroidSdkPath.getPath(), androidSdkPath.getPath());
}
use of com.android.tools.idea.gradle.util.LocalProperties in project android by JetBrains.
the class GradleProjectSyncData method needsAndroidSdkSync.
private static boolean needsAndroidSdkSync(@NotNull final Project project) {
if (IdeInfo.getInstance().isAndroidStudio()) {
final File ideSdkPath = IdeSdks.getInstance().getAndroidSdkPath();
if (ideSdkPath != null) {
try {
LocalProperties localProperties = new LocalProperties(project);
File projectSdkPath = localProperties.getAndroidSdkPath();
return projectSdkPath == null || !filesEqual(ideSdkPath, projectSdkPath);
} catch (IOException ignored) {
}
}
return true;
}
return false;
}
Aggregations