diff --git a/android/app/build.gradle b/android/app/build.gradle index 99b5e424837..362deaaa71f 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -10,7 +10,7 @@ apply plugin: 'com.android.application' // Set up Android app project. android { compileSdkVersion 35 - ndkVersion project.ext.tiNdkVersion + ndkVersion = project.ext.tiNdkVersion defaultConfig { applicationId 'com.titanium.test' minSdkVersion 21 @@ -32,9 +32,9 @@ android { sourceCompatibility JavaVersion.VERSION_17 targetCompatibility JavaVersion.VERSION_17 } - namespace 'com.titanium.test' + namespace = 'com.titanium.test' lint { - checkReleaseBuilds false + checkReleaseBuilds = false } } diff --git a/android/build.gradle b/android/build.gradle index 099e2d2ac5d..2af7ad3200b 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -6,14 +6,14 @@ */ buildscript { - ext.kotlin_version = '1.9.23' + ext.kotlin_version = '2.0.20' repositories { google() mavenCentral() } dependencies { - classpath 'com.android.tools.build:gradle:8.8.2' + classpath 'com.android.tools.build:gradle:8.11.1' 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.17' @@ -30,9 +30,9 @@ allprojects { project.apply plugin: 'checkstyle' checkstyle { toolVersion = '10.11.0' - configFile file("${rootDir}/checkstyle.xml"); - ignoreFailures false - showViolations true + configFile = file("${rootDir}/checkstyle.xml"); + ignoreFailures = false + showViolations = true } // Include Titanium's gradle constants in all gradle sub-projects. diff --git a/android/gradle/wrapper/gradle-wrapper.jar b/android/gradle/wrapper/gradle-wrapper.jar index a4b76b9530d..1b33c55baab 100644 Binary files a/android/gradle/wrapper/gradle-wrapper.jar and b/android/gradle/wrapper/gradle-wrapper.jar differ diff --git a/android/gradle/wrapper/gradle-wrapper.properties b/android/gradle/wrapper/gradle-wrapper.properties index 79eb9d003fe..7705927e949 100644 --- a/android/gradle/wrapper/gradle-wrapper.properties +++ b/android/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.3-all.zip networkTimeout=10000 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME diff --git a/android/gradlew b/android/gradlew index f5feea6d6b1..23d15a93670 100755 --- a/android/gradlew +++ b/android/gradlew @@ -86,8 +86,7 @@ done # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) -APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s -' "$PWD" ) || exit +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -115,7 +114,7 @@ case "$( uname )" in #( NONSTOP* ) nonstop=true ;; esac -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar +CLASSPATH="\\\"\\\"" # Determine the Java command to use to start the JVM. @@ -206,7 +205,7 @@ fi DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Collect all arguments for the java command: -# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, # and any embedded shellness will be escaped. # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be # treated as '${Hostname}' itself on the command line. @@ -214,7 +213,7 @@ DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ "$@" # Stop when "xargs" is not available. diff --git a/android/gradlew.bat b/android/gradlew.bat index 9b42019c791..5eed7ee8452 100644 --- a/android/gradlew.bat +++ b/android/gradlew.bat @@ -70,11 +70,11 @@ goto fail :execute @rem Setup the command line -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar +set CLASSPATH= @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* :end @rem End local scope for the variables with windows NT shell diff --git a/android/templates/build/app.build.gradle b/android/templates/build/app.build.gradle index dcb91f38827..1e4306d9bd2 100644 --- a/android/templates/build/app.build.gradle +++ b/android/templates/build/app.build.gradle @@ -8,13 +8,13 @@ if (file("${projectDir}/google-services.json").exists()) { repositories { <% if (mavenRepositoryUrls) { for (let nextUrl of mavenRepositoryUrls) { %> - maven { url '<%- nextUrl %>' } + maven { url = '<%- nextUrl %>' } <% } } %> } android { compileSdkVersion <%- compileSdkVersion %> - namespace '<%- applicationId %>' + namespace = '<%- applicationId %>' defaultConfig { applicationId '<%- applicationId %>' minSdkVersion <%- minSdkVersion %> @@ -23,11 +23,11 @@ android { versionName '<%- versionName %>' manifestPlaceholders = project.ext.tiManifestPlaceholders manifestPlaceholders.put('localApplicationId', applicationId) // Legacy placeholder old AARs sometimes use. - multiDexEnabled true + multiDexEnabled = true aaptOptions { // Android build tools ignores asset directories with leading underscores, but iOS supports it. // So, we must redefine ignore string with underscore pattern removed to support this too. - ignoreAssetsPattern '!.svn:!.git:!.ds_store:!*.scc:.*:!CVS:!thumbs.db:!picasa.ini:!*~' + ignoreAssetsPattern = '!.svn:!.git:!.ds_store:!*.scc:.*:!CVS:!thumbs.db:!picasa.ini:!*~' } <% if (ndkAbiArray && (ndkAbiArray.length > 0)) { %> ndk { @@ -40,7 +40,7 @@ android { targetCompatibility JavaVersion.VERSION_17 } buildFeatures { - buildConfig true + buildConfig = true } signingConfigs { def tiKeystoreFilePath = <%- "'" + tiSdkAndroidDir.replace(/\\/g, '\\\\') + "/dev_keystore'" %> @@ -66,15 +66,15 @@ android { storePassword tiKeystorePassword keyAlias tiKeystoreAliasName keyPassword tiKeystoreAliasPassword - enableV3Signing true + enableV3Signing = true } } buildTypes { debug { - signingConfig signingConfigs.config + signingConfig = signingConfigs.config } release { - signingConfig signingConfigs.config + signingConfig = signingConfigs.config <% if (proguardFilePaths && (proguardFilePaths.length > 0)) { %> minifyEnabled true proguardFiles( @@ -84,7 +84,7 @@ android { } } lintOptions { - checkReleaseBuilds false + checkReleaseBuilds = false } packagingOptions { pickFirst '/lib/arm64-v8a/libc++_shared.so' diff --git a/android/templates/build/root.build.gradle b/android/templates/build/root.build.gradle index 9949e25a90d..80d23b4ca4e 100644 --- a/android/templates/build/root.build.gradle +++ b/android/templates/build/root.build.gradle @@ -1,12 +1,12 @@ buildscript { - ext.kotlin_version = '1.9.23' + ext.kotlin_version = '2.0.20' repositories { google() mavenCentral() } dependencies { - classpath 'com.android.tools.build:gradle:8.8.2' + classpath 'com.android.tools.build:gradle:8.11.1' classpath 'com.google.gms:google-services:4.4.1' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" <% for (let i = 0; i < classpaths.length; i++) {%> diff --git a/android/templates/module/generated/build.gradle b/android/templates/module/generated/build.gradle index 5cb22938bf6..9649e9a8a25 100644 --- a/android/templates/module/generated/build.gradle +++ b/android/templates/module/generated/build.gradle @@ -10,7 +10,7 @@ apply plugin: '<%= plugins[i] %>' repositories { maven { // Path to the Titanium SDK's "m2repository" containing the "titanium.aar" library. - url '<%- tiMavenUrl %>' + url = uri('<%- tiMavenUrl %>') } } @@ -19,8 +19,8 @@ def tiModuleBindingsJsonPath = "${buildDir}/ti-generated/json/<%- moduleName %>. android { compileSdkVersion <%- compileSdkVersion %> - namespace '<%- moduleId %>' - ndkVersion '28.1.13356709' + namespace = '<%- moduleId %>' + ndkVersion = '28.1.13356709' defaultConfig { minSdkVersion 21 targetSdkVersion <%- compileSdkVersion %> @@ -44,7 +44,7 @@ android { aaptOptions { // Android build tools ignores asset directories with leading underscores, but iOS supports it. // So, we must redefine ignore string with underscore pattern removed to support this too. - ignoreAssetsPattern '!.svn:!.git:!.ds_store:!*.scc:.*:!CVS:!thumbs.db:!picasa.ini:!*~' + ignoreAssetsPattern = '!.svn:!.git:!.ds_store:!*.scc:.*:!CVS:!thumbs.db:!picasa.ini:!*~' } javaCompileOptions { annotationProcessorOptions { @@ -74,7 +74,7 @@ android { } } buildFeatures { - buildConfig true + buildConfig = true } externalNativeBuild { ndkBuild { @@ -148,7 +148,7 @@ android { // Trigger a build failure if an AAR library was found under the "lib" directory. // While it will compile with the library, Google's build system won't merge the AAR into this module's AAR. preBuild.doFirst { - def libDirectory = new File("${projectDir}/../../lib") + def libDirectory = file("${projectDir}/../../lib") if (libDirectory.exists()) { libDirectory.eachFile { if (it.name.toLowerCase().endsWith('.aar')) { @@ -179,27 +179,26 @@ project.afterEvaluate { } } +tasks.register('generateCppFiles', Exec) { + environment 'TI_MODULE_BINDINGS_JSON_FILE', tiModuleBindingsJsonPath + environment 'TI_MODULE_GENERATED_JNI_DIR', "${projectDir}/build/ti-generated/jni" + environment 'TI_MODULE_GENERATED_JS_DIR', "${projectDir}/build/ti-generated/js" + environment 'TI_MODULE_ID', '<%- moduleId %>' + environment 'TI_MODULE_NAMESPACE', '<%- moduleId.toLowerCase() %>' + environment 'TI_MODULE_TEMPLATE_DIR', '<%- tiSdkModuleTemplateDir.replace(/\\/g, '\\\\') %>' + executable = 'node' + workingDir = projectDir + args = ['generate-cpp-files.js'] +} + // Hook into Java compile task. tasks.withType(JavaCompile).configureEach { - // Log all Java linting errors/warnings. - options.compilerArgs << "-Xlint:all" + options.compilerArgs << "-Xlint:all" - // Execute our "generate-cpp-files.js" script after Java compile to finish generating C++ files. - // Depends on the JSON file produced by our "kroll-apt" Java annotation processor. - // TODO: Our annotation processor should do ALL of the proxy code generation. Don't piece-meal it. - doLast { - exec { - environment 'TI_MODULE_BINDINGS_JSON_FILE', tiModuleBindingsJsonPath - environment 'TI_MODULE_GENERATED_JNI_DIR', "${projectDir}/build/ti-generated/jni" - environment 'TI_MODULE_GENERATED_JS_DIR', "${projectDir}/build/ti-generated/js" - environment 'TI_MODULE_ID', '<%- moduleId %>' - environment 'TI_MODULE_NAMESPACE', '<%- moduleId.toLowerCase() %>' - environment 'TI_MODULE_TEMPLATE_DIR', '<%- tiSdkModuleTemplateDir.replace(/\\/g, '\\\\') %>' - executable = 'node' - workingDir = projectDir - args = ['generate-cpp-files.js'] - } - } + // Execute our "generate-cpp-files.js" script after Java compile to finish generating C++ files. + // Depends on the JSON file produced by our "kroll-apt" Java annotation processor. + // TODO: Our annotation processor should do ALL of the proxy code generation. Don't piece-meal it. + finalizedBy(tasks.generateCppFiles) } // Titanium does not support incremental @Kroll annotation processing. Disable it in kotlin to avoid build warnings. @@ -208,18 +207,18 @@ project.ext['kapt.incremental.apt'] = false dependencies { // This reads the code's @Kroll annotations and generates code which interops between V8 and proxy classes. def krollAptJarPath = '<%- krollAptJarPath.replace(/\\/g, '\\\\') %>' - annotationProcessor files(krollAptJarPath) - compileOnly files(krollAptJarPath) - kapt files(krollAptJarPath) + annotationProcessor(files(krollAptJarPath)) + compileOnly(files(krollAptJarPath)) + kapt(files(krollAptJarPath)) // Reference this module's local JAR file dependencies. - implementation fileTree(dir: "${projectDir}/../../lib", include: ['*.jar']) + implementation(project.fileTree(dir: "${projectDir}/../../lib", include: ['*.jar'])) // Reference the main Titanium library. - implementation 'org.appcelerator:titanium:<%- tiSdkVersion %>' + implementation("org.appcelerator:titanium:<%- tiSdkVersion %>") // Reference the core kotlin library. - implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" + implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version") } // This block is used when we run "gradlew :module:publish" at the command line. @@ -228,9 +227,9 @@ publishing { publications { titaniumPublication(MavenPublication) { // Set up maven repo info. - groupId '<%- moduleMavenGroupId %>' - artifactId '<%- moduleMavenArtifactId %>' - version '<%- moduleVersion %>' + groupId = '<%- moduleMavenGroupId %>' + artifactId = '<%- moduleMavenArtifactId %>' + version = '<%- moduleVersion %>' artifact file("${buildDir}/outputs/aar/${project.name}-release.aar") // Generates the "*.pom" XML file containing all of Titanium's above dependencies. @@ -259,7 +258,7 @@ publishing { repositories { maven { // The maven directory tree produced above will be outputted to the following local directory. - url "${buildDir}/outputs/m2repository" + url = uri("${buildDir}/outputs/m2repository") } } } diff --git a/android/titanium/build.gradle b/android/titanium/build.gradle index 44789c1d4be..91f0082e9ca 100644 --- a/android/titanium/build.gradle +++ b/android/titanium/build.gradle @@ -43,10 +43,10 @@ for (nextString in tiBuildVersionString.split('\\.')) { } android { - ndkVersion project.ext.tiNdkVersion - namespace 'org.appcelerator.titanium' + ndkVersion = project.ext.tiNdkVersion + namespace = 'org.appcelerator.titanium' defaultConfig { - compileSdk 35 + compileSdk = 35 minSdkVersion 21 targetSdkVersion 35 versionName tiBuildVersionString @@ -77,11 +77,11 @@ android { } } buildFeatures { - buildConfig true + buildConfig = true } externalNativeBuild { cmake { - version '3.22.1' + version = '3.22.1' path "${projectDir}/../runtime/v8/src/native/CMakeLists.txt" } } @@ -125,8 +125,16 @@ android { } } +// Download/install the V8 library referenced in our "package.json", if not already done. +tasks.register('updateLibraryThenExit', Exec) { + executable = 'node' + workingDir = projectDir + args = ['libv8-services.js', 'update-library'] +} + // Downloads/extracts V8 library and creates a cmake file for it. To be executed before C/C++ "build" or "clean". tasks.register('updateV8Library') { + dependsOn tasks.named('updateLibraryThenExit') def packageJson = new JsonSlurper().parse(file("${projectDir}/../package.json")) def v8MakeFilePath = "${projectDir}/../runtime/v8/src/ndk-modules/libv8/V8Settings.cmake" inputs.property 'v8.version', packageJson.v8.version @@ -143,13 +151,6 @@ tasks.register('updateV8Library') { "set(LIBV8_VERSION \"${packageJson.v8.version}\")", "set(LIBV8_MODE \"${packageJson.v8.mode}\")" ].join('\n') + '\n' - - // Download/install the V8 library referenced in our "package.json", if not already done. - exec { - executable = 'node' - workingDir = projectDir - args = ['libv8-services.js', 'update-library'] - } } } @@ -180,32 +181,32 @@ tasks.register('checkstyleChanged', Checkstyle) { // Performs a transpile/polyfill/rollup of our "titanium_mobile/common/Resources" directory tree's JS files, // takes a V8 snapshot of rolled-up files, and then generates a C++ header file of that snapshot to be compiled-in. // Note: This supports incremental builds. Only executes when JS files change or snapshot output file is missing. + +tasks.register('createV8Snapshot', Exec) { + executable = 'node' + workingDir = projectDir + args = ['libv8-services.js', 'create-snapshot'] +} + tasks.register('snapshotTiCommonFiles') { + dependsOn tasks.named('createV8Snapshot') inputs.dir "${projectDir}/../../common/Resources" inputs.file "${projectDir}/../../build/lib/builder.js" inputs.file "${projectDir}/../../build/lib/android.js" outputs.file "${projectDir}/../runtime/v8/generated/V8Snapshots.h" - doFirst { - exec { - executable = 'node' - workingDir = projectDir - args = ['libv8-services.js', 'create-snapshot'] - } - } } // Runs our "prebuild.js" script before the C/C++ compile, but after Java compile. (Mid-build script?) // Generates C/C++ files providing our Android-only JS files via byte arrays. +tasks.register('runPrebuild', Exec) { + executable = 'node' + workingDir = projectDir + args = ['prebuild.js'] +} + tasks.withType(JavaCompile).configureEach { - dependsOn checkJavaStyle - dependsOn snapshotTiCommonFiles - doLast { - exec { - executable = 'node' - workingDir = projectDir - args = ['prebuild.js'] - } - } + dependsOn(checkJavaStyle, snapshotTiCommonFiles) + finalizedBy(tasks.runPrebuild) } // Set up project to compile Java side before compiling the C/C++ side. @@ -263,12 +264,19 @@ def getChangedFiles() { files } +def generatedDir = file("${projectDir}/../runtime/v8/generated") +def distFiles = fileTree( + dir: file("${projectDir}/../../dist/android"), + include: '**/*', + exclude: 'libv8/**/*' +) + clean.doLast { // Delete generated C/C++ files. - project.delete file("${projectDir}/../runtime/v8/generated") + delete generatedDir - // Delete the files copied to our distribution directory. This is what gets packaged/installed. - project.delete fileTree(dir: file("${projectDir}/../../dist/android"), include: '**/*', exclude: 'libv8/**/*') + // Delete the files copied to our distribution directory. + delete distFiles } dependencies { @@ -327,9 +335,9 @@ publishing { publications { titaniumPublication(MavenPublication) { // Set up maven repo info. - groupId 'org.appcelerator' - artifactId 'titanium' - version tiBuildVersionString + groupId = 'org.appcelerator' + artifactId = 'titanium' + version = tiBuildVersionString artifact file("${buildDir}/outputs/aar/titanium-release.aar") // Generates the "*.pom" XML file containing all of Titanium's above dependencies, @@ -355,7 +363,7 @@ publishing { repositories { maven { // The maven directory tree produced above will be outputted to the following local directory. - url "${buildDir}/outputs/m2repository" + url = "${buildDir}/outputs/m2repository" } } } @@ -363,12 +371,12 @@ publishing { publish.doLast { // After above publishing step, extract C/C++ "*.so" libraries from AAR to "./build/outputs/jniLibs" directory. def jniLibsOutputDir = "${buildDir}/outputs/jniLibs" - project.delete jniLibsOutputDir + delete jniLibsOutputDir copy { from zipTree("${buildDir}/outputs/aar/titanium-release.aar") into jniLibsOutputDir include 'jni/**/*' - includeEmptyDirs false + includeEmptyDirs = false eachFile { it.relativePath = new RelativePath(true, it.relativePath.segments.drop(1)) }