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.
This commit is contained in:
Peter Cai 2024-01-20 16:36:23 -05:00
parent 70c29c195b
commit b580193624
15 changed files with 173 additions and 21 deletions

3
.gitignore vendored
View file

@ -15,4 +15,5 @@
.cxx
local.properties
/libs/**/build
/buildSrc/build
/buildSrc/build
/app-deps/libs

View file

@ -4,6 +4,7 @@
<bytecodeTargetLevel target="1.7">
<module name="OpenEUICC.app" target="17" />
<module name="OpenEUICC.app-common" target="17" />
<module name="OpenEUICC.app-deps" target="17" />
<module name="OpenEUICC.app-unpriv" target="17" />
<module name="OpenEUICC.buildSrc" target="17" />
<module name="OpenEUICC.buildSrc.main" target="17" />

View file

@ -14,6 +14,7 @@
<option value="$PROJECT_DIR$" />
<option value="$PROJECT_DIR$/app" />
<option value="$PROJECT_DIR$/app-common" />
<option value="$PROJECT_DIR$/app-deps" />
<option value="$PROJECT_DIR$/app-unpriv" />
<option value="$PROJECT_DIR$/buildSrc" />
<option value="$PROJECT_DIR$/libs" />

View file

@ -29,18 +29,8 @@ android {
}
dependencies {
implementation(project(":libs:lpac-jni"))
implementation("androidx.core:core-ktx:1.12.0")
implementation("androidx.appcompat:appcompat:1.6.1")
implementation("com.google.android.material:material:1.10.0")
implementation("androidx.constraintlayout:constraintlayout:2.1.4")
//noinspection KtxExtensionAvailable
implementation("androidx.preference:preference:1.2.1")
implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.6.2")
implementation("androidx.swiperefreshlayout:swiperefreshlayout:1.1.0")
implementation("androidx.cardview:cardview:1.0.0")
implementation("androidx.datastore:datastore-preferences:1.0.0")
implementation("com.journeyapps:zxing-android-embedded:4.3.0")
api(project(":libs:lpac-jni"))
api(project(":app-deps"))
testImplementation("junit:junit:4.13.2")
androidTestImplementation("androidx.test.ext:junit:1.1.5")
androidTestImplementation("androidx.test.espresso:espresso-core:3.5.1")

1
app-deps/.gitignore vendored Normal file
View file

@ -0,0 +1 @@
/build

16
app-deps/Android.bp Normal file
View file

@ -0,0 +1,16 @@
java_defaults {
name: "OpenEUICC-deps-defaults",
static_libs: [
// DO NOT EDIT THIS SECTION MANUALLY
"androidx.core_core-ktx",
"androidx.appcompat_appcompat",
"com.google.android.material_material",
"androidx-constraintlayout_constraintlayout",
"androidx.preference_preference",
"androidx.lifecycle_lifecycle-runtime-ktx",
"androidx.swiperefreshlayout_swiperefreshlayout",
"androidx.cardview_cardview",
"OpenEUICC_androidx.datastore_datastore-preferences",
"OpenEUICC_com.journeyapps_zxing-android-embedded",
],
}

70
app-deps/build.gradle.kts Normal file
View file

@ -0,0 +1,70 @@
import org.lineageos.generatebp.GenerateBpPlugin
import org.lineageos.generatebp.GenerateBpPluginExtension
import org.lineageos.generatebp.models.Module
plugins {
id("com.android.library")
id("org.jetbrains.kotlin.android")
}
apply {
plugin<GenerateBpPlugin>()
}
android {
namespace = "im.angry.openeuicc_deps"
compileSdk = 33
defaultConfig {
minSdk = 28
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles("consumer-rules.pro")
}
buildTypes {
release {
isMinifyEnabled = false
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro"
)
}
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = "1.8"
}
}
dependencies {
api("androidx.core:core-ktx:1.12.0")
api("androidx.appcompat:appcompat:1.6.1")
api("com.google.android.material:material:1.10.0")
api("androidx.constraintlayout:constraintlayout:2.1.4")
//noinspection KtxExtensionAvailable
api("androidx.preference:preference:1.2.1")
api("androidx.lifecycle:lifecycle-runtime-ktx:2.6.2")
api("androidx.swiperefreshlayout:swiperefreshlayout:1.1.0")
api("androidx.cardview:cardview:1.0.0")
api("androidx.datastore:datastore-preferences:1.0.0")
api("com.journeyapps:zxing-android-embedded:4.3.0")
testImplementation("junit:junit:4.13.2")
androidTestImplementation("androidx.test.ext:junit:1.1.5")
androidTestImplementation("androidx.test.espresso:espresso-core:3.5.1")
}
configure<GenerateBpPluginExtension> {
targetSdk.set(android.compileSdk!!)
availableInAOSP.set { module: Module ->
when {
module.group == "androidx.datastore" -> false
module.group.startsWith("androidx") -> true
module.group == "com.google.android.material" -> true
else -> false
}
}
}

View file

21
app-deps/proguard-rules.pro vendored Normal file
View file

@ -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

View file

@ -0,0 +1,24 @@
package im.angry.openeuicc_deps
import androidx.test.platform.app.InstrumentationRegistry
import androidx.test.ext.junit.runners.AndroidJUnit4
import org.junit.Test
import org.junit.runner.RunWith
import org.junit.Assert.*
/**
* Instrumented test, which will execute on an Android device.
*
* See [testing documentation](http://d.android.com/tools/testing).
*/
@RunWith(AndroidJUnit4::class)
class ExampleInstrumentedTest {
@Test
fun useAppContext() {
// Context of the app under test.
val appContext = InstrumentationRegistry.getInstrumentation().targetContext
assertEquals("im.angry.openeuicc_deps.test", appContext.packageName)
}
}

View file

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
</manifest>

View file

@ -0,0 +1,17 @@
package im.angry.openeuicc_deps
import org.junit.Test
import org.junit.Assert.*
/**
* Example local unit test, which will execute on the development machine (host).
*
* See [testing documentation](http://d.android.com/tools/testing).
*/
class ExampleUnitTest {
@Test
fun addition_isCorrect() {
assertEquals(4, 2 + 2)
}
}

View file

@ -42,7 +42,4 @@ android {
dependencies {
implementation(project(":app-common"))
implementation("androidx.core:core-ktx:1.9.0")
implementation("androidx.appcompat:appcompat:1.6.1")
implementation("com.google.android.material:material:1.11.0")
}

View file

@ -38,14 +38,11 @@ android {
}
dependencies {
implementation("androidx.constraintlayout:constraintlayout:2.1.4")
implementation("androidx.recyclerview:recyclerview:1.3.2")
compileOnly(project(":libs:hidden-apis-stub"))
implementation(project(":libs:hidden-apis-shim"))
implementation(project(":libs:lpac-jni"))
implementation(project(":app-common"))
implementation("androidx.appcompat:appcompat:1.6.1")
testImplementation("junit:junit:4.13.2")
androidTestImplementation("androidx.test.ext:junit:1.1.3")
androidTestImplementation("androidx.test.espresso:espresso-core:3.4.0")
androidTestImplementation("androidx.test.ext:junit:1.1.5")
androidTestImplementation("androidx.test.espresso:espresso-core:3.5.1")
}

View file

@ -12,6 +12,17 @@ dependencyResolutionManagement {
mavenCentral()
}
}
buildscript {
repositories {
maven("https://raw.githubusercontent.com/lineage-next/gradle-generatebp/4356136ecccc68cf6796a5dcd2388c66b80e0c11/.m2")
}
dependencies {
classpath("org.lineageos:gradle-generatebp:+")
}
}
rootProject.name = "OpenEUICC"
include(":app")
include(":libs:hidden-apis-stub")
@ -19,3 +30,4 @@ include(":libs:hidden-apis-shim")
include(":libs:lpac-jni")
include(":app-common")
include(":app-unpriv")
include(":app-deps")