Migrate all groovy to kts

This commit is contained in:
Nullptr 2022-02-10 21:15:41 +08:00
parent 1e3be68fac
commit 9ae8dbb7ed
20 changed files with 441 additions and 411 deletions

View File

@ -1,18 +0,0 @@
plugins {
id 'java-library'
}
java {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
}
dependencies {
implementation 'com.google.code.findbugs:jsr305:3.0.2'
implementation 'org.bouncycastle:bcpkix-jdk15on:1.69'
implementation 'org.bouncycastle:bcprov-jdk15on:1.69'
api 'com.google.guava:guava:30.1.1-jre'
api 'com.android.tools.build:apksig:7.0.1'
compileOnlyApi 'com.google.auto.value:auto-value-annotations:1.8.2'
annotationProcessor 'com.google.auto.value:auto-value:1.8.2'
}

21
apkzlib/build.gradle.kts Normal file
View File

@ -0,0 +1,21 @@
val androidSourceCompatibility: JavaVersion by rootProject.extra
val androidTargetCompatibility: JavaVersion by rootProject.extra
plugins {
id("java-library")
}
java {
sourceCompatibility = androidSourceCompatibility
targetCompatibility = androidTargetCompatibility
}
dependencies {
implementation("com.google.code.findbugs:jsr305:3.0.2")
implementation("org.bouncycastle:bcpkix-jdk15on:1.70")
implementation("org.bouncycastle:bcprov-jdk15on:1.70")
api("com.google.guava:guava:31.0.1-jre")
api("com.android.tools.build:apksig:7.1.1")
compileOnlyApi("com.google.auto.value:auto-value-annotations:1.9")
annotationProcessor("com.google.auto.value:auto-value:1.9")
}

View File

@ -1,96 +0,0 @@
apply plugin: 'com.android.application'
android {
flavorDimensions "api"
productFlavors {
Riru {
dimension 'api'
}
}
compileSdkVersion rootProject.ext.androidCompileSdkVersion
defaultConfig {
applicationId "org.lsposed.lspatch"
minSdkVersion rootProject.ext.androidMinSdkVersion
targetSdkVersion rootProject.ext.androidTargetSdkVersion
versionCode rootProject.ext.verCode
versionName rootProject.ext.verName
multiDexEnabled false
signingConfigs {
config {
if (project.hasProperty('androidStoreFile') && !androidStoreFile.isEmpty()) {
storeFile = file(androidStoreFile)
storePassword = androidStorePassword
keyAlias = androidKeyAlias
keyPassword = androidKeyPassword
}
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_11
targetCompatibility JavaVersion.VERSION_11
}
}
buildTypes {
debug {
debuggable true
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
signingConfig = signingConfigs.config.storeFile == null ? signingConfigs.debug : signingConfigs.config
}
release {
debuggable false
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
signingConfig = signingConfigs.config.storeFile == null ? signingConfigs.debug : signingConfigs.config
}
}
lintOptions {
abortOnError false
}
applicationVariants.all { variant ->
def buildType = variant.name.capitalize()
def variantName = variant.name
variant.outputs.all {
outputFileName = "${variant.getFlavorName()}-${variant.versionName}.apk"
}
task "copyDex$buildType"(type: Copy) {
dependsOn("assemble$buildType")
def dexFilePath = "$buildDir/intermediates/dex/${variantName}/mergeDex${buildType}/classes.dex"
from dexFilePath
rename "classes.dex", "lsp.dex"
into "$rootProject.projectDir/out/dexes"
}
task "copySo$buildType"(type: Copy) {
dependsOn("assemble$buildType")
from "$buildDir/intermediates/merged_native_libs/${variantName}/out/lib"
into "$rootProject.projectDir/out/so"
}
task "copy$buildType"() {
dependsOn("copySo$buildType")
dependsOn("copyDex$buildType")
doLast {
System.out.println("Dex and so files has been copy to ${rootProject.projectDir}${File.separator}out")
}
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation project(path: ':lspcore')
implementation project(path: ':hiddenapi-bridge')
compileOnly project(":hiddenapi-stubs")
implementation project(':share')
implementation project(':imanager')
implementation 'com.google.code.gson:gson:2.8.8'
}

99
app/build.gradle.kts Normal file
View File

@ -0,0 +1,99 @@
val androidCompileSdkVersion: Int by rootProject.extra
val androidMinSdkVersion: Int by rootProject.extra
val androidTargetSdkVersion: Int by rootProject.extra
val androidSourceCompatibility: JavaVersion by rootProject.extra
val androidTargetCompatibility: JavaVersion by rootProject.extra
plugins {
id("com.android.application")
}
android {
flavorDimensions += "api"
productFlavors {
create("Riru") {
dimension = "api"
}
}
compileSdk = androidCompileSdkVersion
defaultConfig {
minSdk = androidMinSdkVersion
targetSdk = androidTargetSdkVersion
multiDexEnabled = false
signingConfigs.create("config") {
val androidStoreFile = project.findProperty("androidStoreFile") as String?
if (!androidStoreFile.isNullOrEmpty()) {
storeFile = file(androidStoreFile)
storePassword = project.property("androidStorePassword") as String
keyAlias = project.property("androidKeyAlias") as String
keyPassword = project.property("androidKeyPassword") as String
}
}
compileOptions {
sourceCompatibility = androidSourceCompatibility
targetCompatibility = androidTargetCompatibility
}
}
buildTypes {
debug {
isDebuggable = true
isMinifyEnabled = false
proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro")
if (signingConfigs["config"].storeFile != null) signingConfigs["config"] else signingConfigs["debug"]
}
release {
isDebuggable = false
isMinifyEnabled = false
proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro")
if (signingConfigs["config"].storeFile != null) signingConfigs["config"] else signingConfigs["debug"]
}
}
lint {
isAbortOnError = false
}
}
androidComponents.onVariants { variant ->
val variantCapped = variant.name.capitalize()
val variantLowered = variant.name.toLowerCase()
task<Copy>("copyDex$variantCapped") {
dependsOn("assemble$variantCapped")
from("$buildDir/intermediates/dex/$variantLowered/mergeDex$variantCapped/classes.dex")
rename("classes.dex", "lsp.dex")
into("${rootProject.projectDir}/out/dexes")
}
task<Copy>("copySo$variantCapped") {
dependsOn("assemble$variantCapped")
from("$buildDir/intermediates/merged_native_libs/$variantLowered/out/lib")
into("${rootProject.projectDir}/out/so")
}
task("copy$variantCapped") {
dependsOn("copySo$variantCapped")
dependsOn("copyDex$variantCapped")
doLast {
println("Dex and so files has been copied to ${rootProject.projectDir}${File.separator}out")
}
}
}
dependencies {
implementation(project(":lspcore"))
implementation(project(":hiddenapi-bridge"))
compileOnly(project(":hiddenapi-stubs"))
implementation(project(":share"))
implementation(project(":imanager"))
implementation("com.google.code.gson:gson:2.8.9")
}

View File

@ -1,55 +0,0 @@
apply plugin: 'com.android.application'
android {
compileSdk 30
buildToolsVersion "30.0.3"
defaultConfig {
minSdk rootProject.ext.androidMinSdkVersion
targetSdk rootProject.ext.androidTargetSdkVersion
versionCode 1
versionName "1.0"
multiDexEnabled false
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_11
targetCompatibility JavaVersion.VERSION_11
}
applicationVariants.all { variant ->
def buildType = variant.name.capitalize()
def variantLowered = variant.name.toLowerCase()
variant.outputs.all {
outputFileName = "${variant.getFlavorName()}-${variant.versionName}.apk"
}
task "copyDex$buildType"(type: Copy) {
dependsOn("assemble$buildType")
def dexFilePath = "$buildDir/intermediates/dex/${variantLowered}/mergeDex${buildType}/classes.dex"
from dexFilePath
rename "classes.dex", "loader.dex"
into "$rootProject.projectDir/out/dexes"
}
task "copy$buildType"() {
dependsOn("copyDex$buildType")
doLast {
System.out.println("Dex and so files has been copy to ${rootProject.projectDir}${File.separator}out")
}
}
}
}
dependencies {
implementation 'de.upb.cs.swt:axml:2.1.1'
compileOnly project(":hiddenapi-stubs")
}

60
appstub/build.gradle.kts Normal file
View File

@ -0,0 +1,60 @@
val androidMinSdkVersion: Int by rootProject.extra
val androidTargetSdkVersion: Int by rootProject.extra
val androidCompileSdkVersion: Int by rootProject.extra
val androidBuildToolsVersion: String by rootProject.extra
val androidSourceCompatibility: JavaVersion by rootProject.extra
val androidTargetCompatibility: JavaVersion by rootProject.extra
plugins {
id("com.android.application")
}
android {
compileSdk = androidCompileSdkVersion
buildToolsVersion = androidBuildToolsVersion
defaultConfig {
minSdk = androidMinSdkVersion
targetSdk = androidTargetSdkVersion
multiDexEnabled = false
}
buildTypes {
release {
isMinifyEnabled = false
proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro")
}
}
compileOptions {
sourceCompatibility = androidSourceCompatibility
targetCompatibility = androidTargetCompatibility
}
}
androidComponents.onVariants { variant ->
val variantCapped = variant.name.capitalize()
val variantLowered = variant.name.toLowerCase()
task<Copy>("copyDex$variantCapped") {
dependsOn("assemble$variantCapped")
from("$buildDir/intermediates/dex/$variantLowered/mergeDex$variantCapped/classes.dex")
rename("classes.dex", "loader.dex")
into("${rootProject.projectDir}/out/dexes")
}
task("copy$variantCapped") {
dependsOn("copyDex$variantCapped")
doLast {
println("Loader dex has been copied to ${rootProject.projectDir}${File.separator}out")
}
}
}
dependencies {
implementation("de.upb.cs.swt:axml:2.1.2")
compileOnly(project(":hiddenapi-stubs"))
}

View File

@ -1,10 +0,0 @@
description = 'android manifest content parser'
apply plugin: 'java-library'
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
}
java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}

View File

@ -0,0 +1,13 @@
val androidSourceCompatibility: JavaVersion by rootProject.extra
val androidTargetCompatibility: JavaVersion by rootProject.extra
description = "android manifest content parser"
plugins {
id("java-library")
}
java {
sourceCompatibility = androidSourceCompatibility
targetCompatibility = androidTargetCompatibility
}

View File

@ -1,56 +0,0 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:7.0.3'
classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.31'
classpath("androidx.navigation:navigation-safe-args-gradle-plugin:2.4.0-beta02")
}
}
// sync from https://github.com/LSPosed/LSPosed/blob/master/build.gradle.kts
ext {
androidCompileSdkVersion = 31
androidCompileNdkVersion = "23.0.7599858"
androidBuildToolsVersion = "31.0.0"
androidMinSdkVersion = 28
androidTargetSdkVersion = 30
verCode = 1
verName = "lspatch"
apiCode = 93
defaultManagerPackageName = "org.lsposed.lspatch"
androidSourceCompatibility = JavaVersion.VERSION_11
androidTargetCompatibility = JavaVersion.VERSION_11
agpVersion = "7.0.3"
navVersion = "2.4.0-beta02"
}
allprojects {
repositories {
google()
mavenCentral()
}
}
//subprojects {
// afterEvaluate { module ->
// if (module.name == 'apksigner') {
// sourceSets.main.java.srcDirs += 'src/apksigner/java'
// }
// }
//}
task clean(type: Delete) {
delete rootProject.buildDir
}
["Debug", "Release"].each { variant ->
tasks.register("build$variant") {
description("Build LSPatch with $variant")
dependsOn tasks.getByPath(":patch:build$variant")
}
}

46
build.gradle.kts Normal file
View File

@ -0,0 +1,46 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
mavenCentral()
}
val agpVersion by extra("7.0.3")
val navVersion by extra("2.5.0-alpha01")
dependencies {
classpath("com.android.tools.build:gradle:$agpVersion")
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.10")
classpath("androidx.navigation:navigation-safe-args-gradle-plugin:$navVersion")
}
}
// sync from https://github.com/LSPosed/LSPosed/blob/master/build.gradle.kts
val defaultManagerPackageName by extra("org.lsposed.lspatch")
val apiCode by extra(93)
val verCode by extra(1)
val verName by extra("0.3")
val androidMinSdkVersion by extra(28)
val androidTargetSdkVersion by extra(32)
val androidCompileSdkVersion by extra(32)
val androidCompileNdkVersion by extra("23.1.7779620")
val androidBuildToolsVersion by extra("31.0.0")
val androidSourceCompatibility by extra(JavaVersion.VERSION_11)
val androidTargetCompatibility by extra(JavaVersion.VERSION_11)
allprojects {
repositories {
google()
mavenCentral()
}
}
tasks.register<Delete>("clean") {
delete(rootProject.buildDir)
}
listOf("Debug", "Release").forEach { variant ->
tasks.register("build$variant") {
description = "Build LSPatch with $variant"
dependsOn(tasks.getByPath(":patch:build$variant"))
}
}

View File

@ -1,32 +0,0 @@
plugins {
id 'com.android.library'
}
android {
flavorDimensions "api"
productFlavors {
Riru {
dimension 'api'
}
}
compileSdk 31
defaultConfig {
minSdk 27
targetSdk 31
}
buildTypes {
release {
minifyEnabled true
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
implementation project(path: ':lspcore')
}

40
imanager/build.gradle.kts Normal file
View File

@ -0,0 +1,40 @@
val androidMinSdkVersion: Int by rootProject.extra
val androidTargetSdkVersion: Int by rootProject.extra
val androidCompileSdkVersion: Int by rootProject.extra
val androidBuildToolsVersion: String by rootProject.extra
val androidSourceCompatibility: JavaVersion by rootProject.extra
val androidTargetCompatibility: JavaVersion by rootProject.extra
plugins {
id("com.android.library")
}
android {
flavorDimensions += "api"
productFlavors.create("Riru") {
dimension = "api"
}
compileSdk = androidCompileSdkVersion
defaultConfig {
minSdk = androidMinSdkVersion
targetSdk = androidTargetSdkVersion
}
buildTypes {
release {
isMinifyEnabled = true
}
}
compileOptions {
sourceCompatibility = androidSourceCompatibility
targetCompatibility = androidTargetCompatibility
}
}
dependencies {
implementation(project(":lspcore"))
}

View File

@ -1,47 +0,0 @@
plugins {
id 'com.android.application'
id 'org.jetbrains.kotlin.android'
}
android {
compileSdk 31
defaultConfig {
applicationId "org.lsposed.lspatch"
minSdk 27
targetSdk 31
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
buildFeatures {
viewBinding = true
}
}
dependencies {
compileOnly project(":patch")
compileOnly project(path: ':lspcore')
implementation project(":imanager")
implementation 'androidx.core:core-ktx:1.6.0'
implementation 'androidx.appcompat:appcompat:1.3.1'
implementation 'com.google.android.material:material:1.4.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.0'
}

58
manager/build.gradle.kts Normal file
View File

@ -0,0 +1,58 @@
val androidCompileSdkVersion: Int by rootProject.extra
val androidMinSdkVersion: Int by rootProject.extra
val androidTargetSdkVersion: Int by rootProject.extra
val defaultManagerPackageName: String by rootProject.extra
val verCode: Int by rootProject.extra
val verName: String by rootProject.extra
val androidSourceCompatibility: JavaVersion by rootProject.extra
val androidTargetCompatibility: JavaVersion by rootProject.extra
plugins {
id("com.android.application")
kotlin("android")
}
android {
compileSdk = androidCompileSdkVersion
defaultConfig {
applicationId = defaultManagerPackageName
minSdk = androidMinSdkVersion
targetSdk = androidTargetSdkVersion
versionCode = verCode
versionName = verName
}
buildTypes {
release {
isMinifyEnabled = true
proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro")
}
}
compileOptions {
sourceCompatibility = androidSourceCompatibility
targetCompatibility = androidTargetCompatibility
}
kotlinOptions {
jvmTarget = "11"
}
buildFeatures {
viewBinding = true
}
}
dependencies {
compileOnly(project(":patch"))
compileOnly(project(":lspcore"))
implementation(project(":imanager"))
implementation("androidx.core:core-ktx:1.7.0")
implementation("androidx.appcompat:appcompat:1.4.1")
implementation("com.google.android.material:material:1.5.0")
implementation("androidx.constraintlayout:constraintlayout:2.1.3")
}

View File

@ -1,69 +0,0 @@
plugins {
id 'java-library'
}
java {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
}
compileJava.options.encoding = "UTF-8"
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation project(':axmlprinter')
implementation project(':share')
implementation project(':apkzlib')
implementation 'commons-io:commons-io:2.11.0'
implementation 'com.beust:jcommander:1.81'
implementation 'com.google.code.gson:gson:2.8.8'
}
jar {
baseName = "lspatch"
destinationDirectory = new File("$rootProject.projectDir/out")
manifest {
attributes 'Main-Class': 'org.lsposed.patch.LSPatch'
}
dependsOn configurations.runtimeClasspath
from {
configurations.runtimeClasspath.collect {
it.isDirectory() ? it : zipTree(it)
}
}
from fileTree(dir: 'src/main', includes: ['assets/**'])
into("assets/dex") {
from fileTree(dir: "$rootProject.projectDir/out/dexes")
}
into("assets/so") {
from fileTree(dir: "$rootProject.projectDir/out/so")
}
exclude 'META-INF/*.SF', 'META-INF/*.DSA', 'META-INF/*.RSA', 'META-INF/*.MF', 'META-INF/*.txt', "META-INF/versions/**"
}
tasks.register("buildDebug") {
jar.dependsOn(':appstub:copyDebug')
jar.dependsOn(':app:copyRiruDebug')
dependsOn(build)
}
tasks.register("buildRelease") {
jar.dependsOn(':appstub:copyRelease')
jar.dependsOn(':app:copyRiruRelease')
dependsOn(build)
}
tasks.build.doLast {
println("Build to " + jar.archivePath)
println("Try \'java -jar " + jar.archiveName + "\' find more help")
}
sourceSets.main.resources {
srcDirs = [
"src/main/java",
];
include "**/*.*"
}

69
patch/build.gradle.kts Normal file
View File

@ -0,0 +1,69 @@
val androidSourceCompatibility: JavaVersion by rootProject.extra
val androidTargetCompatibility: JavaVersion by rootProject.extra
plugins {
id("java-library")
}
java {
sourceCompatibility = androidSourceCompatibility
targetCompatibility = androidTargetCompatibility
}
dependencies {
implementation(fileTree("dir" to "libs", "include" to listOf("*.jar")))
implementation(project(":axmlprinter"))
implementation(project(":share"))
implementation(project(":apkzlib"))
implementation("commons-io:commons-io:2.11.0")
implementation("com.beust:jcommander:1.82")
implementation("com.google.code.gson:gson:2.8.9")
}
tasks.jar {
archiveBaseName.set("lspatch")
destinationDirectory.set(file("${rootProject.projectDir}/out"))
manifest {
attributes("Main-Class" to "org.lsposed.patch.LSPatch")
}
dependsOn(configurations.runtimeClasspath)
from(configurations.runtimeClasspath.get().map { if (it.isDirectory) it else zipTree(it) })
from("src/main") {
include("assets/**")
}
into("assets/dex") {
from("${rootProject.projectDir}/out/dexes")
}
into("assets/so") {
from("${rootProject.projectDir}/out/so")
}
exclude("META-INF/*.SF", "META-INF/*.DSA", "META-INF/*.RSA", "META-INF/*.MF", "META-INF/*.txt", "META-INF/versions/**")
}
val jar = tasks.jar.get()
tasks.register("buildDebug") {
jar.dependsOn(":appstub:copyDebug")
jar.dependsOn(":app:copyRiruDebug")
dependsOn(tasks.build)
}
tasks.register("buildRelease") {
jar.dependsOn(":appstub:copyRelease")
jar.dependsOn(":app:copyRiruRelease")
dependsOn(tasks.build)
}
tasks["build"].doLast {
println("Build to " + jar.archiveFile)
println("Try \'java -jar " + jar.archiveFileName + "\' find more help")
}
sourceSets["main"].resources {
srcDirs("src/main/java")
include("**/*.*")
}

View File

@ -1,21 +0,0 @@
include ':app'
rootProject.name='LSPatch'
include ':lspcore'
project(':lspcore').projectDir = new File('core/core')
include ':lspapp'
project(':lspapp').projectDir = new File('core/app')
include ':hiddenapi-stubs'
project(':hiddenapi-stubs').projectDir = new File('core/hiddenapi-stubs')
include ':interface'
project(':interface').projectDir = new File('core/service/interface')
include ':hiddenapi-bridge'
project(':hiddenapi-bridge').projectDir = new File('core/hiddenapi-bridge')
include ':manager-service'
project(':manager-service').projectDir = new File('core/manager-service')
include ':patch'
include ':axmlprinter'
include ':share'
include ':appstub'
include ':apkzlib'
include ':imanager'
include ':manager'

24
settings.gradle.kts Normal file
View File

@ -0,0 +1,24 @@
rootProject.name = "LSPatch"
include(":hiddenapi-bridge")
include(":hiddenapi-stubs")
include(":interface")
include(":lspapp")
include(":lspcore")
include(":manager-service")
project(":hiddenapi-bridge").projectDir = file("core/hiddenapi-bridge")
project(":hiddenapi-stubs").projectDir = file("core/hiddenapi-stubs")
project(":interface").projectDir = file("core/service/interface")
project(":lspapp").projectDir = file("core/app")
project(":lspcore").projectDir = file("core/core")
project(":manager-service").projectDir = file("core/manager-service")
include(":apkzlib")
include(":app")
include(":appstub")
include(":axmlprinter")
include(":imanager")
include(":manager")
include(":patch")
include(":share")

View File

@ -1,7 +0,0 @@
plugins {
id 'java-library'
}
java {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
}

11
share/build.gradle.kts Normal file
View File

@ -0,0 +1,11 @@
val androidSourceCompatibility: JavaVersion by rootProject.extra
val androidTargetCompatibility: JavaVersion by rootProject.extra
plugins {
id("java-library")
}
java {
sourceCompatibility = androidSourceCompatibility
targetCompatibility = androidTargetCompatibility
}