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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions android/.gitignore
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
Expand Up @@ -9,47 +9,50 @@ apply plugin: 'com.android.application'

// Set up Android app project.
android {
compileSdkVersion 33
ndkVersion project.ext.tiNdkVersion
//namespace 'com.titanium.test'
defaultConfig {
applicationId 'com.titanium.test'
minSdkVersion 21
compileSdk 33
minSdkVersion 26
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"
Comment on lines +27 to +28
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are these indentations intentional?

Suggested change
'src/main/assets',
"${projectDir}/../titanium/build/outputs/ti-assets"
'src/main/assets',
"${projectDir}/../titanium/build/outputs/ti-assets"

]
}
}
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
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'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this the newest Gradle version we can upgrade to? I see 8.3 is over 8 months and 8.7 dropped about a month ago.

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
}
3 changes: 3 additions & 0 deletions android/gradle.properties
Expand Up @@ -15,3 +15,6 @@ android.enableJetifier=false

# remove if com.android.tools.build:gradle can be raised in /android/build.gradle
android.suppressUnsupportedCompileSdk=33
android.defaults.buildfeatures.buildconfig=true
android.nonTransitiveRClass=false
android.nonFinalResIds=false
3 changes: 2 additions & 1 deletion android/gradle/wrapper/gradle-wrapper.properties
@@ -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
networkTimeout=10000
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
15 changes: 9 additions & 6 deletions android/kroll-apt/build.gradle
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
@@ -0,0 +1 @@
org.appcelerator.kroll.annotations.generator.KrollJSONGenerator,dynamic
4 changes: 1 addition & 3 deletions android/settings.gradle
@@ -1,4 +1,2 @@
rootProject.name = 'TitaniumSDK'
include ':app'
include ':kroll-apt'
include ':titanium'
include ':app', ':kroll-apt', ':titanium'
1 change: 1 addition & 0 deletions android/templates/build/app.build.gradle
Expand Up @@ -14,6 +14,7 @@ repositories {

android {
compileSdkVersion <%- compileSdkVersion %>
namespace '<%- applicationId %>'
defaultConfig {
applicationId '<%- applicationId %>'
minSdkVersion <%- minSdkVersion %>
Expand Down
11 changes: 5 additions & 6 deletions android/templates/build/root.build.gradle
@@ -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'
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
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'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Intentional indention?

Suggested change
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'

]
}
27 changes: 14 additions & 13 deletions android/titanium/AndroidManifest.xml
@@ -1,39 +1,40 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="org.appcelerator.titanium">
<manifest xmlns:android="http://schemas.android.com/apk/res/android">

<application>
<activity
android:name="org.appcelerator.titanium.TiActivity"
android:exported="false"
android:configChanges="${tiActivityConfigChanges}"/>
android:configChanges="${tiActivityConfigChanges}"
android:exported="false" />
<activity
android:name="org.appcelerator.titanium.TiTranslucentActivity"
android:exported="false"
android:configChanges="${tiActivityConfigChanges}"
android:theme="@style/Theme.AppDerived.Translucent"/>
android:exported="false"
android:theme="@style/Theme.AppDerived.Translucent" />
<activity
android:name="ti.modules.titanium.media.TiCameraActivity"
android:exported="false"
android:configChanges="${tiActivityConfigChanges}"
android:theme="@style/Theme.Titanium.Dark.Fullscreen"/>
android:exported="false"
android:theme="@style/Theme.Titanium.Dark.Fullscreen" />
<activity
android:name="ti.modules.titanium.media.TiCameraXActivity"
android:exported="false"
android:configChanges="${tiActivityConfigChanges}"
android:theme="@style/Theme.Titanium.Dark.Fullscreen"/>
android:exported="false"
android:theme="@style/Theme.Titanium.Dark.Fullscreen" />
<activity
android:name="ti.modules.titanium.media.TiVideoActivity"
android:exported="false"
android:configChanges="${tiActivityConfigChanges}"
android:theme="@style/Theme.AppDerived.Fullscreen"/>
android:exported="false"
android:theme="@style/Theme.AppDerived.Fullscreen" />
<activity
android:name="ti.modules.titanium.ui.android.TiPreferencesActivity"
android:exported="false"/>
android:exported="false" />

<provider
android:name="org.appcelerator.titanium.io.TiFileProvider"
android:authorities="${applicationId}.tifileprovider"
android:exported="false"
android:grantUriPermissions="true"/>
android:grantUriPermissions="true" />

</application>
</manifest>