Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add deployment to Github packages & Maven Central #353

Merged
merged 24 commits into from
Feb 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
28a6d68
Add deployment to Github packages
ekigamba May 17, 2021
4eda94d
Add javadoc generation during publishing for both utils & library module
ekigamba May 17, 2021
d298a24
Remove mapbox key from library
ekigamba May 24, 2021
f7637f5
Add Sonatype and Maven Central publishing capability
ekigamba May 24, 2021
910c82c
Move Github packages and Maven Central packaging code to publish.gradle
ekigamba May 24, 2021
ea5d265
Add sample token in MapBoxOfflineResourcesDownloaderTest
ekigamba May 24, 2021
30ab141
Add Github actions CI
ekigamba May 24, 2021
0fd6894
Fix instrumentation tests
ekigamba May 24, 2021
236cf70
Fix ci.yml format causing error
ekigamba Sep 28, 2021
5d32d01
Fix failing tests in ArrowLineLayerTest
ekigamba Sep 28, 2021
90b19d8
Fix failing tests in MapboxOfflineDownloaderServiceTest
ekigamba Sep 28, 2021
56ef742
Add Github CI SSH debugging
ekigamba Oct 1, 2021
3e99543
Remove Github CI ssh debugging
ekigamba Oct 1, 2021
1dcbb0d
Add coveralls report key to CI build
ekigamba Oct 4, 2021
3a590e9
Fix coveralls not sending reports to Github
ekigamba Oct 5, 2021
c1029d8
Upgrade coveralls version to 2.10.2
ekigamba Oct 5, 2021
04a78c9
Update library dependency in util module
ekigamba Jan 28, 2022
05b2d80
Update build status badge, coveralls and artefact version badges
ekigamba Jan 28, 2022
1f74f0e
Remove unused imports
ekigamba Jan 28, 2022
87a9def
Update cgradapter-android dependency and it's repository
ekigamba Feb 5, 2022
6060e45
Retrigger codacy
ekigamba Feb 9, 2022
8a31547
Remove bintray instructions from README.MD
ekigamba Feb 9, 2022
e7e3012
Announce bintray sunset and changes in repository
ekigamba Feb 9, 2022
c7b40b5
Fix badges on README.MD
ekigamba Feb 10, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# This workflow will build a Java project with Gradle
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-gradle

name: Android CI with Gradle

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

jobs:
unit_tests:
env:
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Set up JDK 1.8
uses: actions/setup-java@v1
with:
java-version: 1.8
- name: Print Java version
run: java -version
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Clean project
run: ./gradlew clean --stacktrace
- name: Build project skipping tests
run: ./gradlew build -x test --stacktrace
- name: Run jacocoTestReport for each module
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: 22
script: ./gradlew jacocoTestReport --stacktrace
- name: Merge jacoco reports from all modules
run: ./gradlew jacocoFullReport --stacktrace
- name: Upload coverage to Coveralls with Gradle
run: ./gradlew coveralls --stacktrace
31 changes: 10 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
# Kujaku (Peacock) [![Build Status](https://travis-ci.org/onaio/kujaku.svg?branch=master)](https://travis-ci.org/onaio/kujaku) [ ![Download](https://api.bintray.com/packages/ona/kujaku/library/images/download.svg) ](https://bintray.com/ona/kujaku/library/_latestVersion) [![Coverage Status](https://coveralls.io/repos/github/onaio/kujaku/badge.svg)](https://coveralls.io/github/onaio/kujaku)
# Kujaku (Peacock) ![Build Status](https://github.com/onaio/kujaku/actions/workflows/ci.yml/badge.svg) ![Download](https://badgen.net/maven/v/maven-central/io.ona.kujaku/library) [![Coverage Status](https://coveralls.io/repos/github/onaio/kujaku/badge.svg)](https://coveralls.io/github/onaio/kujaku)

A mapping and check-in library for Android using **MapBox SDK (Version 8.3.3)**

## IMPORTANT UPDATE

**Kujaku library and utils artefacts are no longer available on bintray and any builds using these dependencies will fail. Kindly update to use `mavenCentral()` repository in your `build.gradle` and the `library` version `0.9.0` for a successful build. Kindly [create an issue](https://github.com/onaio/kujaku/issues/new) in case you face any problems.**

A mapping and check-in library for Android using **MapBox SDK (Version 7.2.0)**

# Table of Contents

Expand All @@ -24,23 +29,7 @@ For instructions on how to run the sample app see [these instructions](./sample/

### How to publish artifacts

To publish new versions to the **Bintray/JFrog** account, run:

```
export BINTRAY_USER=johndoe
export BINTRAY_KEY=98sdfkmykeyhere90sdckl
./gradlew :utils:clean :utils:assembleRelease :utils:bintrayUpload
./gradlew :library:clean :library:assembleRelease :library:bintrayUpload

```

To publish locally:

```
./gradlew :utils:clean :utils:assembleRelease :utils:publishToMavenLocal
./gradlew :library:clean :library:assembleRelease :library:publishToMavenLocal

```
Due to the sunsetting of JFrog Bintray, Kujaku artefacts/release are no longer available on bintray and all publishing is done to Maven Central. Some of the packages are also published to Github packages.

## How to import the library

Expand All @@ -54,7 +43,7 @@ To import the library:

allprojects {
repositories {
maven { url "http://dl.bintray.com/ona/kujaku" }
mavenCentral()
}
}

Expand All @@ -72,7 +61,7 @@ android {
dependencies {
...
// Kujaku dependencies
implementation 'io.ona.kujaku:library:0.7.2'
implementation 'io.ona.kujaku:library:0.9.0'
...
}
```
Expand Down
16 changes: 15 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ buildscript {
repositories {
google()
jcenter()
maven{ url "https://plugins.gradle.org/m2/" }
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
Expand All @@ -12,7 +13,7 @@ buildscript {
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.4'
classpath 'com.github.dcendents:android-maven-gradle-plugin:2.0'
classpath 'io.fabric.tools:gradle:1.25.4'
classpath 'org.kt3k.gradle.plugin:coveralls-gradle-plugin:2.8.3'
classpath 'gradle.plugin.org.kt3k.gradle.plugin:coveralls-gradle-plugin:2.10.2'
classpath 'com.palantir:jacoco-coverage:0.4.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
Expand All @@ -26,6 +27,19 @@ allprojects {
repositories {
google()
jcenter()
/*maven {
url 'https://api.mapbox.com/downloads/v2/releases/maven'
authentication {
basic(BasicAuthentication)
}
credentials {
// Do not change the username below.
// This should always be `mapbox` (not your username).
username = "mapbox"
// Use the secret token you stored in gradle.properties as the password
password = project.properties['MAPBOX_DOWNLOADS_TOKEN'] ?: ""
}
}*/
}
}

Expand Down
63 changes: 4 additions & 59 deletions library/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ buildscript {
allprojects {
repositories {
maven { url "https://dl.google.com/dl/android/maven2/" }
maven { url "http://dl.bintray.com/ona/kujaku" }
mavenLocal()
}
}

Expand All @@ -25,64 +25,6 @@ version '0.9.0'

project.version = this.version

task sourceJar(type: Jar) {
from android.sourceSets.main.java.srcDirs
classifier "sources"
}

artifacts {
archives sourceJar
}

publishing {
publications {
Production(MavenPublication) {
artifact("$buildDir/outputs/aar/library-release.aar")
artifact(sourceJar)
groupId 'io.ona.kujaku'
artifactId 'library'
version this.version

//The publication doesn't know about our dependencies, so we have to manually add them to the pom
pom.withXml {
def dependenciesNode = asNode().appendNode('dependencies')

//Iterate over the compile dependencies (we don't want the test ones), adding a <dependency> node for each
configurations.implementation.allDependencies.each {
def dependencyNode = dependenciesNode.appendNode('dependency')
dependencyNode.appendNode('groupId', it.group)
dependencyNode.appendNode('artifactId', it.name)
dependencyNode.appendNode('version', it.version)
}
}
}
}
}

bintray {
// Get Bintray credential from environment variable
user = System.getenv('BINTRAY_USER') // Get bintray User
key = System.getenv('BINTRAY_KEY') // Get bintray Secret Key
configurations = ['archives']
pkg {
repo = 'kujaku'
name = project.name
userOrg = 'ona'
licenses = ['Apache-2.0']
desc = 'Kujaku library'
websiteUrl = "https://ona.io"
publish = true
vcsUrl = "https://github.com/onaio/kujaku.git"
version {
name = this.version
desc = "Kujaku library version ${this.version}"
released = new Date()
vcsTag = this.version
}
}
publications = ['Production']
}

jacoco {
toolVersion = jacocoVersion
}
Expand Down Expand Up @@ -251,3 +193,6 @@ task jacocoTestReport(type: JacocoReport, dependsOn: ['testDebugUnitTest', 'crea
'jacoco/testDebugUnitTest.exec', 'outputs/code-coverage/connected/*coverage.ec'
])
}

// Add github packages, maven-central and sonatype publishing
apply from: '../publish.gradle'
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import java.util.Date;
import java.util.UUID;

import io.ona.kujaku.BuildConfig;
import io.ona.kujaku.data.MapBoxDeleteTask;
import io.ona.kujaku.data.MapBoxDownloadTask;
import io.ona.kujaku.data.realm.objects.MapBoxOfflineQueueTask;
Expand Down Expand Up @@ -87,7 +86,7 @@ public void getTasksShouldReturnCurrentRecordsWithAddedRecords() throws JSONExce
MapBoxDownloadTask mapBoxDownloadTask = createSampleDownloadTask(packageName, mapName, sampleMapBoxStyleURL);
mapBoxOfflineQueueTask = MapBoxDownloadTask.constructMapBoxOfflineQueueTask(mapBoxDownloadTask);
} else {
MapBoxDeleteTask mapBoxDeleteTask = new MapBoxDeleteTask(mapName, BuildConfig.MAPBOX_SDK_ACCESS_TOKEN);
MapBoxDeleteTask mapBoxDeleteTask = new MapBoxDeleteTask(mapName, "sample-token");
mapBoxOfflineQueueTask = MapBoxDeleteTask.constructMapBoxOfflineQueueTask(mapBoxDeleteTask);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,11 @@ public class MapBoxOfflineResourcesDownloaderTest extends BaseTest {
public ExpectedException expectedException = ExpectedException.none();

@Before
public void setup() {
public void setup() throws Throwable {
context = InstrumentationRegistry.getTargetContext();
MapBoxOfflineResourcesDownloader.instance = null;

uiThreadTestRule.runOnUiThread(() -> Mapbox.getInstance(context, "sample-token"));
}

@Test
Expand All @@ -79,7 +81,7 @@ public void downloadMapShouldThrowExceptionWhenGivenNullContext() throws Throwab
uiThreadTestRule.runOnUiThread(new Runnable() {
@Override
public void run() {
mapBoxOfflineResourcesDownloader = MapBoxOfflineResourcesDownloader.getInstance(null, Mapbox.getInstance(context, BuildConfig.MAPBOX_SDK_ACCESS_TOKEN));
mapBoxOfflineResourcesDownloader = MapBoxOfflineResourcesDownloader.getInstance(null, Mapbox.getInstance(context, Mapbox.getAccessToken()));
}
});
mapBoxOfflineResourcesDownloader.downloadMap(invalidDownloadTask, null);
Expand Down Expand Up @@ -206,7 +208,7 @@ private void createMapboxOfflineResourcesDownloaderInstanceOnUIThread() throws T
uiThreadTestRule.runOnUiThread(new Runnable() {
@Override
public void run() {
mapBoxOfflineResourcesDownloader = MapBoxOfflineResourcesDownloader.getInstance(context, BuildConfig.MAPBOX_SDK_ACCESS_TOKEN);
mapBoxOfflineResourcesDownloader = MapBoxOfflineResourcesDownloader.getInstance(context, Mapbox.getAccessToken());
}
});
}
Expand Down Expand Up @@ -327,7 +329,7 @@ public void onError(String error) {
uiThreadTestRule.runOnUiThread(new Runnable() {
@Override
public void run() {
mapBoxOfflineResourcesDownloader = MapBoxOfflineResourcesDownloader.getInstance(null, Mapbox.getInstance(context, BuildConfig.MAPBOX_SDK_ACCESS_TOKEN));
mapBoxOfflineResourcesDownloader = MapBoxOfflineResourcesDownloader.getInstance(null, Mapbox.getInstance(context, Mapbox.getAccessToken()));
}
});
mapBoxOfflineResourcesDownloader.deleteMap("Sample Map name", offlineRegionDeleteCallback);
Expand All @@ -345,7 +347,7 @@ public void deleteMapShouldCallErrorMethodWhenGiveNonExistentMapName() throws Th
uiThreadTestRule.runOnUiThread(new Runnable() {
@Override
public void run() {
mapBoxOfflineResourcesDownloader = MapBoxOfflineResourcesDownloader.getInstance(context, Mapbox.getInstance(context, BuildConfig.MAPBOX_SDK_ACCESS_TOKEN));
mapBoxOfflineResourcesDownloader = MapBoxOfflineResourcesDownloader.getInstance(context, Mapbox.getInstance(context, Mapbox.getAccessToken()));
}
});

Expand Down Expand Up @@ -490,7 +492,7 @@ public void onError(String error) {
uiThreadTestRule.runOnUiThread(new Runnable() {
@Override
public void run() {
mapBoxOfflineResourcesDownloader = MapBoxOfflineResourcesDownloader.getInstance(null, Mapbox.getInstance(context, BuildConfig.MAPBOX_SDK_ACCESS_TOKEN));
mapBoxOfflineResourcesDownloader = MapBoxOfflineResourcesDownloader.getInstance(null, Mapbox.getInstance(context, Mapbox.getAccessToken()));
mapBoxOfflineResourcesDownloader.deleteMap(invalidDownloadTask.getMapName(), offlineRegionDeleteCallback);
}
});
Expand Down Expand Up @@ -523,7 +525,7 @@ public void onError(String errorReason) {
uiThreadTestRule.runOnUiThread(new Runnable() {
@Override
public void run() {
mapBoxOfflineResourcesDownloader = MapBoxOfflineResourcesDownloader.getInstance(null, Mapbox.getInstance(context, BuildConfig.MAPBOX_SDK_ACCESS_TOKEN));
mapBoxOfflineResourcesDownloader = MapBoxOfflineResourcesDownloader.getInstance(null, Mapbox.getInstance(context, Mapbox.getAccessToken()));
}
});
mapBoxOfflineResourcesDownloader.getIncompleteMapDownloads(incompleteMapDownloadCallback);
Expand Down Expand Up @@ -712,7 +714,7 @@ private MapBoxDownloadTask createSampleDownloadTask(String mapName) {
-17.875469,
25.854782
),
BuildConfig.MAPBOX_SDK_ACCESS_TOKEN
Mapbox.getAccessToken()
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -541,8 +541,8 @@ private void getTaskStatus(@NonNull MapBoxOfflineQueueTask mapBoxOfflineQueueTas
private void showProgressNotification(@NonNull String mapName, double percentageProgress, boolean showAction) {
if (downloadProgressNotification == null) {
downloadProgressNotification = new DownloadProgressNotification(this);
downloadProgressNotification.createInitialNotification(mapName, BuildConfig.MAPBOX_SDK_ACCESS_TOKEN, REQUEST_ID_STOP_MAP_DOWNLOAD, showAction);
}
downloadProgressNotification.createInitialNotification(mapName, Mapbox.getAccessToken(), REQUEST_ID_STOP_MAP_DOWNLOAD, showAction);

downloadProgressNotification.updateNotification(percentageProgress, mapName, REQUEST_ID_STOP_MAP_DOWNLOAD, showAction);

Expand Down Expand Up @@ -722,7 +722,7 @@ public void onDestroy() {
super.onDestroy();
stopDownloadProgressUpdater();

if (MapBoxOfflineResourcesDownloader.getInstance(this, BuildConfig.MAPBOX_SDK_ACCESS_TOKEN)
if (MapBoxOfflineResourcesDownloader.getInstance(this, Mapbox.getAccessToken())
.getConnectivityReceiverActivationCounter() > 0) {
ConnectivityReceiver.instance(this)
.deactivate();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import com.mapbox.mapboxsdk.style.layers.SymbolLayer;
import com.mapbox.mapboxsdk.style.sources.GeoJsonSource;
import com.mapbox.mapboxsdk.utils.ColorUtils;
import com.mapbox.mapboxsdk.utils.ThreadUtils;

import org.junit.Before;
import org.junit.Test;
Expand Down Expand Up @@ -55,6 +56,7 @@ public class ArrowLineLayerTest extends BaseKujakuLayerTest {
@Before
public void setUp() {
context = RuntimeEnvironment.application;
ThreadUtils.init(context);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import android.app.Activity;
import android.content.Intent;

import com.mapbox.mapboxsdk.Mapbox;

import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
Expand All @@ -20,6 +22,7 @@
import io.ona.kujaku.TestApplication;
import io.ona.kujaku.activities.MapActivity;
import io.ona.kujaku.helpers.ActivityLauncherHelper;
import io.ona.kujaku.test.shadows.ShadowConnectivityReceiver;

import static junit.framework.Assert.assertEquals;
import static org.robolectric.Shadows.shadowOf;
Expand All @@ -30,7 +33,8 @@
@RunWith(RobolectricTestRunner.class)
@Config(constants = BuildConfig.class
, manifest = Config.NONE
, application = TestApplication.class)
, application = TestApplication.class,
shadows = {ShadowConnectivityReceiver.class})
public class KujakuLibraryTest {

@Rule
Expand All @@ -40,12 +44,13 @@ public class KujakuLibraryTest {

@Before
public void setupBeforeTest() {
Mapbox.getInstance(RuntimeEnvironment.application, "some-access-token");
activity = Robolectric.buildActivity(Activity.class).create().get();
}

@Test
public void testMethodLaunchMapActivityShouldSuccessfullyLaunchMapActivity() throws InterruptedException {
ActivityLauncherHelper.launchMapActivity(activity, BuildConfig.MAPBOX_SDK_ACCESS_TOKEN, new ArrayList<>(), true);
ActivityLauncherHelper.launchMapActivity(activity, Mapbox.getAccessToken(), new ArrayList<>(), true);
Thread.sleep(5000l);

Robolectric.getForegroundThreadScheduler().runOneTask(); // flush foreground job to allow AsyncTask's onPostExecute to run
Expand Down
Loading