Skip to content

Commit

Permalink
v1.4.8
Browse files Browse the repository at this point in the history
Update project build
  • Loading branch information
krmanik committed Apr 14, 2022
1 parent fd24d7f commit a670562
Show file tree
Hide file tree
Showing 68 changed files with 261 additions and 5,415 deletions.
111 changes: 27 additions & 84 deletions CordovaLib/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,53 +16,43 @@
under the License.
*/

ext {
buildscript {
apply from: 'cordova.gradle'
cdvCompileSdkVersion = privateHelpers.getProjectTarget()
cdvBuildToolsVersion = privateHelpers.findLatestInstalledBuildTools()
}
apply from: 'repositories.gradle'

buildscript {
repositories {
google()
jcenter()
}
repositories repos

dependencies {
// The gradle plugin and the maven plugin have to be updated after each version of Android
// studio comes out
classpath 'com.android.tools.build:gradle:4.0.0'
classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1'
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7.3'
// Android Gradle Plugin (AGP) Build Tools
classpath "com.android.tools.build:gradle:${cordovaConfig.AGP_VERSION}"
}
}

allprojects {
repositories {
google()
jcenter()
def hasRepositoriesGradle = file('repositories.gradle').exists()
if (hasRepositoriesGradle) {
apply from: 'repositories.gradle'
} else {
apply from: "${project.rootDir}/repositories.gradle"
}

repositories repos
}

apply plugin: 'com.android.library'
apply plugin: 'com.github.dcendents.android-maven'
apply plugin: 'com.jfrog.bintray'

group = 'org.apache.cordova'
version = '9.0.0'

android {
compileSdkVersion cdvCompileSdkVersion
buildToolsVersion cdvBuildToolsVersion
compileSdkVersion cordovaConfig.SDK_VERSION
buildToolsVersion cordovaConfig.BUILD_TOOLS_VERSION

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}

// For the Android Cordova Lib, we will hardcode the minSdkVersion and not allow changes.
// For the Android Cordova Lib, we allow changing the minSdkVersion, but it is at the users own risk
defaultConfig {
minSdkVersion 22
minSdkVersion cordovaConfig.MIN_SDK_VERSION
}

sourceSets {
Expand All @@ -85,64 +75,17 @@ android {
}
}

install {
repositories.mavenInstaller {
pom {
project {
packaging 'aar'
name 'Cordova'
url 'https://cordova.apache.org'
licenses {
license {
name 'The Apache Software License, Version 2.0'
url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
}
}
developers {
developer {
id 'stevengill'
name 'Steve Gill'
}
}
scm {
connection 'scm:git:https://github.com/apache/cordova-android.git'
developerConnection 'scm:git:git@github.com:apache/cordova-android.git'
url 'https://github.com/apache/cordova-android'

}
}
}
}
}

task sourcesJar(type: Jar) {
from android.sourceSets.main.java.srcDirs
classifier = 'sources'
dependencies {
implementation "androidx.appcompat:appcompat:${cordovaConfig.ANDROIDX_APP_COMPAT_VERSION}"
implementation "androidx.webkit:webkit:${cordovaConfig.ANDROIDX_WEBKIT_VERSION}"
}

artifacts {
archives sourcesJar
}

bintray {
user = System.getenv('BINTRAY_USER')
key = System.getenv('BINTRAY_KEY')
configurations = ['archives']
pkg {
repo = 'maven'
name = 'cordova-android'
userOrg = 'cordova'
licenses = ['Apache-2.0']
vcsUrl = 'https://github.com/apache/cordova-android'
websiteUrl = 'https://cordova.apache.org'
issueTrackerUrl = 'https://github.com/apache/cordova-android/issues'
publicDownloadNumbers = true
licenses = ['Apache-2.0']
labels = ['android', 'cordova', 'phonegap']
version {
name = '9.0.0'
released = new Date()
vcsTag = '9.0.0'
}
}
/**
* In a project created though CLI, the `cordova-publish.gradle` file is not copied to the `framework` dir.
* App development (CLI) projects can not and should not publish our framework.
* In this case, there is no need for the gradle build process to know about the publish process.
*/
def cordovaPublishGradle = './cordova-publish.gradle'
if(file(cordovaPublishGradle).exists()) {
apply from: cordovaPublishGradle
}
100 changes: 68 additions & 32 deletions CordovaLib/cordova.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@
*/

import java.util.regex.Pattern
import groovy.swing.SwingBuilder
import com.g00fy2.versioncompare.Version
import io.github.g00fy2.versioncompare.Version

String doEnsureValueExists(filePath, props, key) {
if (props.get(key) == null) {
Expand Down Expand Up @@ -54,10 +53,13 @@ String doFindLatestInstalledBuildTools(String minBuildToolsVersionString) {
throw e
}

def minBuildToolsVersion = new Version(minBuildToolsVersionString)
def maxVersion = new Version((minBuildToolsVersion.getMajor() + 1) + ".0.0")

def highestBuildToolsVersion = buildToolsDirContents
.collect { new Version(it) }
// Invalid inputs will be handled as 0.0.0
.findAll { it.isHigherThan('0.0.0') }
.findAll { it.isHigherThan('0.0.0') && it.isLowerThan(maxVersion) }
.max()

if (highestBuildToolsVersion == null) {
Expand All @@ -69,7 +71,7 @@ String doFindLatestInstalledBuildTools(String minBuildToolsVersionString) {

if (highestBuildToolsVersion.isLowerThan(minBuildToolsVersionString)) {
throw new RuntimeException("""
No usable Android build tools found. Highest installed version is
No usable Android build tools found. Highest ${minBuildToolsVersion.getMajor()}.x installed version is
${highestBuildToolsVersion.getOriginalString()}; minimum version
required is ${minBuildToolsVersionString}.
""".replaceAll(/\s+/, ' ').trim())
Expand Down Expand Up @@ -131,30 +133,6 @@ def doExtractStringFromManifest(name) {
return matcher.group(1)
}

def doPromptForPassword(msg) {
if (System.console() == null) {
def ret = null
new SwingBuilder().edt {
dialog(modal: true, title: 'Enter password', alwaysOnTop: true, resizable: false, locationRelativeTo: null, pack: true, show: true) {
vbox {
label(text: msg)
def input = passwordField()
button(defaultButton: true, text: 'OK', actionPerformed: {
ret = input.password;
dispose();
})
}
}
}
if (!ret) {
throw new GradleException('User canceled build')
}
return new String(ret)
} else {
return System.console().readPassword('\n' + msg);
}
}

def doGetConfigXml() {
def xml = file("src/main/res/xml/config.xml").getText()
// Disable namespace awareness since Cordova doesn't use them properly
Expand All @@ -175,15 +153,72 @@ def doGetConfigPreference(name, defaultValue) {
return ret
}

def doApplyCordovaConfigCustomization() {
// Apply user overide properties that comes from the "--gradleArg=-P" parameters
if (project.hasProperty('cdvMinSdkVersion')) {
cordovaConfig.MIN_SDK_VERSION = Integer.parseInt('' + cdvMinSdkVersion)
}
if (project.hasProperty('cdvSdkVersion')) {
cordovaConfig.SDK_VERSION = Integer.parseInt('' + cdvSdkVersion)
}
if (project.hasProperty('cdvMaxSdkVersion')) {
cordovaConfig.MAX_SDK_VERSION = Integer.parseInt('' + cdvMaxSdkVersion)
}
if (project.hasProperty('cdvBuildToolsVersion')) {
cordovaConfig.BUILD_TOOLS_VERSION = cdvBuildToolsVersion
}
if (project.hasProperty('cdvAndroidXAppCompatVersion')) {
cordovaConfig.ANDROIDX_APP_COMPAT_VERSION = cdvAndroidXAppCompatVersion
}
if (project.hasProperty('cdvAndroidXWebKitVersion')) {
cordovaConfig.ANDROIDX_WEBKIT_VERSION = cdvAndroidXWebKitVersion
}

if (!cordovaConfig.BUILD_TOOLS_VERSION) {
cordovaConfig.BUILD_TOOLS_VERSION = doFindLatestInstalledBuildTools(
cordovaConfig.MIN_BUILD_TOOLS_VERSION
)
}

// Ensure the configured build tools version is at least our declared minimum
def buildToolsVersion = new Version(cordovaConfig.BUILD_TOOLS_VERSION)
if (buildToolsVersion.isLowerThan(cordovaConfig.MIN_BUILD_TOOLS_VERSION)) {
throw new RuntimeException("""
Expected Android Build Tools version >= ${cordovaConfig.MIN_BUILD_TOOLS_VERSION},
but got Android Build Tools version ${cordovaConfig.BUILD_TOOLS_VERSION}. Please use version ${cordovaConfig.MIN_BUILD_TOOLS_VERSION} or later.
""".replaceAll(/\s+/, ' ').trim())
}
}

// Properties exported here are visible to all plugins.
ext {
def defaultsFilePath = './cdv-gradle-config-defaults.json'
def projectConfigFilePath = "$rootDir/cdv-gradle-config.json"
def targetConfigFilePath = null

/**
* Check if the project config file path exists. This file will exist if coming from CLI project.
* If this file does not exist, falls back onto the default file.
* This scenario can occur if building the framework's AAR package for publishing.
*/
if(file(projectConfigFilePath).exists()) {
targetConfigFilePath = projectConfigFilePath
} else {
targetConfigFilePath = defaultsFilePath
}

def jsonFile = new File(targetConfigFilePath)
cordovaConfig = new groovy.json.JsonSlurper().parseText(jsonFile.text)

// Apply Gradle Properties
doApplyCordovaConfigCustomization()

// These helpers are shared, but are not guaranteed to be stable / unchanged.
privateHelpers = {}
privateHelpers.getProjectTarget = { doGetProjectTarget() }
privateHelpers.findLatestInstalledBuildTools = { doFindLatestInstalledBuildTools('19.1.0') }
privateHelpers.applyCordovaConfigCustomization = { doApplyCordovaConfigCustomization() }
privateHelpers.extractIntFromManifest = { name -> doExtractIntFromManifest(name) }
privateHelpers.extractStringFromManifest = { name -> doExtractStringFromManifest(name) }
privateHelpers.promptForPassword = { msg -> doPromptForPassword(msg) }
privateHelpers.ensureValueExists = { filePath, props, key -> doEnsureValueExists(filePath, props, key) }

// These helpers can be used by plugins / projects and will not change.
Expand All @@ -196,10 +231,11 @@ ext {

buildscript {
repositories {
jcenter()
google()
mavenCentral()
}

dependencies {
classpath 'com.g00fy2:versioncompare:1.3.4@jar'
classpath 'io.github.g00fy2:versioncompare:1.4.1@jar'
}
}
4 changes: 3 additions & 1 deletion CordovaLib/project.properties
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
# GENERATED FILE! DO NOT EDIT!

# This file was originally created by the Android Tools, but is now
# used by cordova-android to manage the project configuration.

# Indicates whether an apk should be generated for each density.
split.density=false

# Project target.
target=android-29
apk-configurations=
renderscript.opt.level=O0
android.library=true
target=android-29
23 changes: 23 additions & 0 deletions CordovaLib/repositories.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/* Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
*/

ext.repos = {
google()
mavenCentral()
jcenter()
}
Loading

0 comments on commit a670562

Please sign in to comment.