Skip to content

Commit

Permalink
Allow specifying compileSdk
Browse files Browse the repository at this point in the history
Users should be able to select compileSdk. Add `--compileSdk` option and
DO NOT verify it against our min required compile sdk.
This implements:
#927

Set min required compileSdk to 22 according to:
#920
  • Loading branch information
rosen-vladimirov committed Sep 25, 2015
1 parent 5d83392 commit 051c6af
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 7 deletions.
23 changes: 17 additions & 6 deletions lib/android-tools-info.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import * as semver from "semver";
export class AndroidToolsInfo implements IAndroidToolsInfo {
private static ANDROID_TARGET_PREFIX = "android";
private static SUPPORTED_TARGETS = ["android-17", "android-18", "android-19", "android-21", "android-22", "android-23"];
private static MIN_REQUIRED_COMPILE_TARGET = 21;
private static MIN_REQUIRED_COMPILE_TARGET = 22;
private static REQUIRED_BUILD_TOOLS_RANGE_PREFIX = ">=22";
private static VERSION_REGEX = /^(\d+\.){2}\d+$/;
private showWarningsAsErrors: boolean;
Expand Down Expand Up @@ -120,12 +120,23 @@ export class AndroidToolsInfo implements IAndroidToolsInfo {
private getCompileSdk(): IFuture<number> {
return ((): number => {
if(!this.selectedCompileSdk) {
let latestValidAndroidTarget = this.getLatestValidAndroidTarget().wait();
if(latestValidAndroidTarget) {
let integerVersion = this.parseAndroidSdkString(latestValidAndroidTarget);
let userSpecifiedCompileSdk = this.$options.compileSdk;
if(userSpecifiedCompileSdk) {
let installedTargets = this.getInstalledTargets().wait();
let androidCompileSdk = `${AndroidToolsInfo.ANDROID_TARGET_PREFIX}-${userSpecifiedCompileSdk}`;
if(!_.contains(installedTargets, androidCompileSdk)) {
this.$errors.failWithoutHelp(`You have specified '${userSpecifiedCompileSdk}' for compile sdk, but it is not installed on your system.`);
}

this.selectedCompileSdk = userSpecifiedCompileSdk;
} else {
let latestValidAndroidTarget = this.getLatestValidAndroidTarget().wait();
if(latestValidAndroidTarget) {
let integerVersion = this.parseAndroidSdkString(latestValidAndroidTarget);

if(integerVersion && integerVersion >= AndroidToolsInfo.MIN_REQUIRED_COMPILE_TARGET) {
this.selectedCompileSdk = integerVersion;
if(integerVersion && integerVersion >= AndroidToolsInfo.MIN_REQUIRED_COMPILE_TARGET) {
this.selectedCompileSdk = integerVersion;
}
}
}
}
Expand Down
1 change: 1 addition & 0 deletions lib/declarations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ interface IOptions extends ICommonOptions {
ignoreScripts: boolean;
tnsModulesVersion: string;
staticBindings: boolean;
compileSdk: number;
}

interface IProjectFilesManager {
Expand Down
3 changes: 2 additions & 1 deletion lib/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ export class Options extends commonOptionsLibPath.OptionsBase {
sdk: { type: OptionType.String },
ignoreScripts: {type: OptionType.Boolean },
tnsModulesVersion: { type: OptionType.String },
staticBindings: {type: OptionType.Boolean}
staticBindings: {type: OptionType.Boolean},
compileSdk: {type: OptionType.Number }
},
path.join($hostInfo.isWindows ? process.env.LocalAppData : path.join(osenv.home(), ".local/share"), ".nativescript-cli"),
$errors, $staticConfig);
Expand Down

0 comments on commit 051c6af

Please sign in to comment.