From e7cc18d32ae264a6454b82cbe917a9194f6d7aa3 Mon Sep 17 00:00:00 2001 From: Tyler Potter Date: Fri, 20 Feb 2026 19:54:37 -0700 Subject: [PATCH] feat(build): set up two-module structure for framework/batteries split Create the eppo-android-common module as the batteries-included artifact while the eppo module becomes the framework artifact. This follows the same pattern as the common SDK v4 branch. Changes: - Create eppo-android-common module with transitive dependency on :eppo - Update settings.gradle to include new module - Update example app to depend on :eppo-android-common - Change eppo module artifact ID from android-sdk to android-sdk-framework - Use separate namespace for eppo-android-common to avoid BuildConfig conflicts --- eppo-android-common/build.gradle | 153 ++++++++++++++++++ eppo-android-common/consumer-rules.pro | 2 + .../src/main/AndroidManifest.xml | 3 + eppo/build.gradle | 6 +- example/build.gradle | 2 +- settings.gradle | 1 + 6 files changed, 163 insertions(+), 4 deletions(-) create mode 100644 eppo-android-common/build.gradle create mode 100644 eppo-android-common/consumer-rules.pro create mode 100644 eppo-android-common/src/main/AndroidManifest.xml diff --git a/eppo-android-common/build.gradle b/eppo-android-common/build.gradle new file mode 100644 index 00000000..2b87db59 --- /dev/null +++ b/eppo-android-common/build.gradle @@ -0,0 +1,153 @@ +plugins { + id 'com.android.library' + id 'maven-publish' + id "com.vanniktech.maven.publish" version "0.32.0" + id 'signing' + id "com.diffplug.spotless" version "8.0.0" +} + +group = "cloud.eppo" +version = "4.12.1" + +android { + buildFeatures.buildConfig false + compileSdk 34 + + defaultConfig { + // Use a different namespace to avoid conflicts with the framework module + // The code still uses cloud.eppo.android packages, but the Android namespace is different + namespace "cloud.eppo.android.common" + minSdk 26 + targetSdk 34 + consumerProguardFiles "consumer-rules.pro" + } + + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + matchingFallbacks = ['release'] + } + + debug { + minifyEnabled false + matchingFallbacks = ['debug'] + } + } + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } + testOptions { + unitTests.returnDefaultValues = true + } + packagingOptions { + resources { + excludes += "META-INF/**" + } + } +} + +dependencies { + // API dependency on framework (for compilation) + api project(':eppo') + + // These will be added in PR4 when we add default implementations + // implementation 'cloud.eppo:eppo-sdk-common:4.0.0-SNAPSHOT' + // implementation "com.squareup.okhttp3:okhttp:4.12.0" + // implementation "com.fasterxml.jackson.core:jackson-databind:2.19.1" +} + +spotless { + format 'misc', { + target '*.gradle', '.gitattributes', '.gitignore' + + trimTrailingWhitespace() + leadingTabsToSpaces(2) + endWithNewline() + } + java { + target '**/*.java' + + googleJavaFormat() + formatAnnotations() + } +} + +signing { + if (System.getenv("GPG_PRIVATE_KEY") && System.getenv("GPG_PASSPHRASE")) { + // Use in-memory keys for CI builds + useInMemoryPgpKeys(System.env.GPG_PRIVATE_KEY, System.env.GPG_PASSPHRASE) + } + + sign publishing.publications // Sign all Maven publications +} + +// Make sure signing tasks only run if configured correctly +tasks.withType(Sign) { + onlyIf { + (System.getenv("GPG_PRIVATE_KEY") && System.getenv("GPG_PASSPHRASE")) || + (project.hasProperty('signing.keyId') && + project.hasProperty('signing.password') && + project.hasProperty('signing.secretKeyRingFile')) + } +} + +// For backward compatibility, keep same artifact ID +mavenPublishing { + publishToMavenCentral(com.vanniktech.maven.publish.SonatypeHost.CENTRAL_PORTAL) + signAllPublications() + coordinates("cloud.eppo", "android-sdk", project.version) + + pom { + name = 'Eppo Android' + description = 'Eppo Android SDK - batteries-included with OkHttp and Jackson' + url = 'https://github.com/Eppo-exp/android-sdk' + licenses { + license { + name = 'MIT License' + url = 'http://www.opensource.org/licenses/mit-license.php' + } + } + developers { + developer { + name = 'Eppo' + email = 'https://www.geteppo.com' + } + } + scm { + connection = 'scm:git:git://github.com/Eppo-exp/android-sdk.git' + developerConnection = 'scm:git:ssh://github.com/Eppo-exp/android-sdk.git' + url = 'https://github.com/Eppo-exp/android-sdk/tree/main' + } + } +} + +// Custom task to ensure we can conditionally publish either a release or snapshot artifact +// based on a command line switch. See github workflow files for more details on usage. +task checkVersion { + doLast { + if (!project.hasProperty('release') && !project.hasProperty('snapshot')) { + throw new GradleException("You must specify either -Prelease or -Psnapshot") + } + if (project.hasProperty('release') && project.version.endsWith('SNAPSHOT')) { + throw new GradleException("You cannot specify -Prelease with a SNAPSHOT version") + } + if (project.hasProperty('snapshot') && !project.version.endsWith('SNAPSHOT')) { + throw new GradleException("You cannot specify -Psnapshot with a non-SNAPSHOT version") + } + project.ext.shouldPublish = true + } +} + +// Ensure checkVersion runs before publishing +tasks.named('publish').configure { + dependsOn checkVersion +} + +// Conditionally enable or disable publishing tasks +tasks.withType(PublishToMavenRepository) { + onlyIf { + project.ext.has('shouldPublish') && project.ext.shouldPublish + } +} diff --git a/eppo-android-common/consumer-rules.pro b/eppo-android-common/consumer-rules.pro new file mode 100644 index 00000000..4a548a8c --- /dev/null +++ b/eppo-android-common/consumer-rules.pro @@ -0,0 +1,2 @@ +# Consumer ProGuard rules for eppo-android-common (batteries-included) +# These rules are included in apps that use this library diff --git a/eppo-android-common/src/main/AndroidManifest.xml b/eppo-android-common/src/main/AndroidManifest.xml new file mode 100644 index 00000000..9a40236b --- /dev/null +++ b/eppo-android-common/src/main/AndroidManifest.xml @@ -0,0 +1,3 @@ + + + diff --git a/eppo/build.gradle b/eppo/build.gradle index 4aabb135..bb66f2c1 100644 --- a/eppo/build.gradle +++ b/eppo/build.gradle @@ -126,11 +126,11 @@ tasks.withType(Sign) { mavenPublishing { publishToMavenCentral(com.vanniktech.maven.publish.SonatypeHost.CENTRAL_PORTAL) signAllPublications() - coordinates("cloud.eppo", "android-sdk", project.version) + coordinates("cloud.eppo", "android-sdk-framework", project.version) pom { - name = 'Eppo Android' - description = 'Eppo Android SDK' + name = 'Eppo Android Framework' + description = 'Eppo Android SDK Framework - requires HTTP and parser implementations' url = 'https://github.com/Eppo-exp/android-sdk' licenses { license { diff --git a/example/build.gradle b/example/build.gradle index 2278e0a8..88e00f21 100644 --- a/example/build.gradle +++ b/example/build.gradle @@ -58,7 +58,7 @@ dependencies { implementation 'androidx.appcompat:appcompat:1.7.1' implementation 'com.google.android.material:material:1.12.0' implementation 'androidx.constraintlayout:constraintlayout:2.2.1' - implementation project(path: ':eppo') + implementation project(path: ':eppo-android-common') testImplementation 'junit:junit:4.13.2' androidTestImplementation 'androidx.test.ext:junit:1.2.1' androidTestImplementation 'androidx.test.espresso:espresso-core:3.6.1' diff --git a/settings.gradle b/settings.gradle index fc9b6edb..f3817e14 100644 --- a/settings.gradle +++ b/settings.gradle @@ -19,3 +19,4 @@ dependencyResolutionManagement { rootProject.name = "Eppo SDK" include ':example' include ':eppo' +include ':eppo-android-common'