Skip to content

Commit cf361b2

Browse files
authored
Refactor LSPosed integration using composite builds (#71)
We change the integration with the core repository (JingMatrix/LSPosed) from manual subproject inclusion to a Gradle composite build. Key changes include: - Replaced direct `include` and `projectDir` mappings in `settings.gradle.kts` with `includeBuild("core")`. - Configured dependency substitutions to map 'vector' module coordinates to the appropriate projects within the included build. - Updated dependency declarations across all subprojects to use the substituted coordinates. - Removed `share/lspatch-rules.pro` and the corresponding `afterEvaluate` logic in the root build script, as local testing confirms these additional ProGuard rules are no longer required. - Remove build of libxposed in GitHub Actions workflow. - Switch from eager resolution of `runtimeClasspath` to the Provider API's lazy `map` implementation in the jar configuration. This change resolves a `beforeEvaluate` lifecycle error encountered during composite builds, as it prevents the early evaluation of included builds during the configuration phase.
1 parent 411e0cf commit cf361b2

11 files changed

Lines changed: 22 additions & 82 deletions

File tree

.github/workflows/main.yml

Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -34,19 +34,6 @@ jobs:
3434
echo ${{ secrets.KEY_STORE }} | base64 --decode > key.jks
3535
fi
3636
37-
- name: Checkout libxposed/api
38-
uses: actions/checkout@main
39-
with:
40-
repository: libxposed/api
41-
path: libxposed/api
42-
ref: 54582730315ba4a3d7cfaf9baf9d23c419e07006
43-
44-
- name: Checkout libxposed/service
45-
uses: actions/checkout@main
46-
with:
47-
repository: libxposed/service
48-
path: libxposed/service
49-
5037
- name: Setup Java
5138
uses: actions/setup-java@v4
5239
with:
@@ -68,20 +55,10 @@ jobs:
6855
shell: bash
6956
run: rm -rf $ANDROID_HOME/cmake
7057

71-
- name: Build dependencies with Gradle
72-
working-directory: libxposed
73-
run: |
74-
cd api
75-
echo 'org.gradle.jvmargs=-Xmx2048m' >> gradle.properties
76-
./gradlew :api:publishApiPublicationToMavenLocal
77-
cd ../service
78-
echo 'org.gradle.jvmargs=-Xmx2048m' >> gradle.properties
79-
./gradlew :interface:publishInterfacePublicationToMavenLocal
80-
8158
- name: Set short commit id
8259
run: echo "commit=$(echo ${{ github.sha }} | cut -c-7)" > $GITHUB_ENV
8360

84-
- name: Build core with Gradle
61+
- name: Build with Gradle
8562
run: |
8663
{
8764
echo 'org.gradle.parallel=true'

build.gradle.kts

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -240,17 +240,3 @@ subprojects {
240240
configureBaseExtension()
241241
}
242242
}
243-
244-
245-
project(":core") {
246-
afterEvaluate {
247-
if (property("android") is LibraryExtension) {
248-
val android = property("android") as LibraryExtension
249-
android.run {
250-
buildTypes {
251-
release { proguardFiles(rootProject.file("share/lspatch-rules.pro")) }
252-
}
253-
}
254-
}
255-
}
256-
}

core

Submodule core updated from 752d88c to cef2ffb

jar/build.gradle.kts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@ fun Jar.configure(variant: String) {
2323
attributes("Main-Class" to "org.lsposed.patch.LSPatch")
2424
}
2525
dependsOn(configurations.runtimeClasspath)
26-
from(configurations.runtimeClasspath.get().map { if (it.isDirectory) it else zipTree(it) })
26+
from(configurations.runtimeClasspath.map { configuration ->
27+
configuration.map { if (it.isDirectory) it else zipTree(it) }
28+
})
2729

2830
into("assets") {
2931
from("src/main/assets")

manager/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ afterEvaluate {
8383

8484
dependencies {
8585
implementation(projects.patch)
86-
implementation(projects.services.daemonService)
86+
implementation("vector:daemon-service")
8787
implementation(projects.share.android)
8888
implementation(projects.share.java)
8989
implementation(platform(lspatch.androidx.compose.bom))

meta-loader/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ androidComponents.onVariants { variant ->
4242
}
4343

4444
dependencies {
45-
compileOnly(projects.hiddenapi.stubs)
45+
compileOnly("vector:stubs")
4646
implementation(projects.share.java)
4747
implementation(libs.hiddenapibypass)
4848
}

patch-loader/build.gradle.kts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,10 @@ androidComponents.onVariants { variant ->
6262
}
6363

6464
dependencies {
65-
compileOnly(projects.hiddenapi.stubs)
66-
implementation(projects.core)
67-
implementation(projects.hiddenapi.bridge)
68-
implementation(projects.services.daemonService)
65+
compileOnly("vector:stubs")
66+
implementation("vector:core")
67+
implementation("vector:bridge")
68+
implementation("vector:daemon-service")
6969
implementation(projects.share.android)
7070
implementation(projects.share.java)
7171

patch/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ java {
1717
}
1818

1919
dependencies {
20-
implementation(projects.axml)
2120
implementation(projects.apkzlib)
21+
implementation("vector:axml")
2222
implementation(projects.share.java)
2323

2424
implementation(lspatch.commons.io)

settings.gradle.kts

Lines changed: 9 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,6 @@ dependencyResolutionManagement {
1313
repositories {
1414
google()
1515
mavenCentral()
16-
mavenLocal {
17-
content {
18-
includeGroup("io.github.libxposed")
19-
}
20-
}
2116
}
2217
versionCatalogs {
2318
create("libs") {
@@ -31,31 +26,22 @@ dependencyResolutionManagement {
3126

3227
rootProject.name = "LSPatch"
3328
include(
34-
":apache",
3529
":apkzlib",
36-
":axml",
37-
":core",
38-
":hiddenapi:bridge",
39-
":hiddenapi:stubs",
4030
":jar",
4131
":manager",
4232
":meta-loader",
4333
":patch",
4434
":patch-loader",
45-
":services:daemon-service",
46-
":services:manager-service",
47-
":services:xposed-service:interface",
4835
":share:android",
4936
":share:java",
5037
)
5138

52-
project(":apache").projectDir = file("core/apache")
53-
project(":axml").projectDir = file("core/axml")
54-
project(":core").projectDir = file("core/core")
55-
project(":hiddenapi:bridge").projectDir = file("core/hiddenapi/bridge")
56-
project(":hiddenapi:stubs").projectDir = file("core/hiddenapi/stubs")
57-
project(":services:daemon-service").projectDir = file("core/services/daemon-service")
58-
project(":services:manager-service").projectDir = file("core/services/manager-service")
59-
project(":services:xposed-service:interface").projectDir = file("core/services/xposed-service/interface")
60-
61-
buildCache { local { removeUnusedEntriesAfterDays = 1 } }
39+
includeBuild("core") {
40+
dependencySubstitution {
41+
substitute(module("vector:axml")).using(project(":external:axml"))
42+
substitute(module("vector:bridge")).using(project(":hiddenapi:bridge"))
43+
substitute(module("vector:core")).using(project(":core"))
44+
substitute(module("vector:daemon-service")).using(project(":services:daemon-service"))
45+
substitute(module("vector:stubs")).using(project(":hiddenapi:stubs"))
46+
}
47+
}

share/android/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,5 @@ android {
1212
}
1313

1414
dependencies {
15-
implementation(projects.services.daemonService)
15+
implementation("vector:daemon-service")
1616
}

0 commit comments

Comments
 (0)