Skip to content

Commit 98e0014

Browse files
committed
Migration to latest Android Studio and Maven Central
1 parent f90d583 commit 98e0014

17 files changed

+222
-177
lines changed

.github/workflows/deploy-to-nexus.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: Deploy to Nexus
2+
on:
3+
workflow_dispatch:
4+
jobs:
5+
deployAarsToNexus:
6+
runs-on: ubuntu-latest
7+
steps:
8+
- uses: actions/checkout@v4
9+
with:
10+
fetch-depth: 0
11+
- uses: actions/setup-java@v4
12+
with:
13+
distribution: 'corretto'
14+
java-version: '17'
15+
- shell: bash
16+
env:
17+
# The following env variables are used by gradle/publish-module.gradle
18+
GPG_SIGNING_KEY: ${{ secrets.GPG_SIGNING_KEY }}
19+
GPG_PASSWORD: ${{ secrets.GPG_PASSWORD }}
20+
# The following env variables are used by gradle/publish-root.gradle
21+
OSSR_USERNAME: ${{ secrets.OSSR_USERNAME }}
22+
OSSR_PASSWORD: ${{ secrets.OSSR_PASSWORD }}
23+
SONATYPE_STATING_PROFILE_ID: ${{ secrets.SONATYPE_STAGING_PROFILE_ID }}
24+
# The script generates sec.gpg file that is required by gradle/publish-module.gradle
25+
# and starts :deployNexus lane using fastlane.
26+
run: |
27+
echo "${{ secrets.GPG_FILE }}" > sec.gpg.asc
28+
gpg -d --passphrase "${{ secrets.GPG_FILE_PSWD }}" --batch sec.gpg.asc > sec.gpg
29+
fastlane deployNexus

build.gradle

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,13 @@
33
buildscript {
44
repositories {
55
google()
6-
jcenter()
6+
mavenCentral()
7+
gradlePluginPortal()
78
}
89
dependencies {
9-
classpath 'com.android.tools.build:gradle:4.0.0'
10-
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.5'
10+
classpath 'com.android.tools.build:gradle:8.6.0'
11+
// https://plugins.gradle.org/plugin/io.github.gradle-nexus.publish-plugin
12+
classpath "io.github.gradle-nexus:publish-plugin:1.3.0"
1113

1214
// NOTE: Do not place your application dependencies here; they belong
1315
// in the individual module build.gradle files
@@ -17,6 +19,10 @@ buildscript {
1719
allprojects {
1820
repositories {
1921
google()
20-
jcenter()
22+
mavenCentral()
2123
}
22-
}
24+
}
25+
26+
// Maven Central publishing
27+
apply plugin: 'io.github.gradle-nexus.publish-plugin'
28+
apply from: rootProject.file('gradle/publish-root.gradle')

gradle.properties

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,7 @@
1515
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
1616
# org.gradle.parallel=true
1717
android.useAndroidX=true
18-
android.enableJetifier=true
1918

20-
VERSION_NAME=2.3.0
2119
GROUP=no.nordicsemi.android
2220

2321
POM_DESCRIPTION=nRF Logger API Library

gradle/git-tag-version.gradle

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
ext.getVersionCodeFromTags = { ->
2+
try {
3+
def code = new ByteArrayOutputStream()
4+
exec {
5+
commandLine 'git', 'tag', '--list'
6+
standardOutput = code
7+
}
8+
return 14 + code.toString().split("\n").size()
9+
}
10+
catch (ignored) {
11+
return -1
12+
}
13+
}
14+
15+
ext.getVersionNameFromTags = { ->
16+
try {
17+
def stdout = new ByteArrayOutputStream()
18+
exec {
19+
commandLine 'git', 'describe', '--tags', '--abbrev=0'
20+
standardOutput = stdout
21+
}
22+
return stdout.toString().trim().split("%")[0]
23+
}
24+
catch (ignored) {
25+
return null
26+
}
27+
}

gradle/gradle-bintray-push.gradle

Lines changed: 0 additions & 123 deletions
This file was deleted.

gradle/publish-module.gradle

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
apply plugin: 'maven-publish'
2+
apply plugin: 'signing'
3+
apply from: rootProject.file("gradle/git-tag-version.gradle")
4+
5+
group = GROUP
6+
version = getVersionNameFromTags()
7+
8+
tasks.register('androidSourcesJar', Jar) {
9+
from android.sourceSets.main.java.srcDirs
10+
}
11+
12+
afterEvaluate {
13+
publishing {
14+
publications {
15+
release(MavenPublication) {
16+
from components.release
17+
18+
artifact androidSourcesJar
19+
20+
groupId = GROUP
21+
artifactId = POM_ARTIFACT_ID
22+
version = getVersionNameFromTags()
23+
24+
pom {
25+
name = POM_NAME
26+
packaging = POM_PACKAGING
27+
description = POM_DESCRIPTION
28+
url = POM_URL
29+
30+
scm {
31+
url = POM_SCM_URL
32+
connection = POM_SCM_CONNECTION
33+
developerConnection = POM_SCM_DEV_CONNECTION
34+
}
35+
36+
licenses {
37+
license {
38+
name = POM_LICENCE_NAME
39+
url = POM_LICENCE_URL
40+
}
41+
}
42+
43+
developers {
44+
developer {
45+
id = POM_DEVELOPER_ID
46+
name = POM_DEVELOPER_NAME
47+
email = POM_DEVELOPER_EMAIL
48+
}
49+
}
50+
}
51+
}
52+
}
53+
}
54+
}
55+
56+
ext["signing.keyId"] = System.env.GPG_SIGNING_KEY
57+
ext["signing.password"] = System.env.GPG_PASSWORD
58+
ext["signing.secretKeyRingFile"] = "../sec.gpg"
59+
60+
signing {
61+
sign publishing.publications
62+
}

gradle/publish-root.gradle

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// Create variables with empty default values
2+
File secretPropsFile = project.rootProject.file('local.properties')
3+
if (secretPropsFile.exists()) {
4+
// Read local.properties file first if it exists
5+
Properties p = new Properties()
6+
new FileInputStream(secretPropsFile).withCloseable { is -> p.load(is) }
7+
p.each { name, value -> ext[name] = value }
8+
}
9+
10+
// Set up Sonatype repository
11+
12+
nexusPublishing {
13+
14+
repositories {
15+
sonatype {
16+
stagingProfileId = System.env.SONATYPE_STATING_PROFILE_ID
17+
username = System.env.OSSR_USERNAME
18+
password = System.env.OSSR_PASSWORD
19+
}
20+
}
21+
22+
}

gradle/wrapper/gradle-wrapper.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
33
distributionPath=wrapper/dists
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists
6-
distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip
6+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip

library/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
The jar files were created before the project was submitted on jcenter repository.
1+
The jar files were created before the project was submitted on Maven Central repository.
22

3-
Please, use jenter to obtain the newer versions.
3+
Please, use Maven Central to obtain the newer versions.

log-timber/build.gradle

Lines changed: 28 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,48 @@
11
apply plugin: 'com.android.library'
22

33
android {
4-
compileSdkVersion 29
4+
namespace 'no.nordicsemi.android.log.timber'
5+
compileSdk 34
56

67
defaultConfig {
7-
minSdkVersion 16
8-
targetSdkVersion 29
9-
versionCode 7
10-
versionName VERSION_NAME
8+
minSdk 16
9+
targetSdk 34
1110
}
11+
1212
buildTypes {
1313
release {
1414
minifyEnabled false
1515
}
1616
}
17+
18+
publishing {
19+
singleVariant('release') {
20+
withSourcesJar()
21+
withJavadocJar()
22+
}
23+
}
24+
25+
compileOptions {
26+
sourceCompatibility JavaVersion.VERSION_11
27+
targetCompatibility JavaVersion.VERSION_11
28+
}
1729
}
1830

1931
dependencies {
2032
api project(':log')
21-
api 'com.jakewharton.timber:timber:4.7.1'
33+
api 'com.jakewharton.timber:timber:5.0.1'
2234
}
2335

24-
afterEvaluate { project ->
25-
android.libraryVariants.all { variant ->
26-
tasks.androidJavadocs.doFirst {
27-
classpath += configurations.compile
28-
}
36+
// === Maven Central configuration ===
37+
if (rootProject.file('gradle/publish-module.gradle').exists()) {
38+
ext {
39+
POM_ARTIFACT_ID = 'log-timber'
40+
POM_NAME = 'nRF Logger API Library'
41+
POM_PACKAGING = 'aar'
2942
}
43+
apply from: rootProject.file('gradle/publish-module.gradle')
3044
}
3145

32-
apply from: rootProject.file('gradle/gradle-bintray-push.gradle')
46+
afterEvaluate {
47+
generateMetadataFileForReleasePublication.dependsOn androidSourcesJar
48+
}

0 commit comments

Comments
 (0)