use of com.android.sdklib.repository.AndroidSdkHandler in project android by JetBrains.
the class InstallTaskTest method setUp.
@Before
public void setUp() {
Mockito.when(myExisting1.getPath()).thenReturn("p1");
Mockito.when(myAvailable1.getPath()).thenReturn("p2");
Mockito.when(myAvailable2.getPath()).thenReturn("p3");
RepositoryPackages repoPackages = new RepositoryPackages(ImmutableList.of(myExisting1), ImmutableList.of(myAvailable1, myAvailable2));
AndroidSdkHandler repoHandler = new AndroidSdkHandler(SDK_ROOT, null, myFileOp, new FakeRepoManager(SDK_ROOT, repoPackages));
RepoManager repoManager = repoHandler.getSdkManager(myProgressIndicator);
myInstallTask = new InstallTask(factory, repoHandler, new FakeSettingsController(false), myProgressIndicator);
myInstallTask.setInstallRequests(ImmutableList.of(new UpdatablePackage(myAvailable1), new UpdatablePackage(myAvailable2)));
myInstallTask.setUninstallRequests(ImmutableList.of(myExisting1));
Mockito.when(myInstaller.prepare(myProgressIndicator)).thenReturn(true);
Mockito.when(myInstaller2.prepare(myProgressIndicator)).thenReturn(true);
Mockito.when(myUninstaller.prepare(myProgressIndicator)).thenReturn(true);
Mockito.when(myInstaller.complete(myProgressIndicator)).thenReturn(true);
Mockito.when(myInstaller2.complete(myProgressIndicator)).thenReturn(true);
Mockito.when(myUninstaller.complete(myProgressIndicator)).thenReturn(true);
myOperations = new HashMap<>();
myOperations.put(myExisting1, myUninstaller);
myOperations.put(myAvailable1, myInstaller);
myOperations.put(myAvailable2, myInstaller2);
Mockito.when(factory.createInstaller(eq(myAvailable1), eq(repoManager), any(), eq(myFileOp))).thenReturn(myInstaller);
Mockito.when(factory.createInstaller(eq(myAvailable2), eq(repoManager), any(), eq(myFileOp))).thenReturn(myInstaller2);
Mockito.when(factory.createUninstaller(myExisting1, repoManager, myFileOp)).thenReturn(myUninstaller);
}
use of com.android.sdklib.repository.AndroidSdkHandler in project android by JetBrains.
the class AndroidSdksTest method testTryToChooseSdkHandler.
public void testTryToChooseSdkHandler() {
myAndroidSdks.create(findAndroidTarget(), mySdkPath, myJdk, false);
AndroidSdkHandler sdkHandler = myAndroidSdks.tryToChooseSdkHandler();
AndroidSdkData sdkData = getSdkData(mySdkPath);
assertNotNull(sdkData);
assertSame(sdkData.getSdkHandler(), sdkHandler);
}
use of com.android.sdklib.repository.AndroidSdkHandler in project android by JetBrains.
the class AndroidJpsUtil method getAndroidTarget.
@Nullable
public static Pair<IAndroidTarget, AndroidSdkHandler> getAndroidTarget(@NotNull JpsSdk<JpsSimpleElement<JpsAndroidSdkProperties>> sdk, @Nullable CompileContext context, String builderName) {
JpsAndroidSdkProperties sdkProperties = sdk.getSdkProperties().getData();
final String targetHashString = sdkProperties.getBuildTargetHashString();
if (targetHashString == null) {
if (context != null) {
context.processMessage(new CompilerMessage(builderName, BuildMessage.Kind.ERROR, "Cannot parse SDK " + sdk.getParent().getName() + ": build target is not specified"));
}
return null;
}
final AndroidSdkHandler sdkHandler = AndroidSdkHandler.getInstance(new File(sdk.getHomePath()));
RepoLogger log = new RepoLogger();
final IAndroidTarget target = sdkHandler.getAndroidTargetManager(log).getTargetFromHashString(targetHashString, log);
if (target == null) {
if (context != null) {
context.processMessage(new CompilerMessage(builderName, BuildMessage.Kind.ERROR, "Cannot parse SDK '" + sdk.getParent().getName() + "': unknown target " + targetHashString));
}
return null;
}
return Pair.create(target, sdkHandler);
}
Aggregations