Skip to content

Commit

Permalink
Merge pull request #28 from jquick-axway/TIMOB-25865
Browse files Browse the repository at this point in the history
[TIMOB-25865] Android: Modified CLI to not select "build-tools" version newer than supported if a supported version is installed
  • Loading branch information
lokeshchdhry committed Jun 5, 2018
2 parents ce51b4a + b5c2a57 commit dbdb4f7
Showing 1 changed file with 34 additions and 15 deletions.
49 changes: 34 additions & 15 deletions lib/android.js
Original file line number Diff line number Diff line change
Expand Up @@ -451,20 +451,27 @@ exports.detect = function detect(config, opts, finished) {

// check if the sdk is missing any commands
var missing = Object.keys(requiredSdkTools).filter(function (cmd) { return !results.sdk.executables[cmd]; });
if (missing.length) {
if (missing.length || !results.sdk.buildTools.supported) {
var dummyPath = path.join(path.resolve('/'), 'path', 'to', 'android-sdk'),
msg = __n('Missing required Android SDK tool: %%s', 'Missing required Android SDK tools: %%s', missing.length, '__' + missing.join(', ') + '__') + '\n\n'
+ __('The Android SDK located at %s has incomplete or out-of-date packages.', '__' + results.sdk.path + '__') + '\n\n'
+ __('Current installed Android SDK tools:') + '\n'
+ ' Android SDK Tools: ' + (results.sdk.tools.version || 'not installed') + '\n'
+ ' Android SDK Platform Tools: ' + (results.sdk.platformTools.version || 'not installed') + '\n'
+ ' Android SDK Build Tools: ' + (results.sdk.buildTools.version || 'not installed') + '\n\n'
+ __('Make sure you have the latest Android SDK Tools, Platform Tools, and Build Tools installed.') + '\n\n'
+ __('You can also specify the exact location of these required tools by running:') + '\n';

missing.forEach(function (m) {
msg += ' ' + commandPrefix + 'ti config android.executables.' + m + ' "' + path.join(dummyPath, m + requiredSdkTools[m]) + '"\n';
});
msg = '';

if (missing.length) {
msg += __n('Missing required Android SDK tool: %%s', 'Missing required Android SDK tools: %%s', missing.length, '__' + missing.join(', ') + '__') + '\n\n';
}

msg += __('The Android SDK located at %s has incomplete or out-of-date packages.', '__' + results.sdk.path + '__') + '\n\n'
+ __('Current installed Android SDK tools:') + '\n'
+ ' Android SDK Tools: ' + (results.sdk.tools.version || 'not installed') + ' (Supported: ' + androidPackageJson.vendorDependencies['android tools'] + ')' + '\n'
+ ' Android SDK Platform Tools: ' + (results.sdk.platformTools.version || 'not installed') + ' (Supported: ' + androidPackageJson.vendorDependencies['android platform tools'] + ')' + '\n'
+ ' Android SDK Build Tools: ' + (results.sdk.buildTools.version || 'not installed') + ' (Supported: ' + androidPackageJson.vendorDependencies['android build tools'] + ')' + '\n\n'
+ __('Make sure you have the latest Android SDK Tools, Platform Tools, and Build Tools installed.') + '\n';

if (missing.length) {
msg += '\n' + __('You can also specify the exact location of these required tools by running:') + '\n';
missing.forEach(function (m) {
msg += ' ' + commandPrefix + 'ti config android.executables.' + m + ' "' + path.join(dummyPath, m + requiredSdkTools[m]) + '"\n';
});
}

msg += '\n' + __('If you need to, run "%s" to reconfigure the Titanium Android settings.', commandPrefix + 'titanium setup android');

Expand Down Expand Up @@ -765,11 +772,23 @@ function findSDK(dir, config, androidPackageJson, callback) {
len = files.length,
buildToolsSupported;
for(; i < len; i++) {
if (buildToolsSupported = appc.version.satisfies(files[i], androidPackageJson.vendorDependencies['android build tools'], true)) {
var isSupported = appc.version.satisfies(files[i], androidPackageJson.vendorDependencies['android build tools'], true);
if (isSupported) {
buildToolsSupported = isSupported;
ver = files[i];
break;
if (buildToolsSupported == true) {
// The version found is fully supported (not set to 'maybe'). So, stop here.
break;
}
}
}

// If we've failed to find a build-tools version that Titanium supports up above,
// then grab the newest old version installed to be logged as unsupported later.
if (!ver && (len > 0)) {
ver = files[len - 1];
buildToolsSupported = false;
}
}
if (ver) {
// A selectedVersion specified or supported version has been found
Expand Down

0 comments on commit dbdb4f7

Please sign in to comment.