Skip to content

Commit 729d028

Browse files
authored
[NO MERGE] Prepare mvn central (#27)
Prepare mcumgr-android for publishing on maven central. This commit modifies the gradle build files for hosting on the maven central repository. The gradle file which is used to upload the archives to maven central is taken from https://github.com/JakeWharton/timber. The group details for the project are located in the root build.properties file. This file contains, among others: * Version: 0.6.3-SNAPSHOT * Group: io.runtime.mcumgr The package specific artifact ID and name are located in the module gradle.properties file. The core and transport specific implementations have been split. The core now resides in the mcumgr-core module, while the BLE transport implementation has a separate module, mcumgr-ble, which pulls mcumgr-core in as an api dependency. This change is useful to allow users to reimplement their own transport layer or potentially add a new transport all together. Furthermore, since I plan on adding the CoAP BLE transport at some point to the main repo, this allows me to simply add a new module, mcumgr-coap-ble, rather than adding it to mcumgr-android and forceing users to add dependencies which they will not use. Finally, I can forsee a future where the core could be broken out into it's own plain java library for use in non-android applications. This would simplify that process as it is already built as a separate artifact.
1 parent 09ce393 commit 729d028

File tree

72 files changed

+501
-199
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

72 files changed

+501
-199
lines changed

build.gradle

+1-2
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,19 @@
66
*/
77

88
buildscript {
9-
109
repositories {
1110
google()
1211
jcenter()
1312
}
1413
dependencies {
1514
classpath 'com.android.tools.build:gradle:3.1.4'
16-
// classpath 'com.github.dcendents:android-maven-gradle-plugin:2.0'
1715
}
1816
}
1917

2018
allprojects {
2119
repositories {
2220
google()
2321
jcenter()
22+
maven { url 'https://oss.sonatype.org/content/repositories/snapshots/' }
2423
}
2524
}

gradle.properties

+13-17
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,13 @@
1-
# Project-wide Gradle settings.
2-
3-
# IDE (e.g. Android Studio) users:
4-
# Gradle settings configured through the IDE *will override*
5-
# any settings specified in this file.
6-
7-
# For more details on how to configure your build environment visit
8-
# http://www.gradle.org/docs/current/userguide/build_environment.html
9-
10-
# Specifies the JVM arguments used for the daemon process.
11-
# The setting is particularly useful for tweaking memory settings.
12-
org.gradle.jvmargs=-Xmx1536m
13-
14-
# When configured, Gradle will run in incubating parallel mode.
15-
# This option should only be used with decoupled projects. More details, visit
16-
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
17-
# org.gradle.parallel=true
1+
VERSION_NAME=0.6.3-SNAPSHOT
2+
GROUP=io.runtime.mcumgr
3+
4+
POM_DESCRIPTION=A mobile management library for devices running Apache Mynewt and Zephyr (DFU, logs, stats, config, etc.)
5+
POM_URL=https://github.com/runtimeco/mcumgr-android
6+
POM_SCM_URL=https://github.com/runtimeco/mcumgr-android
7+
POM_SCM_CONNECTION=scm:[email protected]:runtimeco/mcumgr-android.git
8+
POM_SCM_DEV_CONNECTION=scm:[email protected]:runtimeco/mcumgr-android.git
9+
POM_LICENCE_NAME=The Apache Software License, Version 2.0
10+
POM_LICENCE_URL=http://www.apache.org/licenses/LICENSE-2.0.txt
11+
POM_LICENCE_DIST=repo
12+
POM_DEVELOPER_ID=runtimeco
13+
POM_DEVELOPER_NAME=Runtime, Inc.

gradle/gradle-mvn-push.gradle

+213
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,213 @@
1+
/*
2+
* Copyright 2013 Chris Banes
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
apply plugin: 'maven'
18+
apply plugin: 'signing'
19+
20+
version = VERSION_NAME
21+
group = GROUP
22+
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://oss.sonatype.org/service/local/staging/deploy/maven2/"
30+
}
31+
32+
def getSnapshotRepositoryUrl() {
33+
return hasProperty('SNAPSHOT_REPOSITORY_URL') ? SNAPSHOT_REPOSITORY_URL :
34+
"https://oss.sonatype.org/content/repositories/snapshots/"
35+
}
36+
37+
def getRepositoryUsername() {
38+
return hasProperty('SONATYPE_NEXUS_USERNAME') ? SONATYPE_NEXUS_USERNAME : ""
39+
}
40+
41+
def getRepositoryPassword() {
42+
return hasProperty('SONATYPE_NEXUS_PASSWORD') ? SONATYPE_NEXUS_PASSWORD : ""
43+
}
44+
45+
afterEvaluate { project ->
46+
uploadArchives {
47+
repositories {
48+
mavenDeployer {
49+
beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }
50+
51+
pom.groupId = GROUP
52+
pom.artifactId = POM_ARTIFACT_ID
53+
pom.version = VERSION_NAME
54+
55+
repository(url: getReleaseRepositoryUrl()) {
56+
authentication(userName: getRepositoryUsername(), password: getRepositoryPassword())
57+
}
58+
snapshotRepository(url: getSnapshotRepositoryUrl()) {
59+
authentication(userName: getRepositoryUsername(), password: getRepositoryPassword())
60+
}
61+
62+
pom.project {
63+
name POM_NAME
64+
packaging POM_PACKAGING
65+
description POM_DESCRIPTION
66+
url POM_URL
67+
68+
scm {
69+
url POM_SCM_URL
70+
connection POM_SCM_CONNECTION
71+
developerConnection POM_SCM_DEV_CONNECTION
72+
}
73+
74+
licenses {
75+
license {
76+
name POM_LICENCE_NAME
77+
url POM_LICENCE_URL
78+
distribution POM_LICENCE_DIST
79+
}
80+
}
81+
82+
developers {
83+
developer {
84+
id POM_DEVELOPER_ID
85+
name POM_DEVELOPER_NAME
86+
}
87+
}
88+
}
89+
}
90+
}
91+
}
92+
93+
signing {
94+
required { isReleaseBuild() && gradle.taskGraph.hasTask("uploadArchives") }
95+
sign configurations.archives
96+
}
97+
98+
if (project.getPlugins().hasPlugin('com.android.application') ||
99+
project.getPlugins().hasPlugin('com.android.library')) {
100+
task install(type: Upload, dependsOn: assemble) {
101+
repositories.mavenInstaller {
102+
configuration = configurations.archives
103+
104+
pom.groupId = GROUP
105+
pom.artifactId = POM_ARTIFACT_ID
106+
pom.version = VERSION_NAME
107+
108+
pom.project {
109+
name POM_NAME
110+
packaging POM_PACKAGING
111+
description POM_DESCRIPTION
112+
url POM_URL
113+
114+
scm {
115+
url POM_SCM_URL
116+
connection POM_SCM_CONNECTION
117+
developerConnection POM_SCM_DEV_CONNECTION
118+
}
119+
120+
licenses {
121+
license {
122+
name POM_LICENCE_NAME
123+
url POM_LICENCE_URL
124+
distribution POM_LICENCE_DIST
125+
}
126+
}
127+
128+
developers {
129+
developer {
130+
id POM_DEVELOPER_ID
131+
name POM_DEVELOPER_NAME
132+
}
133+
}
134+
}
135+
}
136+
}
137+
138+
task androidJavadocsJar(type: Jar) {
139+
classifier = 'javadoc'
140+
from "$buildDir/dokkaJavadoc"
141+
}
142+
143+
task androidSourcesJar(type: Jar) {
144+
classifier = 'sources'
145+
from android.sourceSets.main.java.source
146+
}
147+
} else {
148+
install {
149+
repositories.mavenInstaller {
150+
pom.groupId = GROUP
151+
pom.artifactId = POM_ARTIFACT_ID
152+
pom.version = VERSION_NAME
153+
154+
pom.project {
155+
name POM_NAME
156+
packaging POM_PACKAGING
157+
description POM_DESCRIPTION
158+
url POM_URL
159+
160+
scm {
161+
url POM_SCM_URL
162+
connection POM_SCM_CONNECTION
163+
developerConnection POM_SCM_DEV_CONNECTION
164+
}
165+
166+
licenses {
167+
license {
168+
name POM_LICENCE_NAME
169+
url POM_LICENCE_URL
170+
distribution POM_LICENCE_DIST
171+
}
172+
}
173+
174+
developers {
175+
developer {
176+
id POM_DEVELOPER_ID
177+
name POM_DEVELOPER_NAME
178+
}
179+
}
180+
}
181+
}
182+
}
183+
184+
task sourcesJar(type: Jar, dependsOn: classes) {
185+
classifier = 'sources'
186+
from sourceSets.main.allSource
187+
}
188+
189+
task javadocJar(type: Jar, dependsOn: javadoc) {
190+
classifier = 'javadoc'
191+
from javadoc.destinationDir
192+
}
193+
}
194+
195+
if (JavaVersion.current().isJava8Compatible()) {
196+
allprojects {
197+
tasks.withType(Javadoc) {
198+
options.addStringOption('Xdoclint:none', '-quiet')
199+
}
200+
}
201+
}
202+
203+
artifacts {
204+
if (project.getPlugins().hasPlugin('com.android.application') ||
205+
project.getPlugins().hasPlugin('com.android.library')) {
206+
archives androidSourcesJar
207+
archives androidJavadocsJar
208+
} else {
209+
archives sourcesJar
210+
archives javadocJar
211+
}
212+
}
213+
}

mcumgr-android-lib/build.gradle

-75
This file was deleted.
File renamed without changes.

mcumgr-ble/build.gradle

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
apply plugin: 'com.android.library'
2+
3+
android {
4+
compileSdkVersion 28
5+
6+
7+
8+
defaultConfig {
9+
minSdkVersion 18
10+
targetSdkVersion 28
11+
versionCode 1
12+
versionName "1.0"
13+
14+
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
15+
16+
}
17+
18+
buildTypes {
19+
release {
20+
minifyEnabled false
21+
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
22+
}
23+
}
24+
25+
}
26+
27+
dependencies {
28+
// Import the BLE Library
29+
api 'no.nordicsemi.android:ble:2.0-alpha6'
30+
31+
// Import the Timber library
32+
implementation 'com.jakewharton.timber:timber:4.7.1'
33+
34+
// Import mcumgr-core
35+
api project(':mcumgr-core')
36+
37+
testImplementation 'junit:junit:4.12'
38+
androidTestImplementation 'com.android.support.test:runner:1.0.2'
39+
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
40+
}
41+
42+
apply from: rootProject.file('gradle/gradle-mvn-push.gradle')

mcumgr-ble/gradle.properties

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
POM_ARTIFACT_ID=mcumgr-ble
2+
POM_NAME=McuManager Ble
3+
POM_PACKAGING=aar

0 commit comments

Comments
 (0)