Skip to content

Commit

Permalink
fix: target/compile sdk usage
Browse files Browse the repository at this point in the history
  • Loading branch information
breautek authored and erisu committed Apr 20, 2021
1 parent d1b91dc commit 98b0684
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 23 deletions.
5 changes: 0 additions & 5 deletions bin/templates/cordova/lib/builders/ProjectBuilder.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ var check_reqs = require('../check_reqs');
var PackageType = require('../PackageType');
const { compareByAll } = require('../utils');
const { createEditor } = require('properties-parser');
const constants = require('../constants');

const MARKER = 'YOUR CHANGES WILL BE ERASED!';
const SIGNING_PROPERTIES = '-signing.properties';
Expand Down Expand Up @@ -270,11 +269,7 @@ class ProjectBuilder {
// update/set the distributionUrl in the gradle-wrapper.properties
const gradleWrapperPropertiesPath = path.join(self.root, 'gradle/wrapper/gradle-wrapper.properties');
const gradleWrapperProperties = createEditor(gradleWrapperPropertiesPath);
<<<<<<< HEAD
const distributionUrl = process.env.CORDOVA_ANDROID_GRADLE_DISTRIBUTION_URL || `https://services.gradle.org/distributions/gradle-${defaults.DEFAULT_GRADLE_VERSION}-all.zip`;
=======
const distributionUrl = process.env.CORDOVA_ANDROID_GRADLE_DISTRIBUTION_URL || `https://services.gradle.org/distributions/gradle-${constants.DEFAULT_GRADLE_VERSION}-all.zip`;
>>>>>>> enhancement: Control SDK versions and other default projects in one place
gradleWrapperProperties.set('distributionUrl', distributionUrl);
gradleWrapperProperties.save();

Expand Down
2 changes: 1 addition & 1 deletion bin/templates/cordova/lib/prepare.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ module.exports.prepare = function (cordovaProject, options) {
const gradlePropertiesUserConfig = {};
if (minSdkVersion) gradlePropertiesUserConfig.cdvMinSdkVersion = minSdkVersion;
if (maxSdkVersion) gradlePropertiesUserConfig.cdvMaxSdkVersion = maxSdkVersion;
if (targetSdkVersion) gradlePropertiesUserConfig.cdvTargetSdkVersion = targetSdkVersion;
if (targetSdkVersion) gradlePropertiesUserConfig.cdvSdkVersion = targetSdkVersion;
if (args.jvmargs) gradlePropertiesUserConfig['org.gradle.jvmargs'] = args.jvmargs;
if (isGradlePluginKotlinEnabled) {
gradlePropertiesUserConfig['kotlin.code.style'] = gradlePluginKotlinCodeStyle || 'official';
Expand Down
28 changes: 11 additions & 17 deletions bin/templates/project/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,9 @@ task wrapper(type: Wrapper) {
ext {
apply from: '../CordovaLib/cordova.gradle'

// The value for android.compileSdkVersion.
if (!project.hasProperty('cdvCompileSdkVersion')) {
cdvCompileSdkVersion = null;
// The value for android.compileSdkVersion & android.targetSdkVersion
if (!project.hasProperty('cdvSdkVersion')) {
cdvSdkVersion = null;
}
// The value for android.buildToolsVersion.
if (!project.hasProperty('cdvBuildToolsVersion')) {
Expand All @@ -112,10 +112,6 @@ ext {
if (!project.hasProperty('cdvMaxSdkVersion')) {
cdvMaxSdkVersion = null
}
// The value for android.targetSdkVersion.
if (!project.hasProperty('cdvTargetSdkVersion')) {
cdvTargetSdkVersion = null;
}
// Whether to build architecture-specific APKs.
if (!project.hasProperty('cdvBuildMultipleApks')) {
cdvBuildMultipleApks = null
Expand Down Expand Up @@ -160,11 +156,11 @@ if (hasBuildExtras2) {
}

// Set property defaults after extension .gradle files.
ext.cdvCompileSdkVersion = cdvCompileSdkVersion == null ? (
defaultCompileSdkVersion == null
ext.cdvSdkVersion = cdvSdkVersion == null ? (
defaultSdkVersion == null
? privateHelpers.getProjectTarget()
: defaultCompileSdkVersion
) : Integer.parseInt('' + cdvCompileSdkVersion);
: defaultSdkVersion
) : Integer.parseInt('' + cdvSdkVersion);

if (ext.cdvBuildToolsVersion == null) {
ext.cdvBuildToolsVersion = privateHelpers.findLatestInstalledBuildTools()
Expand All @@ -186,7 +182,6 @@ ext.cdvMinSdkVersion = cdvMinSdkVersion == null ? defaultMinSdkVersion : Integer
if (cdvMaxSdkVersion != null) {
ext.cdvMaxSdkVersion = Integer.parseInt('' + cdvMaxSdkVersion)
}
ext.cdvTargetSdkVersion = cdvTargetSdkVersion == null ? defaultTargetSdkVersion : Integer.parseInt('' + cdvTargetSdkVersion)

ext.cdvVersionCode = cdvVersionCode == null ? null : Integer.parseInt('' + cdvVersionCode)

Expand Down Expand Up @@ -214,13 +209,12 @@ cdvBuildRelease.dependsOn {

task cdvPrintProps {
doLast {
println('cdvCompileSdkVersion=' + cdvCompileSdkVersion)
println('cdvSdkVersion=' + cdvSdkVersion)
println('cdvBuildToolsVersion=' + cdvBuildToolsVersion)
println('cdvVersionCode=' + cdvVersionCode)
println('cdvVersionCodeForceAbiDigit=' + cdvVersionCodeForceAbiDigit)
println('cdvMinSdkVersion=' + cdvMinSdkVersion)
println('cdvMaxSdkVersion=' + cdvMaxSdkVersion)
println('cdvTargetSdkVersion=' + cdvTargetSdkVersion)
println('cdvBuildMultipleApks=' + cdvBuildMultipleApks)
println('cdvReleaseSigningPropertiesFile=' + cdvReleaseSigningPropertiesFile)
println('cdvDebugSigningPropertiesFile=' + cdvDebugSigningPropertiesFile)
Expand All @@ -246,16 +240,16 @@ android {
maxSdkVersion cdvMaxSdkVersion
}

if(cdvTargetSdkVersion != null) {
targetSdkVersion cdvTargetSdkVersion
if (cdvSdkVersion != null) {
targetSdkVersion cdvSdkVersion
compileSdkVersion cdvSdkVersion
}
}

lintOptions {
abortOnError false;
}

compileSdkVersion cdvCompileSdkVersion
buildToolsVersion cdvBuildToolsVersion

// This code exists for Crosswalk and other Native APIs.
Expand Down

0 comments on commit 98b0684

Please sign in to comment.