Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(android): gradle 8 #14014

Merged
merged 20 commits into from
Sep 17, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions android/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ build/
/kroll-apt/bin/
/local.properties
/titanium/assets/Resources/ti.internal/build.properties
/.idea/
3 changes: 3 additions & 0 deletions android/.idea/codeStyles/Project.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 17 additions & 3 deletions android/.idea/inspectionProfiles/Project_Default.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 16 additions & 13 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,47 +9,50 @@ apply plugin: 'com.android.application'

// Set up Android app project.
android {
compileSdkVersion 33
m1ga marked this conversation as resolved.
Show resolved Hide resolved
ndkVersion project.ext.tiNdkVersion
//namespace 'com.titanium.test'
AbdullahFaqeir marked this conversation as resolved.
Show resolved Hide resolved
defaultConfig {
applicationId 'com.titanium.test'
minSdkVersion 21
compileSdk 33
minSdkVersion 26
AbdullahFaqeir marked this conversation as resolved.
Show resolved Hide resolved
targetSdkVersion 33
versionCode 1
versionName '1.0'
manifestPlaceholders = project.ext.tiManifestPlaceholders
manifestPlaceholders.put('localApplicationId', applicationId) // Legacy placeholder old AARs sometimes use.
}
lintOptions {
checkReleaseBuilds false
}
sourceSets {
main {
assets.srcDirs = [
'src/main/assets',
"${projectDir}/../titanium/build/outputs/ti-assets"
'src/main/assets',
"${projectDir}/../titanium/build/outputs/ti-assets"
hansemannn marked this conversation as resolved.
Show resolved Hide resolved
]
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_11
targetCompatibility JavaVersion.VERSION_11
sourceCompatibility JavaVersion.VERSION_17
targetCompatibility JavaVersion.VERSION_17
}
namespace 'com.titanium.test'
lint {
checkReleaseBuilds false
}
}

// Checks our Java code against our style guidelines and for common coding mistakes using "checkstyle.xml".
// Will trigger a build failure if any violations have been detected.
// Customize all the Checkstyle tasks
tasks.withType(Checkstyle) {
tasks.withType(Checkstyle).configureEach {
// Specify all files that should be checked
classpath = files()
source android.sourceSets.main.java.srcDirs
}
// Execute Checkstyle on all files
task checkJavaStyle(type: Checkstyle) {
tasks.register('checkJavaStyle', Checkstyle) {
// include '**/*.java'
}
// Execute Checkstyle on all modified files
task checkstyleChanged(type: Checkstyle) {
tasks.register('checkstyleChanged', Checkstyle) {
include getChangedFiles()
}

Expand All @@ -73,7 +76,7 @@ def getChangedFiles() {
files
}

tasks.withType(JavaCompile) {
tasks.withType(JavaCompile).configureEach {
dependsOn checkJavaStyle
}

Expand Down
14 changes: 7 additions & 7 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@
*/

buildscript {
ext.kotlin_version = '1.8.20'
ext.kotlin_version = '1.9.23'

repositories {
google()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:7.0.4'
classpath 'com.google.gms:google-services:4.3.15'
classpath 'com.android.tools.build:gradle:8.3.1'
AbdullahFaqeir marked this conversation as resolved.
Show resolved Hide resolved
classpath 'com.google.gms:google-services:4.4.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'org.codehaus.groovy:groovy-json:3.0.11'
classpath 'org.codehaus.groovy:groovy-json:3.0.17'
}
}

Expand All @@ -30,7 +30,7 @@ allprojects {
project.apply plugin: 'checkstyle'
checkstyle {
toolVersion = '8.38'
configFile file("${rootDir}/checkstyle.xml");
configFile file("${rootDir}/checkstyle.xml")
ignoreFailures false
showViolations true
}
Expand All @@ -39,6 +39,6 @@ allprojects {
project.apply from: "${rootDir}/templates/build/ti.constants.gradle"
}

task clean(type: Delete) {
delete rootProject.buildDir
tasks.register('clean', Delete) {
delete buildDir
}
6 changes: 1 addition & 5 deletions android/cli/commands/_build.js
Original file line number Diff line number Diff line change
Expand Up @@ -2080,7 +2080,6 @@ AndroidBuilder.prototype.generateLibProjectForModule = async function generateLi

// Load "AndroidManifest.xml", replace ${tiapp.properties['key']} variables, and save to above directories.
const manifest = await AndroidManifest.fromFilePath(sourceManifestFilePath);
manifest.setPackageName(moduleInfo.manifest.moduleid);
manifest.replaceTiPlaceholdersUsing(this.tiapp, this.appid);
await manifest.writeToFilePath(path.join(debugDirPath, 'AndroidManifest.xml'));
await manifest.writeToFilePath(path.join(releaseDirPath, 'AndroidManifest.xml'));
Expand All @@ -2103,7 +2102,6 @@ AndroidBuilder.prototype.generateLibProjectForModule = async function generateLi
this.logger.error(`Unable to load Android <manifest/> content from: ${tiModuleXmlFilePath}`);
throw ex;
}
mainManifest.setPackageName(moduleInfo.manifest.moduleid);
await mainManifest.writeToFilePath(path.join(projectSrcMainDirPath, 'AndroidManifest.xml'));

// Generate a "build.gradle" file for this project from the SDK's "lib.build.gradle" EJS template.
Expand Down Expand Up @@ -2195,6 +2193,7 @@ AndroidBuilder.prototype.generateRootProjectFiles = async function generateRootP
gradleProperties.push({ key: 'android.useAndroidX', value: 'true' });
gradleProperties.push({ key: 'android.enableJetifier', value: 'true' });
gradleProperties.push({ key: 'android.suppressUnsupportedCompileSdk', value: '33' });
gradleProperties.push({ key: 'android.nonTransitiveRClass', value: 'false' });
gradleProperties.push({ key: 'org.gradle.jvmargs', value: `-Xmx${this.javacMaxMemory}` });
await gradlew.writeGradlePropertiesFile(gradleProperties);

Expand Down Expand Up @@ -3718,9 +3717,6 @@ AndroidBuilder.prototype.generateAndroidManifest = async function generateAndroi

// Write secondary "AndroidManifest.xml" if not empty.
if (!secondaryManifest.isEmpty()) {
// Make sure package name is set in <manifest/> so that ".ClassName" references in XML can be resolved.
secondaryManifest.setPackageName(this.appid);

// Replace ${tiapp.properties['key']} placeholders in manifest.
secondaryManifest.replaceTiPlaceholdersUsing(this.tiapp, this.appid);

Expand Down
6 changes: 0 additions & 6 deletions android/cli/commands/_buildModule.js
Original file line number Diff line number Diff line change
Expand Up @@ -612,12 +612,6 @@ AndroidModuleBuilder.prototype.generateModuleProject = async function generateMo
this.logger.error('Unable to load Android <manifest/> content from "timodule.xml" file.');
throw err;
}
let packageName = moduleId;
if (packageName.indexOf('.') < 0) {
packageName = `ti.${packageName}`;
}
mainManifest.setPackageName(packageName);
await mainManifest.writeToFilePath(path.join(moduleMainDir, 'AndroidManifest.xml'));
AbdullahFaqeir marked this conversation as resolved.
Show resolved Hide resolved

// Generate Java file used to provide this module's JS source code to Titanium's JS runtime.
let fileContent = await fs.readFile(path.join(this.moduleTemplateDir, 'CommonJsSourceProvider.java'));
Expand Down
5 changes: 5 additions & 0 deletions android/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,8 @@ android.enableJetifier=false

# remove if com.android.tools.build:gradle can be raised in /android/build.gradle
android.suppressUnsupportedCompileSdk=33

# Enables(True)/Disables(false) namespacing of each library's R class so that its R class includes only the
# resources declared in the library itself and none from the library's dependencies,
# thereby reducing the size of the R class for that library
android.nonTransitiveRClass=false
3 changes: 2 additions & 1 deletion android/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#Tue Mar 19 21:28:34 EET 2024
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip
AbdullahFaqeir marked this conversation as resolved.
Show resolved Hide resolved
networkTimeout=10000
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
15 changes: 9 additions & 6 deletions android/kroll-apt/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,24 @@

apply plugin: 'java'

sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
java {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}

// Checks our Java code against our style guidelines and for common coding mistakes using "checkstyle.xml".
// Will trigger a build failure if any violations have been detected.
// Customize all the Checkstyle tasks
tasks.withType(Checkstyle) {
tasks.withType(Checkstyle).configureEach {
// Specify all files that should be checked
classpath = files()
source 'src/main/java'
}
// Execute Checkstyle on all files
task checkJavaStyle(type: Checkstyle) {
tasks.register('checkJavaStyle', Checkstyle) {
// include '**/*.java'
}
task checkstyleChanged(type: Checkstyle) {
tasks.register('checkstyleChanged', Checkstyle) {
include getChangedFiles()
}

Expand All @@ -47,14 +49,15 @@ def getChangedFiles() {
}

// Hook into Java compile task.
tasks.withType(JavaCompile) {
tasks.withType(JavaCompile).configureEach {
// Check Java code for mistakes before compiling.
dependsOn checkJavaStyle

// Suppress compiler warning "bootstrap class path not set in conjunction with source" which happens when
// building with JDK newer than the Java version we're targeting. (Ex: Build with JDK 8, but target Java 7.)
// Note: Build tool wants a reference to runtime JAR of the same version we're targeting. Not going to happen.
options.compilerArgs << '-Xlint:-options'
options.incremental = true
}

// Bundle the below library dependencies within this project's built JAR.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@

import org.json.simple.JSONValue;

@SupportedSourceVersion(SourceVersion.RELEASE_11)
@SupportedSourceVersion(SourceVersion.RELEASE_17)
@SuppressWarnings("unchecked")
@SupportedAnnotationTypes({
KrollJSONGenerator.Kroll_argument,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
org.appcelerator.kroll.annotations.generator.KrollJSONGenerator,dynamic
4 changes: 1 addition & 3 deletions android/settings.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
rootProject.name = 'TitaniumSDK'
include ':app'
include ':kroll-apt'
include ':titanium'
include ':app', ':kroll-apt', ':titanium'
1 change: 0 additions & 1 deletion android/templates/build/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest
xmlns:android="http://schemas.android.com/apk/res/android"
package="<%- packageName %>"
android:versionCode="1">

<% if (usesPermissions) { for (const nextPermission of usesPermissions) { %>
Expand Down
8 changes: 6 additions & 2 deletions android/templates/build/app.build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ repositories {

android {
compileSdkVersion <%- compileSdkVersion %>
namespace '<%- applicationId %>'
defaultConfig {
applicationId '<%- applicationId %>'
minSdkVersion <%- minSdkVersion %>
Expand All @@ -35,8 +36,11 @@ android {
<% } %>
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_11
targetCompatibility JavaVersion.VERSION_11
sourceCompatibility JavaVersion.VERSION_17
targetCompatibility JavaVersion.VERSION_17
}
buildFeatures {
buildConfig true
}
signingConfigs {
def tiKeystoreFilePath = <%- "'" + tiSdkAndroidDir.replace(/\\/g, '\\\\') + "/dev_keystore'" %>
Expand Down
11 changes: 5 additions & 6 deletions android/templates/build/root.build.gradle
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@

buildscript {
ext.kotlin_version = '1.8.20'
ext.kotlin_version = '1.9.23'

repositories {
google()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:7.0.4'
classpath 'com.google.gms:google-services:4.3.10'
classpath 'com.android.tools.build:gradle:8.3.1'
classpath 'com.google.gms:google-services:4.4.1'
AbdullahFaqeir marked this conversation as resolved.
Show resolved Hide resolved
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
Expand All @@ -21,6 +20,6 @@ allprojects {
project.apply from: "${rootDir}/ti.constants.gradle"
}

task clean(type: Delete) {
delete rootProject.buildDir
tasks.register('clean', Delete) {
delete buildDir
}
5 changes: 3 additions & 2 deletions android/templates/build/ti.constants.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@
*/

project.ext {
tiAndroidXAppCompatLibVersion = '1.6.1'
tiNdkVersion = '26.2.11394342'
tiAndroidXAppCompatLibVersion = '1.4.1'
tiAndroidXCoreLibVersion = '1.9.0'
tiAndroidXFragmentLibVersion = '1.5.7'
tiMaterialLibVersion = '1.6.1'
tiPlayServicesBaseLibVersion = '18.2.0'
tiManifestPlaceholders = [
tiActivityConfigChanges: 'density|fontScale|keyboard|keyboardHidden|layoutDirection|locale|mcc|mnc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|touchscreen|uiMode'
tiActivityConfigChanges: 'density|fontScale|keyboard|keyboardHidden|layoutDirection|locale|mcc|mnc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|touchscreen|uiMode'
hansemannn marked this conversation as resolved.
Show resolved Hide resolved
]
}
Loading