Skip to content

Commit 0f59937

Browse files
authored
Merge pull request #11 from freshpaint-io/IND-1444/deploy-android
Ind 1444/deploy android
2 parents 45dcfd8 + 1a003d5 commit 0f59937

File tree

7 files changed

+180
-256
lines changed

7 files changed

+180
-256
lines changed

.circleci/config.yml

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
version: 2.1
2+
3+
orbs:
4+
android: circleci/android@2.3.0
5+
6+
jobs:
7+
test:
8+
machine:
9+
image: android:2024.11.1
10+
resource_class: large
11+
steps:
12+
- checkout
13+
- android/restore-gradle-cache
14+
- android/restore-build-cache
15+
- run:
16+
name: Run Tests
17+
environment:
18+
JAVA_OPTS: --add-exports jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED
19+
command: ./gradlew test
20+
- android/save-gradle-cache
21+
- android/save-build-cache
22+
- store_test_results:
23+
path: analytics/build/test-results
24+
- store_artifacts:
25+
path: analytics/build/reports/tests
26+
27+
build:
28+
machine:
29+
image: android:2024.11.1
30+
resource_class: large
31+
steps:
32+
- checkout
33+
- android/restore-gradle-cache
34+
- android/restore-build-cache
35+
- run:
36+
name: Build Release AAR
37+
environment:
38+
JAVA_OPTS: --add-exports jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED
39+
command: ./gradlew assembleRelease
40+
- run:
41+
name: Build Javadocs
42+
environment:
43+
JAVA_OPTS: --add-exports jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED
44+
command: ./gradlew androidJavadocs
45+
- android/save-gradle-cache
46+
- android/save-build-cache
47+
- store_artifacts:
48+
path: analytics/build/outputs/aar
49+
destination: aar-files
50+
- store_artifacts:
51+
path: analytics/build/docs
52+
destination: javadocs
53+
- persist_to_workspace:
54+
root: .
55+
paths:
56+
- analytics/build/outputs/aar/*
57+
- analytics/build/docs/*
58+
59+
publish-release:
60+
machine:
61+
image: android:2024.11.1
62+
resource_class: large
63+
steps:
64+
- checkout
65+
- attach_workspace:
66+
at: .
67+
- android/restore-gradle-cache
68+
- run:
69+
name: Publish Release to Sonatype Central
70+
command: |
71+
# If we use ASCII armored in memory keys, need to update this to use ORG_GRADLE_PROJECT_signingKey as an environment var
72+
# See this link https://docs.gradle.org/current/userguide/signing_plugin.html#sec:in-memory-keys
73+
# Then we'll also need to update `gradle-mvn-push.gradle` to use the in-memory PGP keys
74+
./gradlew :analytics:uploadToSonatype -PsonatypeUsername=$SONATYPE_USERNAME -PsonatypePassword=$SONATYPE_PASSWORD
75+
- android/save-gradle-cache
76+
77+
workflows:
78+
version: 2
79+
build-and-publish:
80+
jobs:
81+
- test
82+
- build:
83+
requires:
84+
- test
85+
86+
# Publish releases on master branch and tags
87+
- publish-release:
88+
requires:
89+
- build
90+
filters:
91+
branches:
92+
only: master
93+
tags:
94+
only: /^v.*/
95+
context:
96+
- sonatype-central

analytics/src/main/java/io/freshpaint/android/FreshpaintIntegration.java

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,7 @@ public String key() {
160160
"freshpaint_session_started_seconds";
161161
private static final String KEY_FIREBASE_SCREEN = "firebase_screen";
162162
private static final String KEY_FIREBASE_SCREEN_CLASS = "firebase_screen_class";
163+
163164
/**
164165
* Create a {@link QueueFile} in the given folder with the given name. If the underlying file is
165166
* somehow corrupted, we'll delete it, and try to recreate the file. This method will throw an
@@ -348,7 +349,7 @@ void performEnqueue(BasePayload original) {
348349

349350
eventProps.put(KEY_SESSION_ID, currentSessionId);
350351
eventProps.put(KEY_IS_FIRST_EVENT_IN_SESSION, isFirstEventInSession);
351-
352+
352353
addScreenPropertiesIfAvailable(payload, eventProps);
353354

354355
payload.put("properties", eventProps);
@@ -616,9 +617,9 @@ public void handleMessage(final Message msg) {
616617
}
617618

618619
/**
619-
* Adds Firebase screen properties to the event properties if a screen name is available.
620-
* Extracts screen name from payload (name or category) and generates a corresponding screen class.
621-
*
620+
* Adds Firebase screen properties to the event properties if a screen name is available. Extracts
621+
* screen name from payload (name or category) and generates a corresponding screen class.
622+
*
622623
* @param payload The original payload containing potential screen information
623624
* @param eventProps The event properties map to which screen properties will be added
624625
*/
@@ -633,7 +634,7 @@ private void addScreenPropertiesIfAvailable(ValueMap payload, ValueMap eventProp
633634

634635
/**
635636
* Extracts screen name from payload, trying 'name' first, then 'category'.
636-
*
637+
*
637638
* @param payload The payload to extract screen name from
638639
* @return The screen name if found, null otherwise
639640
*/
@@ -643,9 +644,9 @@ private String getScreenNameFromPayload(ValueMap payload) {
643644
}
644645

645646
/**
646-
* Generates a Firebase-compatible screen class name by removing special characters
647-
* and appending "Screen" suffix.
648-
*
647+
* Generates a Firebase-compatible screen class name by removing special characters and appending
648+
* "Screen" suffix.
649+
*
649650
* @param screenName The original screen name
650651
* @return A sanitized screen class name
651652
*/

build.gradle

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ apply from: rootProject.file('gradle/versioning.gradle')
33
buildscript {
44
ext.kotlin_version = '2.0.21'
55
repositories {
6+
gradlePluginPortal()
67
google()
78
mavenCentral()
89
maven {
@@ -11,6 +12,7 @@ buildscript {
1112
}
1213

1314
dependencies {
15+
classpath 'tech.medivh.plugin.publisher:tech.medivh.plugin.publisher.gradle.plugin:1.2.5'
1416
classpath 'com.android.tools.build:gradle:8.8.2'
1517
classpath 'com.diffplug.spotless:spotless-plugin-gradle:7.0.4'
1618
classpath 'com.getkeepsafe.dexcount:dexcount-gradle-plugin:4.0.0'
@@ -30,6 +32,7 @@ allprojects {
3032
apply plugin: 'idea'
3133

3234
repositories {
35+
gradlePluginPortal()
3336
google()
3437
mavenCentral()
3538
}

gradle.properties

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
GROUP=io.freshpaint.android
22

33
VERSION_CODE=2000
4-
VERSION_NAME=2.0.0
4+
VERSION_NAME=2.0.4
55

66
POM_NAME=Freshpaint for Android
77
POM_DESCRIPTION=Add Freshpaint to your Android App
@@ -17,9 +17,10 @@ POM_LICENCE_DIST=repo
1717

1818
POM_DEVELOPER_ID=freshpaint
1919
POM_DEVELOPER_NAME=Perfalytics, Inc.
20+
POM_DEVELOPER_EMAIL=andrew.lai@freshpaint.io
2021

2122
# Updated JVM args for Java 17 and better performance
22-
org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
23+
org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8 --add-exports jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED
2324

2425
# Modern Android settings
2526
android.useAndroidX=true
@@ -28,6 +29,23 @@ android.enableJetifier=true
2829
# Performance improvements
2930
org.gradle.parallel=true
3031
org.gradle.caching=true
31-
signing.keyId=
32-
signing.password=
33-
signing.secretKey=
32+
33+
# Signing keys
34+
###########################################################################3
35+
# This is an outdated method and can be used locally in a pinch. It allows you to specify a keyring.gpg file on a local system
36+
# This doesn't work well with CI, because CircleCI doesn't allow you to easily upload artifacts - so if we were to try
37+
# this method in Circle, we'd either need to create a gpg key on the target machine and restore on every run, or
38+
# ingest the key in a base64 encoded way, then emit a temporary secring.gpg file.
39+
###########################################################################3
40+
41+
#signing.keyId=last-8-digits-of-gpg-key
42+
#signing.password=password-for-gpg-key
43+
# gpg --keyring secring.gpg --export-secret-keys > ~/.gnupg/secring.gpg
44+
#signing.secretKeyRingFile=you-must-export-this-using-command-above
45+
46+
# Sonatype Central Credentials
47+
# This is not your Sonatype password, this is a generated token from https://central.sonatype.com/account
48+
# Prefer sending these properties into the gradle command via the flag -PsonatypeUsername=your-username, that way, you
49+
# don't have to modify this file and add secrets to it.
50+
#sonatypeUsername=sonatype-user-token
51+
#sonatypePassword=sonatype-user-token-password

gradle/gradle-mvn-push.gradle

Lines changed: 0 additions & 127 deletions
Original file line numberDiff line numberDiff line change
@@ -20,28 +20,6 @@ apply plugin: 'signing'
2020
version = VERSION_NAME
2121
group = GROUP
2222

23-
def isReleaseBuild() {
24-
return !VERSION_NAME.contains("SNAPSHOT")
25-
}
26-
27-
def getReleaseRepositoryUrl() {
28-
return hasProperty('RELEASE_REPOSITORY_URL') ? RELEASE_REPOSITORY_URL
29-
: "https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/"
30-
}
31-
32-
def getSnapshotRepositoryUrl() {
33-
return hasProperty('SNAPSHOT_REPOSITORY_URL') ? SNAPSHOT_REPOSITORY_URL
34-
: "https://s01.oss.sonatype.org/content/repositories/snapshots/"
35-
}
36-
37-
def getRepositoryUsername() {
38-
return hasProperty('NEXUS_USERNAME') ? NEXUS_USERNAME : ""
39-
}
40-
41-
def getRepositoryPassword() {
42-
return hasProperty('NEXUS_PASSWORD') ? NEXUS_PASSWORD : ""
43-
}
44-
4523
afterEvaluate { project ->
4624

4725
if (project.getPlugins().hasPlugin('com.android.application') ||
@@ -86,112 +64,7 @@ afterEvaluate { project ->
8664
}
8765
}
8866

89-
// Configure publishing - replaces uploadArchives
90-
publishing {
91-
publications {
92-
maven(MavenPublication) {
93-
groupId = GROUP
94-
artifactId = POM_ARTIFACT_ID
95-
version = VERSION_NAME
96-
97-
if (project.getPlugins().hasPlugin('com.android.application') ||
98-
project.getPlugins().hasPlugin('com.android.library')) {
99-
// Android library publishing
100-
artifact("$buildDir/outputs/aar/${project.getName()}-release.aar")
101-
artifact androidSourcesJar
102-
artifact androidJavadocsJar
103-
} else {
104-
// Java library publishing
105-
from components.java
106-
artifact sourcesJar
107-
artifact javadocJar
108-
}
109-
110-
pom {
111-
name = POM_NAME
112-
packaging = POM_PACKAGING
113-
description = POM_DESCRIPTION
114-
url = POM_URL
115-
116-
scm {
117-
url = POM_SCM_URL
118-
connection = POM_SCM_CONNECTION
119-
developerConnection = POM_SCM_DEV_CONNECTION
120-
}
121-
122-
licenses {
123-
license {
124-
name = POM_LICENCE_NAME
125-
url = POM_LICENCE_URL
126-
distribution = POM_LICENCE_DIST
127-
}
128-
}
129-
130-
developers {
131-
developer {
132-
id = POM_DEVELOPER_ID
133-
name = POM_DEVELOPER_NAME
134-
}
135-
}
136-
137-
// Add dependencies to POM (replaces automatic dependency resolution)
138-
withXml {
139-
def dependenciesNode = asNode().appendNode('dependencies')
140-
141-
def addDependencies = { configurationName ->
142-
project.configurations.findByName(configurationName)?.allDependencies?.each { dep ->
143-
if (dep.group != null && dep.name != null && dep.version != null && dep.name != 'unspecified') {
144-
def dependencyNode = dependenciesNode.appendNode('dependency')
145-
dependencyNode.appendNode('groupId', dep.group)
146-
dependencyNode.appendNode('artifactId', dep.name)
147-
dependencyNode.appendNode('version', dep.version)
148-
149-
// Set scope based on configuration
150-
if (configurationName == 'implementation' || configurationName == 'runtime') {
151-
dependencyNode.appendNode('scope', 'runtime')
152-
} else if (configurationName == 'api' || configurationName == 'compile') {
153-
dependencyNode.appendNode('scope', 'compile')
154-
}
155-
}
156-
}
157-
}
158-
159-
// Add different types of dependencies
160-
addDependencies('api')
161-
addDependencies('implementation')
162-
addDependencies('compile') // Legacy support
163-
addDependencies('runtime') // Legacy support
164-
}
165-
}
166-
}
167-
}
168-
169-
repositories {
170-
maven {
171-
name = "sonatype"
172-
url = isReleaseBuild() ? getReleaseRepositoryUrl() : getSnapshotRepositoryUrl()
173-
174-
credentials {
175-
username = getRepositoryUsername()
176-
password = getRepositoryPassword()
177-
}
178-
}
179-
}
180-
}
181-
18267
// Configure signing - updated for maven-publish
183-
signing {
184-
required { isReleaseBuild() && gradle.taskGraph.hasTask("publish") }
185-
sign publishing.publications.maven
186-
}
187-
188-
// Legacy compatibility tasks to maintain same interface
189-
task uploadArchives(dependsOn: 'publish') {
190-
doLast {
191-
logger.lifecycle("✅ Published ${project.name} ${VERSION_NAME} to ${isReleaseBuild() ? 'release' : 'snapshot'} repository")
192-
}
193-
}
194-
19568
task install(dependsOn: 'publishToMavenLocal') {
19669
doLast {
19770
logger.lifecycle("✅ Installed ${project.name} ${VERSION_NAME} to local Maven repository")

0 commit comments

Comments
 (0)