Skip to content

Commit

Permalink
fix: compile sdk requirement warning & display in gradle per subproject
Browse files Browse the repository at this point in the history
  • Loading branch information
erisu committed May 16, 2022
1 parent 802ff14 commit 30fbc85
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 2 deletions.
2 changes: 2 additions & 0 deletions framework/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ buildscript {
// Android Gradle Plugin (AGP) Build Tools
classpath "com.android.tools.build:gradle:${cordovaConfig.AGP_VERSION}"
}

cdvHelpers.verifyCordovaConfigForBuild()
}

allprojects {
Expand Down
6 changes: 5 additions & 1 deletion framework/cordova.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -191,9 +191,11 @@ def doApplyCordovaConfigCustomization() {
but got Android Build Tools version ${cordovaConfig.BUILD_TOOLS_VERSION}. Please use version ${cordovaConfig.MIN_BUILD_TOOLS_VERSION} or later.
""".replaceAll(/\s+/, ' ').trim())
}
}

def doVerifyCordovaConfigForBuild() {
if (cordovaConfig.COMPILE_SDK_VERSION < cordovaConfig.SDK_VERSION) {
println "The compileSdkVersion (${cordovaConfig.COMPILE_SDK_VERSION}) should be greater than or equal to the the targetSdkVersion (${cordovaConfig.SDK_VERSION}.)"
println "The \"compileSdkVersion\" (${cordovaConfig.COMPILE_SDK_VERSION}) should be greater than or equal to the the \"targetSdkVersion\" (${cordovaConfig.SDK_VERSION})."
}
}

Expand Down Expand Up @@ -238,6 +240,8 @@ ext {
cdvHelpers.getConfigXml = { doGetConfigXml() }
// Returns the value for the desired <preference>. Added in 4.1.0.
cdvHelpers.getConfigPreference = { name, defaultValue -> doGetConfigPreference(name, defaultValue) }
// Display warnings if any cordova config is not proper for build.
cdvHelpers.verifyCordovaConfigForBuild = { doVerifyCordovaConfigForBuild() }
}

buildscript {
Expand Down
2 changes: 1 addition & 1 deletion lib/check_reqs.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ module.exports.isCompileSdkValid = (compileSdk, targetSdk) => {
const isValid = compileSdk >= targetSdk;

if (!isValid) {
events.emit('warn', `android-compileSdkVersion should be greater than or equal to the android-targetSdkVersion (${targetSdk}.)`);
events.emit('warn', `The "android-compileSdkVersion" (${compileSdk}) should be greater than or equal to the "android-targetSdkVersion" (${targetSdk}).`);
}

return isValid;
Expand Down
2 changes: 2 additions & 0 deletions templates/project/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ buildscript {
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}

cdvHelpers.verifyCordovaConfigForBuild()
}

allprojects {
Expand Down

0 comments on commit 30fbc85

Please sign in to comment.