Skip to content

Commit b580193

Browse files
committed
Generate Android.bp and dependencies with LineageOS's GenerateBp plugin
...extract all common dependencies to a new module, app-deps, and then run LineageOS's GenerateBp plugin based on that. The resulting Android.bp file is a java_defaults that can be used from the main Android.bp. Note that the prebuilt binaries are placed in app-deps/libs by GenerateBp. This directory is explicitly excluded by .gitignore. These binaries should be copied to another repository (android_prebuilts_openeuicc-deps) manually.
1 parent 70c29c1 commit b580193

File tree

15 files changed

+173
-21
lines changed

15 files changed

+173
-21
lines changed

.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,5 @@
1515
.cxx
1616
local.properties
1717
/libs/**/build
18-
/buildSrc/build
18+
/buildSrc/build
19+
/app-deps/libs

.idea/compiler.xml

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/gradle.xml

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app-common/build.gradle.kts

+2-12
Original file line numberDiff line numberDiff line change
@@ -29,18 +29,8 @@ android {
2929
}
3030

3131
dependencies {
32-
implementation(project(":libs:lpac-jni"))
33-
implementation("androidx.core:core-ktx:1.12.0")
34-
implementation("androidx.appcompat:appcompat:1.6.1")
35-
implementation("com.google.android.material:material:1.10.0")
36-
implementation("androidx.constraintlayout:constraintlayout:2.1.4")
37-
//noinspection KtxExtensionAvailable
38-
implementation("androidx.preference:preference:1.2.1")
39-
implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.6.2")
40-
implementation("androidx.swiperefreshlayout:swiperefreshlayout:1.1.0")
41-
implementation("androidx.cardview:cardview:1.0.0")
42-
implementation("androidx.datastore:datastore-preferences:1.0.0")
43-
implementation("com.journeyapps:zxing-android-embedded:4.3.0")
32+
api(project(":libs:lpac-jni"))
33+
api(project(":app-deps"))
4434
testImplementation("junit:junit:4.13.2")
4535
androidTestImplementation("androidx.test.ext:junit:1.1.5")
4636
androidTestImplementation("androidx.test.espresso:espresso-core:3.5.1")

app-deps/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/build

app-deps/Android.bp

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
java_defaults {
2+
name: "OpenEUICC-deps-defaults",
3+
static_libs: [
4+
// DO NOT EDIT THIS SECTION MANUALLY
5+
"androidx.core_core-ktx",
6+
"androidx.appcompat_appcompat",
7+
"com.google.android.material_material",
8+
"androidx-constraintlayout_constraintlayout",
9+
"androidx.preference_preference",
10+
"androidx.lifecycle_lifecycle-runtime-ktx",
11+
"androidx.swiperefreshlayout_swiperefreshlayout",
12+
"androidx.cardview_cardview",
13+
"OpenEUICC_androidx.datastore_datastore-preferences",
14+
"OpenEUICC_com.journeyapps_zxing-android-embedded",
15+
],
16+
}

app-deps/build.gradle.kts

+70
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
import org.lineageos.generatebp.GenerateBpPlugin
2+
import org.lineageos.generatebp.GenerateBpPluginExtension
3+
import org.lineageos.generatebp.models.Module
4+
5+
plugins {
6+
id("com.android.library")
7+
id("org.jetbrains.kotlin.android")
8+
}
9+
10+
apply {
11+
plugin<GenerateBpPlugin>()
12+
}
13+
14+
android {
15+
namespace = "im.angry.openeuicc_deps"
16+
compileSdk = 33
17+
18+
defaultConfig {
19+
minSdk = 28
20+
21+
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
22+
consumerProguardFiles("consumer-rules.pro")
23+
}
24+
25+
buildTypes {
26+
release {
27+
isMinifyEnabled = false
28+
proguardFiles(
29+
getDefaultProguardFile("proguard-android-optimize.txt"),
30+
"proguard-rules.pro"
31+
)
32+
}
33+
}
34+
compileOptions {
35+
sourceCompatibility = JavaVersion.VERSION_1_8
36+
targetCompatibility = JavaVersion.VERSION_1_8
37+
}
38+
kotlinOptions {
39+
jvmTarget = "1.8"
40+
}
41+
}
42+
43+
dependencies {
44+
api("androidx.core:core-ktx:1.12.0")
45+
api("androidx.appcompat:appcompat:1.6.1")
46+
api("com.google.android.material:material:1.10.0")
47+
api("androidx.constraintlayout:constraintlayout:2.1.4")
48+
//noinspection KtxExtensionAvailable
49+
api("androidx.preference:preference:1.2.1")
50+
api("androidx.lifecycle:lifecycle-runtime-ktx:2.6.2")
51+
api("androidx.swiperefreshlayout:swiperefreshlayout:1.1.0")
52+
api("androidx.cardview:cardview:1.0.0")
53+
api("androidx.datastore:datastore-preferences:1.0.0")
54+
api("com.journeyapps:zxing-android-embedded:4.3.0")
55+
testImplementation("junit:junit:4.13.2")
56+
androidTestImplementation("androidx.test.ext:junit:1.1.5")
57+
androidTestImplementation("androidx.test.espresso:espresso-core:3.5.1")
58+
}
59+
60+
configure<GenerateBpPluginExtension> {
61+
targetSdk.set(android.compileSdk!!)
62+
availableInAOSP.set { module: Module ->
63+
when {
64+
module.group == "androidx.datastore" -> false
65+
module.group.startsWith("androidx") -> true
66+
module.group == "com.google.android.material" -> true
67+
else -> false
68+
}
69+
}
70+
}

app-deps/consumer-rules.pro

Whitespace-only changes.

app-deps/proguard-rules.pro

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Add project specific ProGuard rules here.
2+
# You can control the set of applied configuration files using the
3+
# proguardFiles setting in build.gradle.
4+
#
5+
# For more details, see
6+
# http://developer.android.com/guide/developing/tools/proguard.html
7+
8+
# If your project uses WebView with JS, uncomment the following
9+
# and specify the fully qualified class name to the JavaScript interface
10+
# class:
11+
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12+
# public *;
13+
#}
14+
15+
# Uncomment this to preserve the line number information for
16+
# debugging stack traces.
17+
#-keepattributes SourceFile,LineNumberTable
18+
19+
# If you keep the line number information, uncomment this to
20+
# hide the original source file name.
21+
#-renamesourcefileattribute SourceFile
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package im.angry.openeuicc_deps
2+
3+
import androidx.test.platform.app.InstrumentationRegistry
4+
import androidx.test.ext.junit.runners.AndroidJUnit4
5+
6+
import org.junit.Test
7+
import org.junit.runner.RunWith
8+
9+
import org.junit.Assert.*
10+
11+
/**
12+
* Instrumented test, which will execute on an Android device.
13+
*
14+
* See [testing documentation](http://d.android.com/tools/testing).
15+
*/
16+
@RunWith(AndroidJUnit4::class)
17+
class ExampleInstrumentedTest {
18+
@Test
19+
fun useAppContext() {
20+
// Context of the app under test.
21+
val appContext = InstrumentationRegistry.getInstrumentation().targetContext
22+
assertEquals("im.angry.openeuicc_deps.test", appContext.packageName)
23+
}
24+
}

app-deps/src/main/AndroidManifest.xml

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
3+
4+
</manifest>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package im.angry.openeuicc_deps
2+
3+
import org.junit.Test
4+
5+
import org.junit.Assert.*
6+
7+
/**
8+
* Example local unit test, which will execute on the development machine (host).
9+
*
10+
* See [testing documentation](http://d.android.com/tools/testing).
11+
*/
12+
class ExampleUnitTest {
13+
@Test
14+
fun addition_isCorrect() {
15+
assertEquals(4, 2 + 2)
16+
}
17+
}

app-unpriv/build.gradle.kts

-3
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,4 @@ android {
4242

4343
dependencies {
4444
implementation(project(":app-common"))
45-
implementation("androidx.core:core-ktx:1.9.0")
46-
implementation("androidx.appcompat:appcompat:1.6.1")
47-
implementation("com.google.android.material:material:1.11.0")
4845
}

app/build.gradle.kts

+2-5
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,11 @@ android {
3838
}
3939

4040
dependencies {
41-
implementation("androidx.constraintlayout:constraintlayout:2.1.4")
42-
implementation("androidx.recyclerview:recyclerview:1.3.2")
4341
compileOnly(project(":libs:hidden-apis-stub"))
4442
implementation(project(":libs:hidden-apis-shim"))
4543
implementation(project(":libs:lpac-jni"))
4644
implementation(project(":app-common"))
47-
implementation("androidx.appcompat:appcompat:1.6.1")
4845
testImplementation("junit:junit:4.13.2")
49-
androidTestImplementation("androidx.test.ext:junit:1.1.3")
50-
androidTestImplementation("androidx.test.espresso:espresso-core:3.4.0")
46+
androidTestImplementation("androidx.test.ext:junit:1.1.5")
47+
androidTestImplementation("androidx.test.espresso:espresso-core:3.5.1")
5148
}

settings.gradle.kts

+12
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,22 @@ dependencyResolutionManagement {
1212
mavenCentral()
1313
}
1414
}
15+
16+
buildscript {
17+
repositories {
18+
maven("https://raw.githubusercontent.com/lineage-next/gradle-generatebp/4356136ecccc68cf6796a5dcd2388c66b80e0c11/.m2")
19+
}
20+
21+
dependencies {
22+
classpath("org.lineageos:gradle-generatebp:+")
23+
}
24+
}
25+
1526
rootProject.name = "OpenEUICC"
1627
include(":app")
1728
include(":libs:hidden-apis-stub")
1829
include(":libs:hidden-apis-shim")
1930
include(":libs:lpac-jni")
2031
include(":app-common")
2132
include(":app-unpriv")
33+
include(":app-deps")

0 commit comments

Comments
 (0)