use of com.android.repository.Revision in project android by JetBrains.
the class LintIdeClient method getBuildTools.
@Override
@Nullable
public BuildToolInfo getBuildTools(@NonNull com.android.tools.lint.detector.api.Project project) {
if (project.isGradleProject()) {
Module module = getModule();
if (module != null) {
AndroidModuleModel model = AndroidModuleModel.get(module);
if (model != null) {
GradleVersion version = model.getModelVersion();
if (version != null && version.isAtLeast(2, 1, 0)) {
String buildToolsVersion = model.getAndroidProject().getBuildToolsVersion();
AndroidSdkHandler sdk = getSdk();
if (sdk != null) {
try {
Revision revision = Revision.parseRevision(buildToolsVersion);
BuildToolInfo buildToolInfo = sdk.getBuildToolInfo(revision, getRepositoryLogger());
if (buildToolInfo != null) {
return buildToolInfo;
}
} catch (NumberFormatException ignore) {
// Fall through and use the latest
}
}
}
}
}
}
return super.getBuildTools(project);
}
use of com.android.repository.Revision in project android by JetBrains.
the class IdeSdks method isJdk7Supported.
public boolean isJdk7Supported(@Nullable AndroidSdkData sdkData) {
if (sdkData != null) {
ProgressIndicator progress = new StudioLoggerProgressIndicator(Jdks.class);
LocalPackage info = sdkData.getSdkHandler().getLocalPackage(SdkConstants.FD_PLATFORM_TOOLS, progress);
if (info != null) {
Revision revision = info.getVersion();
if (revision.getMajor() >= 19) {
JavaSdk jdk = JavaSdk.getInstance();
Sdk sdk = ProjectJdkTable.getInstance().findMostRecentSdkOfType(jdk);
if (sdk != null) {
JavaSdkVersion version = jdk.getVersion(sdk);
if (version != null && version.isAtLeast(JavaSdkVersion.JDK_1_7)) {
return true;
}
}
}
}
}
return false;
}
use of com.android.repository.Revision in project android by JetBrains.
the class InstantRunConfigurable method updateProjectToInstantRunTools.
/** Update versions relevant for Instant Run, and trigger a Gradle sync if successful */
public static boolean updateProjectToInstantRunTools(@NotNull Project project, @Nullable GradleSyncListener listener) {
String pluginVersion = MINIMUM_GRADLE_PLUGIN_VERSION_STRING;
// Pick max version of "recommended Gradle plugin" and "minimum required for instant run"
if (GradleVersion.parse(GRADLE_PLUGIN_RECOMMENDED_VERSION).compareTo(MINIMUM_GRADLE_PLUGIN_VERSION) > 0) {
pluginVersion = GRADLE_PLUGIN_RECOMMENDED_VERSION;
}
// Update plugin version
AndroidPluginVersionUpdater updater = AndroidPluginVersionUpdater.getInstance(project);
UpdateResult result = updater.updatePluginVersion(GradleVersion.parse(pluginVersion), GradleVersion.parse(GRADLE_LATEST_VERSION));
if (result.isPluginVersionUpdated() && result.versionUpdateSuccess()) {
// Should be at least 23.0.2
String buildToolsVersion = "23.0.2";
AndroidSdkHandler sdk = AndroidSdks.getInstance().tryToChooseSdkHandler();
BuildToolInfo latestBuildTool = sdk.getLatestBuildTool(new StudioLoggerProgressIndicator(InstantRunConfigurable.class), false);
if (latestBuildTool != null) {
Revision revision = latestBuildTool.getRevision();
if (revision.compareTo(Revision.parseRevision(buildToolsVersion)) > 0) {
buildToolsVersion = revision.toShortString();
}
}
// Also update build files to set build tools version 23.0.2
GradleUtil.setBuildToolsVersion(project, buildToolsVersion);
// Also update Gradle wrapper version
GradleWrapper gradleWrapper = GradleWrapper.find(project);
if (gradleWrapper != null) {
gradleWrapper.updateDistributionUrlAndDisplayFailure(GRADLE_LATEST_VERSION);
}
// Request a sync
GradleSyncInvoker.Request request = new GradleSyncInvoker.Request().setRunInBackground(false);
GradleSyncInvoker.getInstance().requestProjectSync(project, request, listener);
return true;
} else {
return false;
}
}
use of com.android.repository.Revision in project android by JetBrains.
the class InstallBuildToolsHyperlink method execute.
@Override
protected void execute(@NotNull Project project) {
List<String> requested = Lists.newArrayList();
Revision minBuildToolsRev = Revision.parseRevision(myVersion);
requested.add(DetailsTypes.getBuildToolsPath(minBuildToolsRev));
ModelWizardDialog dialog = SdkQuickfixUtils.createDialogForPaths(project, requested);
if (dialog != null && dialog.showAndGet()) {
if (myBuildFile != null) {
setBuildToolsVersion(project, myBuildFile, myVersion, true);
} else {
GradleSyncInvoker.getInstance().requestProjectSyncAndSourceGeneration(project, null);
}
}
}
use of com.android.repository.Revision in project android by JetBrains.
the class SdkComponentSourceTest method setUp.
@Override
public void setUp() throws Exception {
super.setUp();
//noinspection Convert2Lambda Since otherwise it desn't create new instances.
myDisposable = new Disposable() {
@Override
public void dispose() {
}
};
MockApplicationEx instance = new MockApplicationEx(myDisposable);
instance.registerService(ExternalComponentManager.class, ExternalComponentManagerImpl.class);
instance.registerService(UpdateSettings.class, UpdateSettings.class);
ApplicationManager.setApplication(instance, myDisposable);
myFileOp = new MockFileOp();
myFileOp.recordExistingFile("/sdk/noRemote/package.xml", getLocalRepoXml("noRemote", new Revision(1)));
myFileOp.recordExistingFile("/sdk/newerRemote/package.xml", getLocalRepoXml("newerRemote", new Revision(1)));
myFileOp.recordExistingFile("/sdk/sameRemote/package.xml", getLocalRepoXml("sameRemote", new Revision(1)));
myFileOp.recordExistingFile("/sdk/olderRemote/package.xml", getLocalRepoXml("olderRemote", new Revision(1, 2)));
myFileOp.recordExistingFile("/sdk/hasPreview/package.xml", getLocalRepoXml("hasPreview", new Revision(1)));
myFileOp.recordExistingFile("/sdk/newerPreview/package.xml", getLocalRepoXml("newerPreview", new Revision(1, 0, 0, 1)));
myFileOp.recordExistingFile("/sdk/samePreview/package.xml", getLocalRepoXml("samePreview", new Revision(1, 0, 0, 1)));
myFileOp.recordExistingFile("/sdk/olderPreview/package.xml", getLocalRepoXml("olderPreview", new Revision(2)));
myFileOp.recordExistingFile("/sdk/zNewerInBeta/package.xml", getLocalRepoXml("zNewerInBeta", new Revision(1)));
final FakeDownloader downloader = new FakeDownloader(myFileOp);
List<String> remotePaths = Lists.newArrayList();
List<Revision> remoteRevisions = Lists.newArrayList();
List<Integer> remoteChannels = Lists.newArrayList();
remotePaths.add("newerRemote");
remoteRevisions.add(new Revision(1, 1));
remoteChannels.add(0);
remotePaths.add("sameRemote");
remoteRevisions.add(new Revision(1));
remoteChannels.add(0);
remotePaths.add("olderRemote");
remoteRevisions.add(new Revision(1, 1));
remoteChannels.add(0);
remotePaths.add("hasPreview");
remoteRevisions.add(new Revision(1, 0, 0, 1));
remoteChannels.add(0);
remotePaths.add("newerPreview");
remoteRevisions.add(new Revision(1, 0, 0, 2));
remoteChannels.add(0);
remotePaths.add("samePreview");
remoteRevisions.add(new Revision(1, 0, 0, 1));
remoteChannels.add(0);
remotePaths.add("olderPreview");
remoteRevisions.add(new Revision(1, 0, 0, 1));
remoteChannels.add(0);
remotePaths.add("onlyRemote");
remoteRevisions.add(new Revision(1));
remoteChannels.add(0);
remotePaths.add("zNewerInBeta");
remoteRevisions.add(new Revision(2));
remoteChannels.add(1);
String url = "http://example.com/repo";
downloader.registerUrl(new URL(url), getRepoXml(remotePaths, remoteRevisions, remoteChannels, true).getBytes());
final RepoManager mgr = new RepoManagerImpl(myFileOp);
mgr.setLocalPath(new File("/sdk"));
mgr.registerSchemaModule(AndroidSdkHandler.getRepositoryModule());
mgr.registerSchemaModule(AndroidSdkHandler.getCommonModule());
mgr.registerSourceProvider(new FakeRepositorySourceProvider(ImmutableList.<RepositorySource>of(new SimpleRepositorySource(url, "dummy", true, mgr.getSchemaModules(), null))));
myChannelId = 0;
myTestComponentSource = new SdkComponentSource() {
@Nullable
@Override
public List<String> getAllChannels() {
return null;
}
@Override
@NotNull
RepoManager getRepoManager() {
return mgr;
}
@NotNull
@Override
SettingsController getSettingsController() {
return new FakeSettingsController(false) {
@Override
public Channel getChannel() {
return Channel.create(myChannelId);
}
};
}
@NotNull
@Override
Downloader getDownloader(@Nullable ProgressIndicator indicator) {
return downloader;
}
};
}
Aggregations