diff --git a/.github/workflows/update-libs.yml b/.github/workflows/update-libs.yml index 2fec31ee..09fa0e2e 100644 --- a/.github/workflows/update-libs.yml +++ b/.github/workflows/update-libs.yml @@ -71,6 +71,13 @@ jobs: path: snippets/build/plugin/*.cgp if-no-files-found: error + - name: Upload ndk-installer CGP + uses: actions/upload-artifact@v4 + with: + name: ndk-installer + path: ndk-installer-plugin/build/plugin/*.cgp + if-no-files-found: error + - name: Commit updated jars run: | sha=$(git -C .cache/CodeOnTheGo rev-parse --short HEAD) diff --git a/ndk-installer-plugin/.gitignore b/ndk-installer-plugin/.gitignore new file mode 100644 index 00000000..6af499b7 --- /dev/null +++ b/ndk-installer-plugin/.gitignore @@ -0,0 +1,29 @@ +# Gradle +.gradle/ +build/ +gradle-app.setting +!gradle-wrapper.jar +.gradletasknamecache + +# IDE +.idea/ +*.iml +*.ipr +*.iws +.project +.classpath +.settings/ +.kotlin/ + +# Local configuration +local.properties + +# OS +.DS_Store +Thumbs.db + +# Logs +*.log + +# Test outputs +test-results/ diff --git a/ndk-installer-plugin/build.gradle.kts b/ndk-installer-plugin/build.gradle.kts new file mode 100644 index 00000000..4ef36565 --- /dev/null +++ b/ndk-installer-plugin/build.gradle.kts @@ -0,0 +1,130 @@ +import org.jetbrains.kotlin.gradle.dsl.JvmTarget + +import java.net.URL +import java.security.MessageDigest +import java.net.HttpURLConnection + + +plugins { + id("com.android.application") + id("org.jetbrains.kotlin.android") + id("com.itsaky.androidide.plugins.build") +} + +pluginBuilder { + pluginName = "ndk-installer" +} + +android { + namespace = "org.appdevforall.ndkinstaller" + compileSdk = 34 + + defaultConfig { + applicationId = "org.appdevforall.ndkinstaller" + minSdk = 26 + targetSdk = 34 + versionCode = 1 + versionName = "1.0.0" + } + + buildTypes { + release { + isMinifyEnabled = false + proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro") + } + } + + androidResources { + noCompress += listOf("xz") + } + + compileOptions { + sourceCompatibility = JavaVersion.VERSION_17 + targetCompatibility = JavaVersion.VERSION_17 + } + +} + +kotlin { + compilerOptions { + jvmTarget.set(JvmTarget.JVM_17) + } +} + +dependencies { + compileOnly(files("../libs/plugin-api.jar")) + + + implementation("org.jetbrains.kotlin:kotlin-stdlib:2.1.21") + implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.9.0") +} + +fun httpDownload(url: String): ByteArray { + val connection = URL(url).openConnection() as HttpURLConnection + connection.instanceFollowRedirects = true + connection.setRequestProperty("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64)") + connection.connectTimeout = 15000 + connection.readTimeout = 30000 + + val code = connection.responseCode + if (code != 200) { + throw GradleException("Failed to download $url (HTTP $code)") + } + + return connection.inputStream.use { it.readBytes() } +} + +fun md5Of(file: File): String { + val md = MessageDigest.getInstance("MD5") + file.inputStream().use { input -> + val buffer = ByteArray(8192) + var read: Int + while (input.read(buffer).also { read = it } != -1) { + md.update(buffer, 0, read) + } + } + return md.digest().joinToString("") { "%02x".format(it) } +} + +val downloadAssets by tasks.registering { + val assetsDir = project.file("src/main/assets") + val archiveFile = assetsDir.resolve("ndk-cmake.tar.xz") + val md5File = assetsDir.resolve("ndk-cmake.tar.xz.md5") + + outputs.files(archiveFile) + + doLast { + assetsDir.mkdirs() + + val archiveUrl = "https://www.appdevforall.org/dev-assets/release/v8/ndk-cmake.tar.xz" + val md5Url = "https://www.appdevforall.org/dev-assets/release/v8/ndk-cmake.tar.xz.md5" + + logger.info("Downloading archive....") + val archiveBytes = httpDownload(archiveUrl) + archiveFile.writeBytes(archiveBytes) + + logger.info("Downloading MD5…") + val md5Bytes = httpDownload(md5Url) + md5File.writeBytes(md5Bytes) + + val expected = md5File.readText().trim() + val actual = md5Of(archiveFile) + + logger.info("Expected MD5: $expected") + logger.info("Actual MD5: $actual") + + md5File.delete() + + if (!expected.equals(actual, ignoreCase = true)) { + throw GradleException("MD5 checksum mismatch for ndk-cmake.tar.xz") + } + + } +} + + + + + + + diff --git a/ndk-installer-plugin/gradle.properties b/ndk-installer-plugin/gradle.properties new file mode 100644 index 00000000..2e113229 --- /dev/null +++ b/ndk-installer-plugin/gradle.properties @@ -0,0 +1,3 @@ +org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8 +android.useAndroidX=true +android.nonTransitiveRClass=true diff --git a/ndk-installer-plugin/gradle/wrapper/gradle-wrapper.jar b/ndk-installer-plugin/gradle/wrapper/gradle-wrapper.jar new file mode 100755 index 00000000..8bdaf60c Binary files /dev/null and b/ndk-installer-plugin/gradle/wrapper/gradle-wrapper.jar differ diff --git a/ndk-installer-plugin/gradle/wrapper/gradle-wrapper.properties b/ndk-installer-plugin/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 00000000..d4081da4 --- /dev/null +++ b/ndk-installer-plugin/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,7 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.3-bin.zip +networkTimeout=10000 +validateDistributionUrl=true +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/ndk-installer-plugin/gradlew b/ndk-installer-plugin/gradlew new file mode 100755 index 00000000..ef07e016 --- /dev/null +++ b/ndk-installer-plugin/gradlew @@ -0,0 +1,251 @@ +#!/bin/sh + +# +# Copyright © 2015 the original authors. +# +# Licensed 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 +# +# https://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. +# +# SPDX-License-Identifier: Apache-2.0 +# + +############################################################################## +# +# Gradle start up script for POSIX generated by Gradle. +# +# Important for running: +# +# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is +# noncompliant, but you have some other compliant shell such as ksh or +# bash, then to run this script, type that shell name before the whole +# command line, like: +# +# ksh Gradle +# +# Busybox and similar reduced shells will NOT work, because this script +# requires all of these POSIX shell features: +# * functions; +# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», +# «${var#prefix}», «${var%suffix}», and «$( cmd )»; +# * compound commands having a testable exit status, especially «case»; +# * various built-in commands including «command», «set», and «ulimit». +# +# Important for patching: +# +# (2) This script targets any POSIX shell, so it avoids extensions provided +# by Bash, Ksh, etc; in particular arrays are avoided. +# +# The "traditional" practice of packing multiple parameters into a +# space-separated string is a well documented source of bugs and security +# problems, so this is (mostly) avoided, by progressively accumulating +# options in "$@", and eventually passing that to Java. +# +# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, +# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; +# see the in-line comments for details. +# +# There are tweaks for specific operating systems such as AIX, CygWin, +# Darwin, MinGW, and NonStop. +# +# (3) This script is generated from the Groovy template +# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# within the Gradle project. +# +# You can find Gradle at https://github.com/gradle/gradle/. +# +############################################################################## + +# Attempt to set APP_HOME + +# Resolve links: $0 may be a link +app_path=$0 + +# Need this for daisy-chained symlinks. +while + APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path + [ -h "$app_path" ] +do + ls=$( ls -ld "$app_path" ) + link=${ls#*' -> '} + case $link in #( + /*) app_path=$link ;; #( + *) app_path=$APP_HOME$link ;; + esac +done + +# This is normally unused +# 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\n' "$PWD" ) || exit + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD=maximum + +warn () { + echo "$*" +} >&2 + +die () { + echo + echo "$*" + echo + exit 1 +} >&2 + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "$( uname )" in #( + CYGWIN* ) cygwin=true ;; #( + Darwin* ) darwin=true ;; #( + MSYS* | MINGW* ) msys=true ;; #( + NONSTOP* ) nonstop=true ;; +esac + +CLASSPATH="\\\"\\\"" + + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD=$JAVA_HOME/jre/sh/java + else + JAVACMD=$JAVA_HOME/bin/java + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD=java + if ! command -v java >/dev/null 2>&1 + then + die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +fi + +# Increase the maximum file descriptors if we can. +if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then + case $MAX_FD in #( + max*) + # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC2039,SC3045 + MAX_FD=$( ulimit -H -n ) || + warn "Could not query maximum file descriptor limit" + esac + case $MAX_FD in #( + '' | soft) :;; #( + *) + # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC2039,SC3045 + ulimit -n "$MAX_FD" || + warn "Could not set maximum file descriptor limit to $MAX_FD" + esac +fi + +# Collect all arguments for the java command, stacking in reverse order: +# * args from the command line +# * the main class name +# * -classpath +# * -D...appname settings +# * --module-path (only if needed) +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. + +# For Cygwin or MSYS, switch paths to Windows format before running java +if "$cygwin" || "$msys" ; then + APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) + CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) + + JAVACMD=$( cygpath --unix "$JAVACMD" ) + + # Now convert the arguments - kludge to limit ourselves to /bin/sh + for arg do + if + case $arg in #( + -*) false ;; # don't mess with options #( + /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath + [ -e "$t" ] ;; #( + *) false ;; + esac + then + arg=$( cygpath --path --ignore --mixed "$arg" ) + fi + # Roll the args list around exactly as many times as the number of + # args, so each arg winds up back in the position where it started, but + # possibly modified. + # + # NB: a `for` loop captures its iteration list before it begins, so + # changing the positional parameters here affects neither the number of + # iterations, nor the values presented in `arg`. + shift # remove old arg + set -- "$@" "$arg" # push replacement arg + done +fi + + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + +# Collect all arguments for the java command: +# * 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. + +set -- \ + "-Dorg.gradle.appname=$APP_BASE_NAME" \ + -classpath "$CLASSPATH" \ + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ + "$@" + +# Stop when "xargs" is not available. +if ! command -v xargs >/dev/null 2>&1 +then + die "xargs is not available" +fi + +# Use "xargs" to parse quoted args. +# +# With -n1 it outputs one arg per line, with the quotes and backslashes removed. +# +# In Bash we could simply go: +# +# readarray ARGS < <( xargs -n1 <<<"$var" ) && +# set -- "${ARGS[@]}" "$@" +# +# but POSIX shell has neither arrays nor command substitution, so instead we +# post-process each arg (as a line of input to sed) to backslash-escape any +# character that might be a shell metacharacter, then use eval to reverse +# that process (while maintaining the separation between arguments), and wrap +# the whole thing up as a single "set" statement. +# +# This will of course break if any of these variables contains a newline or +# an unmatched quote. +# + +eval "set -- $( + printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | + xargs -n1 | + sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | + tr '\n' ' ' + )" '"$@"' + +exec "$JAVACMD" "$@" diff --git a/ndk-installer-plugin/gradlew.bat b/ndk-installer-plugin/gradlew.bat new file mode 100644 index 00000000..5eed7ee8 --- /dev/null +++ b/ndk-installer-plugin/gradlew.bat @@ -0,0 +1,94 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem + +@if "%DEBUG%"=="" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%"=="" set DIRNAME=. +@rem This is normally unused +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if %ERRORLEVEL% equ 0 goto execute + +echo. 1>&2 +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto execute + +echo. 1>&2 +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 + +goto fail + +:execute +@rem Setup the command line + +set CLASSPATH= + + +@rem Execute Gradle +"%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 +if %ERRORLEVEL% equ 0 goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +set EXIT_CODE=%ERRORLEVEL% +if %EXIT_CODE% equ 0 set EXIT_CODE=1 +if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% +exit /b %EXIT_CODE% + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/ndk-installer-plugin/proguard-rules.pro b/ndk-installer-plugin/proguard-rules.pro new file mode 100644 index 00000000..780d2227 --- /dev/null +++ b/ndk-installer-plugin/proguard-rules.pro @@ -0,0 +1,2 @@ +-keep class org.appdevforall.ndkinstaller.** { *; } +-keep class com.itsaky.androidide.plugins.** { *; } diff --git a/ndk-installer-plugin/settings.gradle.kts b/ndk-installer-plugin/settings.gradle.kts new file mode 100644 index 00000000..a168e4dc --- /dev/null +++ b/ndk-installer-plugin/settings.gradle.kts @@ -0,0 +1,31 @@ +rootProject.name = "ndk-installer-plugin" + +pluginManagement { + repositories { + google() + mavenCentral() + gradlePluginPortal() + } +} + +buildscript { + repositories { + google() + mavenCentral() + } + dependencies { + classpath(files("../libs/plugin-api.jar")) + classpath(files("../libs/gradle-plugin.jar")) + classpath("com.android.tools.build:gradle:8.11.0") + classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:2.3.0") + } +} + +dependencyResolutionManagement { + repositoriesMode.set(RepositoriesMode.PREFER_SETTINGS) + repositories { + mavenCentral() + google() + gradlePluginPortal() + } +} diff --git a/ndk-installer-plugin/src/main/AndroidManifest.xml b/ndk-installer-plugin/src/main/AndroidManifest.xml new file mode 100644 index 00000000..d19ae657 --- /dev/null +++ b/ndk-installer-plugin/src/main/AndroidManifest.xml @@ -0,0 +1,42 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ndk-installer-plugin/src/main/assets/ndk-cmake.tar.xz b/ndk-installer-plugin/src/main/assets/ndk-cmake.tar.xz new file mode 100644 index 00000000..de3d0277 --- /dev/null +++ b/ndk-installer-plugin/src/main/assets/ndk-cmake.tar.xz @@ -0,0 +1 @@ + diff --git a/ndk-installer-plugin/src/main/assets/templates/ndk/app/build.gradle.kts.peb b/ndk-installer-plugin/src/main/assets/templates/ndk/app/build.gradle.kts.peb new file mode 100644 index 00000000..1c4e1b3d --- /dev/null +++ b/ndk-installer-plugin/src/main/assets/templates/ndk/app/build.gradle.kts.peb @@ -0,0 +1,173 @@ +import java.util.Properties +import java.io.FileInputStream + +plugins { +id("com.android.application") version "${{AGP_VERSION}}" +${% if LANGUAGE == 'kotlin' %} + kotlin("android") version "${{KOTLIN_VERSION}}" +${% endif %} +} + +val keystorePropsFile = rootProject.file("release.properties") +val keystoreProps = Properties() + +if (keystorePropsFile.exists()) { + keystoreProps.load(FileInputStream(keystorePropsFile)) +} + +val hasValidSigningProps = keystorePropsFile.exists().also { exists -> + if (exists) { + FileInputStream(keystorePropsFile).use { keystoreProps.load(it) } + } +}.let { + listOf("storeFile", "storePassword", + "keyAlias", "keyPassword").all { key -> + keystoreProps[key] != null + } +} + + +android { + namespace = "${{PACKAGE_NAME}}" + compileSdk = ${{COMPILE_SDK}} + + + // disable linter + lint { + checkReleaseBuilds = false + } + + signingConfigs { + if (hasValidSigningProps) { + create("release") { + storeFile = rootProject.file(keystoreProps["storeFile"] as String) + storePassword = keystoreProps["storePassword"] as String + keyAlias = keystoreProps["keyAlias"] as String + keyPassword = keystoreProps["keyPassword"] as String + } + } + } + + defaultConfig { + applicationId = "${{PACKAGE_NAME}}" + minSdk = ${{MIN_SDK}} + targetSdk = ${{TARGET_SDK}} + versionCode = 1 + versionName = "1.0" + + vectorDrawables { + useSupportLibrary = true + } + + ndk { + abiFilters += "arm64-v8a" + } + + externalNativeBuild { + cmake { + cppFlags += "-std=c++17" + } + } + } + + ndkVersion = "29.0.14206865" + + externalNativeBuild { + cmake { + path = file("src/main/cpp/CMakeLists.txt") + } + } + + compileOptions { + sourceCompatibility = ${{JAVA_SOURCE_COMPAT}} + targetCompatibility = ${{JAVA_TARGET_COMPAT}} + } + + buildTypes { + release { + if (hasValidSigningProps) { + signingConfig = signingConfigs.getByName("release") + } + isMinifyEnabled = true + proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro") + } + } + + buildFeatures { + viewBinding = true + + } + composeOptions { + kotlinCompilerExtensionVersion = "1.5.10" + } + packaging { + resources { + resources.excludes.add("/META-INF/{AL2.0,LGPL2.1}") + resources.excludes.add("META-INF/kotlinx_coroutines_core.version") + + // The part below is only needed for compose builds. + // This packaging block is required to solve interdependency conflicts. + // They arise only when using local maven repo, so I suppose online repos have some way of solving such issues. + + // Caused by: com.android.builder.merge.DuplicateRelativeFileException: 4 files found with path 'commonMain/default/linkdata/module' from inputs: + // - AndroidIDE\libs_source\gradle\localMvnRepository\androidx\collection\collection\1.4.2\collection-1.4.2.jar + // - AndroidIDE\libs_source\gradle\localMvnRepository\androidx\lifecycle\lifecycle-common\2.8.7\lifecycle-common-2.8.7.jar + // - AndroidIDE\libs_source\gradle\localMvnRepository\androidx\annotation\annotation\1.8.1\annotation-1.8.1.jar + // - AndroidIDE\libs_source\gradle\localMvnRepository\org\jetbrains\kotlinx\kotlinx-coroutines-core\1.7.3\kotlinx-coroutines-core-1.7.3.jar + // And some others. + resources.pickFirsts.add("nonJvmMain/default/linkdata/package_androidx/0_androidx.knm") + resources.pickFirsts.add("nonJvmMain/default/linkdata/root_package/0_.knm") + resources.pickFirsts.add("nonJvmMain/default/linkdata/module") + + resources.pickFirsts.add("nativeMain/default/linkdata/root_package/0_.knm") + resources.pickFirsts.add("nativeMain/default/linkdata/module") + + resources.pickFirsts.add("commonMain/default/linkdata/root_package/0_.knm") + resources.pickFirsts.add("commonMain/default/linkdata/module") + resources.pickFirsts.add("commonMain/default/linkdata/package_androidx/0_androidx.knm") + + resources.pickFirsts.add("META-INF/kotlin-project-structure-metadata.json") + + resources.merges.add("commonMain/default/manifest") + resources.merges.add("nonJvmMain/default/manifest") + resources.merges.add("nativeMain/default/manifest") + } + } + + configurations.all { + resolutionStrategy { + // Force the use of Kotlin stdlib 1.9.22 for all modules + force("org.jetbrains.kotlin:kotlin-stdlib:1.9.22") + force("org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.9.22") + force("org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.9.22") + + // Force specific AndroidX versions to avoid conflicts + force("androidx.collection:collection:1.4.2") + force("androidx.annotation:annotation:1.8.1") + force("androidx.core:core-ktx:1.8.0") + force("androidx.lifecycle:lifecycle-runtime-ktx:2.3.1") + force("androidx.collection:collection-ktx:1.4.2") + } + } +} + +tasks.withType { + options.compilerArgs.add("-Xlint:deprecation") +} + + +${% if LANGUAGE == 'kotlin' %} + tasks.withType().configureEach { + kotlinOptions.jvmTarget = "${{JAVA_TARGET}}" + } +${% endif %} + +dependencies { + + + implementation("androidx.interpolator:interpolator:1.0.0") + implementation("androidx.startup:startup-runtime:1.1.1") + implementation("com.google.android.material:material:1.9.0") + implementation("androidx.constraintlayout:constraintlayout:2.1.4") + implementation("androidx.appcompat:appcompat:1.6.1") +} \ No newline at end of file diff --git a/ndk-installer-plugin/src/main/assets/templates/ndk/app/gitignore b/ndk-installer-plugin/src/main/assets/templates/ndk/app/gitignore new file mode 100644 index 00000000..42afabfd --- /dev/null +++ b/ndk-installer-plugin/src/main/assets/templates/ndk/app/gitignore @@ -0,0 +1 @@ +/build \ No newline at end of file diff --git a/ndk-installer-plugin/src/main/assets/templates/ndk/app/proguard-rules.pro b/ndk-installer-plugin/src/main/assets/templates/ndk/app/proguard-rules.pro new file mode 100644 index 00000000..481bb434 --- /dev/null +++ b/ndk-installer-plugin/src/main/assets/templates/ndk/app/proguard-rules.pro @@ -0,0 +1,21 @@ +# Add project specific ProGuard rules here. +# You can control the set of applied configuration files using the +# proguardFiles setting in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} + +# Uncomment this to preserve the line number information for +# debugging stack traces. +#-keepattributes SourceFile,LineNumberTable + +# If you keep the line number information, uncomment this to +# hide the original source file name. +#-renamesourcefileattribute SourceFile \ No newline at end of file diff --git a/ndk-installer-plugin/src/main/assets/templates/ndk/app/src/main/AndroidManifest.xml b/ndk-installer-plugin/src/main/assets/templates/ndk/app/src/main/AndroidManifest.xml new file mode 100644 index 00000000..71959e89 --- /dev/null +++ b/ndk-installer-plugin/src/main/assets/templates/ndk/app/src/main/AndroidManifest.xml @@ -0,0 +1,24 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/ndk-installer-plugin/src/main/assets/templates/ndk/app/src/main/cpp/CMakeLists.txt b/ndk-installer-plugin/src/main/assets/templates/ndk/app/src/main/cpp/CMakeLists.txt new file mode 100644 index 00000000..ac9cf262 --- /dev/null +++ b/ndk-installer-plugin/src/main/assets/templates/ndk/app/src/main/cpp/CMakeLists.txt @@ -0,0 +1,9 @@ +cmake_minimum_required(VERSION 3.10.2) + +project("ndkactivitykotlin") + +add_library(native-lib SHARED native-lib.cpp) + +find_library(log-lib log) + +target_link_libraries(native-lib ${log-lib}) \ No newline at end of file diff --git a/ndk-installer-plugin/src/main/assets/templates/ndk/app/src/main/cpp/native-lib.cpp.peb b/ndk-installer-plugin/src/main/assets/templates/ndk/app/src/main/cpp/native-lib.cpp.peb new file mode 100644 index 00000000..2bc61346 --- /dev/null +++ b/ndk-installer-plugin/src/main/assets/templates/ndk/app/src/main/cpp/native-lib.cpp.peb @@ -0,0 +1,9 @@ +#include +#include + +extern "C" JNIEXPORT jstring JNICALL +Java_${{ PACKAGE_NAME | replace({".": "_"}) }}_MainActivity_stringFromJNI( + JNIEnv* env, + jobject /* this */) { + return env->NewStringUTF("Hello from C++"); +} diff --git a/ndk-installer-plugin/src/main/assets/templates/ndk/app/src/main/java/PACKAGE_NAME/MainActivity.java.peb b/ndk-installer-plugin/src/main/assets/templates/ndk/app/src/main/java/PACKAGE_NAME/MainActivity.java.peb new file mode 100644 index 00000000..c12c581d --- /dev/null +++ b/ndk-installer-plugin/src/main/assets/templates/ndk/app/src/main/java/PACKAGE_NAME/MainActivity.java.peb @@ -0,0 +1,38 @@ + +package ${{PACKAGE_NAME}}; + +import androidx.appcompat.app.AppCompatActivity; +import android.os.Bundle; +import ${{PACKAGE_NAME}}.databinding.ActivityMainBinding; + +public class MainActivity extends AppCompatActivity { + private ActivityMainBinding binding; + + // Load the native library + static { + System.loadLibrary("native-lib"); + } + + // Declare the native method + public native String stringFromJNI(); + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + + // Inflate and get instance of binding + binding = ActivityMainBinding.inflate(getLayoutInflater()); + + // set content view to binding's root + setContentView(binding.getRoot()); + + // Call JNI method and display result + binding.textView.setText(stringFromJNI()); + } + + @Override + protected void onDestroy() { + super.onDestroy(); + this.binding = null; + } +} diff --git a/ndk-installer-plugin/src/main/assets/templates/ndk/app/src/main/java/PACKAGE_NAME/MainActivity.kt.peb b/ndk-installer-plugin/src/main/assets/templates/ndk/app/src/main/java/PACKAGE_NAME/MainActivity.kt.peb new file mode 100644 index 00000000..c359f767 --- /dev/null +++ b/ndk-installer-plugin/src/main/assets/templates/ndk/app/src/main/java/PACKAGE_NAME/MainActivity.kt.peb @@ -0,0 +1,42 @@ + +package ${{PACKAGE_NAME}} + +import androidx.appcompat.app.AppCompatActivity +import android.os.Bundle +import ${{PACKAGE_NAME}}.databinding.ActivityMainBinding + +class MainActivity : AppCompatActivity() { + + private var _binding: ActivityMainBinding? = null + + private val binding: ActivityMainBinding + get() = checkNotNull(_binding) { "Activity has been destroyed" } + + // Declare the native method + private external fun stringFromJNI(): String + + // Load the native library + companion object { + init { + System.loadLibrary("native-lib"); + } + } + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + + // Inflate and get instance of binding + _binding = ActivityMainBinding.inflate(layoutInflater) + + // set content view to binding's root + setContentView(binding.root) + + // Call JNI method and display result + binding.textView.text = stringFromJNI() + } + + override fun onDestroy() { + super.onDestroy() + _binding = null + } +} diff --git a/ndk-installer-plugin/src/main/assets/templates/ndk/app/src/main/res/drawable-v24/ic_launcher_foreground.xml b/ndk-installer-plugin/src/main/assets/templates/ndk/app/src/main/res/drawable-v24/ic_launcher_foreground.xml new file mode 100644 index 00000000..2b068d11 --- /dev/null +++ b/ndk-installer-plugin/src/main/assets/templates/ndk/app/src/main/res/drawable-v24/ic_launcher_foreground.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/ndk-installer-plugin/src/main/assets/templates/ndk/app/src/main/res/drawable/ic_launcher_background.xml b/ndk-installer-plugin/src/main/assets/templates/ndk/app/src/main/res/drawable/ic_launcher_background.xml new file mode 100644 index 00000000..07d5da9c --- /dev/null +++ b/ndk-installer-plugin/src/main/assets/templates/ndk/app/src/main/res/drawable/ic_launcher_background.xml @@ -0,0 +1,170 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ndk-installer-plugin/src/main/assets/templates/ndk/app/src/main/res/drawable/ic_launcher_round.webp b/ndk-installer-plugin/src/main/assets/templates/ndk/app/src/main/res/drawable/ic_launcher_round.webp new file mode 100644 index 00000000..ead67900 Binary files /dev/null and b/ndk-installer-plugin/src/main/assets/templates/ndk/app/src/main/res/drawable/ic_launcher_round.webp differ diff --git a/ndk-installer-plugin/src/main/assets/templates/ndk/app/src/main/res/layout/activity_main.xml b/ndk-installer-plugin/src/main/assets/templates/ndk/app/src/main/res/layout/activity_main.xml new file mode 100644 index 00000000..3592bcad --- /dev/null +++ b/ndk-installer-plugin/src/main/assets/templates/ndk/app/src/main/res/layout/activity_main.xml @@ -0,0 +1,17 @@ + + + + + \ No newline at end of file diff --git a/ndk-installer-plugin/src/main/assets/templates/ndk/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml b/ndk-installer-plugin/src/main/assets/templates/ndk/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml new file mode 100644 index 00000000..eca70cfe --- /dev/null +++ b/ndk-installer-plugin/src/main/assets/templates/ndk/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/ndk-installer-plugin/src/main/assets/templates/ndk/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml b/ndk-installer-plugin/src/main/assets/templates/ndk/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml new file mode 100644 index 00000000..eca70cfe --- /dev/null +++ b/ndk-installer-plugin/src/main/assets/templates/ndk/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/ndk-installer-plugin/src/main/assets/templates/ndk/app/src/main/res/mipmap-hdpi/ic_launcher.webp b/ndk-installer-plugin/src/main/assets/templates/ndk/app/src/main/res/mipmap-hdpi/ic_launcher.webp new file mode 100644 index 00000000..d7bb5af9 Binary files /dev/null and b/ndk-installer-plugin/src/main/assets/templates/ndk/app/src/main/res/mipmap-hdpi/ic_launcher.webp differ diff --git a/ndk-installer-plugin/src/main/assets/templates/ndk/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp b/ndk-installer-plugin/src/main/assets/templates/ndk/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp new file mode 100644 index 00000000..bc9b71e2 Binary files /dev/null and b/ndk-installer-plugin/src/main/assets/templates/ndk/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp differ diff --git a/ndk-installer-plugin/src/main/assets/templates/ndk/app/src/main/res/mipmap-mdpi/ic_launcher.webp b/ndk-installer-plugin/src/main/assets/templates/ndk/app/src/main/res/mipmap-mdpi/ic_launcher.webp new file mode 100644 index 00000000..b61d7366 Binary files /dev/null and b/ndk-installer-plugin/src/main/assets/templates/ndk/app/src/main/res/mipmap-mdpi/ic_launcher.webp differ diff --git a/ndk-installer-plugin/src/main/assets/templates/ndk/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp b/ndk-installer-plugin/src/main/assets/templates/ndk/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp new file mode 100644 index 00000000..b003c036 Binary files /dev/null and b/ndk-installer-plugin/src/main/assets/templates/ndk/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp differ diff --git a/ndk-installer-plugin/src/main/assets/templates/ndk/app/src/main/res/mipmap-xhdpi/ic_launcher.webp b/ndk-installer-plugin/src/main/assets/templates/ndk/app/src/main/res/mipmap-xhdpi/ic_launcher.webp new file mode 100644 index 00000000..33b4e993 Binary files /dev/null and b/ndk-installer-plugin/src/main/assets/templates/ndk/app/src/main/res/mipmap-xhdpi/ic_launcher.webp differ diff --git a/ndk-installer-plugin/src/main/assets/templates/ndk/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp b/ndk-installer-plugin/src/main/assets/templates/ndk/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp new file mode 100644 index 00000000..a62f3b0c Binary files /dev/null and b/ndk-installer-plugin/src/main/assets/templates/ndk/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp differ diff --git a/ndk-installer-plugin/src/main/assets/templates/ndk/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp b/ndk-installer-plugin/src/main/assets/templates/ndk/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp new file mode 100644 index 00000000..21a284e0 Binary files /dev/null and b/ndk-installer-plugin/src/main/assets/templates/ndk/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp differ diff --git a/ndk-installer-plugin/src/main/assets/templates/ndk/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp b/ndk-installer-plugin/src/main/assets/templates/ndk/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp new file mode 100644 index 00000000..ead67900 Binary files /dev/null and b/ndk-installer-plugin/src/main/assets/templates/ndk/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp differ diff --git a/ndk-installer-plugin/src/main/assets/templates/ndk/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp b/ndk-installer-plugin/src/main/assets/templates/ndk/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp new file mode 100644 index 00000000..aa7d6427 Binary files /dev/null and b/ndk-installer-plugin/src/main/assets/templates/ndk/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp differ diff --git a/ndk-installer-plugin/src/main/assets/templates/ndk/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp b/ndk-installer-plugin/src/main/assets/templates/ndk/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp new file mode 100644 index 00000000..9126ae37 Binary files /dev/null and b/ndk-installer-plugin/src/main/assets/templates/ndk/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp differ diff --git a/ndk-installer-plugin/src/main/assets/templates/ndk/app/src/main/res/values-night/colors.xml b/ndk-installer-plugin/src/main/assets/templates/ndk/app/src/main/res/values-night/colors.xml new file mode 100644 index 00000000..a6b3daec --- /dev/null +++ b/ndk-installer-plugin/src/main/assets/templates/ndk/app/src/main/res/values-night/colors.xml @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/ndk-installer-plugin/src/main/assets/templates/ndk/app/src/main/res/values-night/themes.xml b/ndk-installer-plugin/src/main/assets/templates/ndk/app/src/main/res/values-night/themes.xml new file mode 100644 index 00000000..e8f677b8 --- /dev/null +++ b/ndk-installer-plugin/src/main/assets/templates/ndk/app/src/main/res/values-night/themes.xml @@ -0,0 +1,9 @@ + + + + + + +