Skip to content
Merged
Show file tree
Hide file tree
Changes from 39 commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
1979147
chore: comment out steps related to Sonarqube
alexgerardojacinto Jan 7, 2025
7d33cbe
feat: add publish-android workflow to publish Android lib in Maven
alexgerardojacinto Jan 7, 2025
ac9937c
chore: change name of workflow to something more suggestive
alexgerardojacinto Jan 7, 2025
5b0fcef
test: include own branch in workflow_dispatch rules
alexgerardojacinto Jan 7, 2025
4842bd1
test: include own branch in workflow_dispatch rules
alexgerardojacinto Jan 7, 2025
9020d9a
refactor: refactor workflow trigger rules
alexgerardojacinto Jan 7, 2025
2337e08
refactor: update library name in script URL
alexgerardojacinto Jan 7, 2025
75cd3cf
refactor: refactor library name and URLs in publish Gradle files
alexgerardojacinto Jan 7, 2025
7465e91
chore: avoid running full release
alexgerardojacinto Jan 7, 2025
08c6953
refactor: remove commented lines
alexgerardojacinto Jan 8, 2025
84c8b08
chore: uncomment line to release 0.0.1 version in Maven
alexgerardojacinto Jan 8, 2025
8a1b7be
feat: set workflow_dispatch to manual trigger, avoiding the GitHub ac…
alexgerardojacinto Jan 8, 2025
b50d008
refactor: remove own branch for workflow_dispatch branch rules
alexgerardojacinto Jan 8, 2025
54fb16c
chore: update changelog
alexgerardojacinto Jan 8, 2025
0f50378
chore: remove duplicated files
alexgerardojacinto Jan 8, 2025
2f07d87
chore: update README.md
alexgerardojacinto Jan 8, 2025
36c3f44
refactor: fix name of library in README.md
alexgerardojacinto Jan 8, 2025
d778351
fix: fix subtitles in README.md
alexgerardojacinto Jan 8, 2025
afc0bb4
fix: fix subtitle in README.md
alexgerardojacinto Jan 8, 2025
148471a
fix: fix subtitles in README.md
alexgerardojacinto Jan 8, 2025
41af2cc
refactor: refactoring text
alexgerardojacinto Jan 8, 2025
1bf7cd8
fix: publish library under `io.ionic.libs` instead of `com.capacitorjs`
alexgerardojacinto Jan 8, 2025
011fbfd
chore: set workflow_dispatch to manual trigger
alexgerardojacinto Jan 8, 2025
765b75d
fix: fix typo in yml file
alexgerardojacinto Jan 8, 2025
50d6023
chore: remove JIRA tickets from CHANGELOG.md
alexgerardojacinto Jan 9, 2025
83d60de
chore: update license from OutSystems to Ionic
alexgerardojacinto Jan 9, 2025
9d8e48c
chore: uncomment line that actually releases lib in Maven repo
alexgerardojacinto Jan 9, 2025
3340682
fix: LICENSE file directory in publish-module.gradle file
alexgerardojacinto Jan 9, 2025
0847eda
refactor: refactor phrasing in README file
alexgerardojacinto Jan 9, 2025
7b5fa41
fix: fixing typo in README
alexgerardojacinto Jan 9, 2025
fba7259
chore: fixing dates in CHANGELOG file
alexgerardojacinto Jan 9, 2025
4e828e2
Merge branch 'feat/RMET-3975/setup-pipelines' of github.com:ionic-tea…
alexgerardojacinto Jan 9, 2025
cf2961d
chore: set minSdk to 23 to keep minimum Android version for Capacitor…
alexgerardojacinto Jan 9, 2025
a2e509b
chore: move doc files to root
alexgerardojacinto Jan 9, 2025
119cc02
chore: fix dates in CHANGELOG
alexgerardojacinto Jan 9, 2025
39b356c
chore: set workflow to trigger in branch push to test it
alexgerardojacinto Jan 9, 2025
9956f8c
test: test running workflow without creating local.properties file
alexgerardojacinto Jan 9, 2025
8976fe6
test: use local.properties file instead of creating environment varia…
alexgerardojacinto Jan 9, 2025
66702cc
chore: remove commented lines
alexgerardojacinto Jan 9, 2025
1a71c10
chore: uncomment line to actually publish library to Maven repo
alexgerardojacinto Jan 9, 2025
a557211
chore: add more info to README.md file
alexgerardojacinto Jan 9, 2025
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
39 changes: 39 additions & 0 deletions .github/workflows/publish-android.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Publish Native Android Library

#on: workflow_dispatch
on:
workflow_dispatch:
push:
branches: [ feat/RMET-3975/setup-pipelines ]

jobs:
publish-android:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v4
- name: set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'adopt'
- name: Grant execute permission for gradlew
run: chmod +x ./gradlew
- name: Grant execute permission for publishing script
run: chmod +x ./scripts/publish-android.sh
- name: Make local props
run: |
cat << EOF > "local.properties"
ossrhUsername=${{ secrets.ANDROID_OSSRH_USERNAME }}
ossrhPassword=${{ secrets.ANDROID_OSSRH_PASSWORD }}
sonatypeStagingProfileId=${{ secrets.ANDROID_SONATYPE_STAGING_PROFILE_ID }}
signing.keyId=${{ secrets.ANDROID_SIGNING_KEY_ID }}
signing.password=${{ secrets.ANDROID_SIGNING_PASSWORD }}
signing.key=${{ secrets.ANDROID_SIGNING_KEY }}
EOF
echo "local.properties file has been created successfully."
- name: Run publish script
working-directory: ./scripts
run: ./publish-android.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: GitHub Actions
name: Run Unit Tests

on:
workflow_dispatch:
Expand Down Expand Up @@ -31,11 +31,12 @@ jobs:
- name: Code Coverage
run: bundle exec fastlane coverage

- name: Setup sonarqube
uses: warchant/setup-sonar-scanner@v8
# Commenting Sonarqube steps for now, until we are able to configure Sonarqube in Ionic repos
#- name: Setup sonarqube
# uses: warchant/setup-sonar-scanner@v8

- name: Send to Sonarcloud
run: bundle exec fastlane sonarqube
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
#- name: Send to Sonarcloud
# run: bundle exec fastlane sonarqube
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Changelog
All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [1.0.0]

### 2025-01-08
- Feat: Add workflows to run unit tests and release the library in Maven repo.

### 2025-01-07
- Feat: Add implementation for whole library, including `getCurrentPosition`, `watchPosition`, and `clearWatch`.
- Chore: Create repository.
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2024 OutSystems
Copyright (c) 2025 Ionic

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
79 changes: 77 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,78 @@
# OSGeolocationLib-Android
# OSGeolocationLib

The `OSGeolocationLib-Android` is a library built using `Kotlin`.
The `OSGeolocationLib-Android` is a library built using `Kotlin` that provides geolocation features for Android applications.

The `OSGLOCController` class provides the main features of the Library, which are:
- obtaining the location/position of the device a single time;
- adding a watch to obtain periodic location updates;
- clearing/removing a previously added watch, turning off location updates.


## Index

- [Motivation](#motivation)
- [Usage](#usage)
- [Methods](#methods)
- [Obtain the current location of the device](#obtain-the-current-location-of-the-device)
- [Add a watch for periodic location updates](#add-a-watch-for-periodic-location-updates)
- [Clear a watch that was added previously](#clear-a-watch-that-was-added-previously)

## Motivation

This library is used by the Geolocation Plugin for [OutSystems' Cordova Plugin](https://github.com/ionic-team/cordova-outsystems-geolocation) and [Ionic's Capacitor Plugin](https://github.com/ionic-team/outsystems-geolocation).

## Usage

In your app-level gradle file, import the `OSGeolocationLib` library like so:

dependencies {
implementation("com.capacitorjs:osgeolocation-android:1.0.0")
}


## Methods

As mentioned before, the library offers the `OSGLOCController` class that provides the following methods to interact with:

### Obtain the current location of the device

```kotlin
suspend fun getCurrentPosition(
activity: Activity,
options: OSGLOCLocationOptions
): Result<OSGLOCLocationResult>
```

The method is composed of the following input parameters:
- **activity**: the `Activity` from the app using the library to use when obtaining the location.
- **options**: `OSGLOCLocationOptions` with the options with which to make the location request with (e.g. timeout).

The method returns a `Result` containing either an object of type `OSGLOCLocationResult`, which includes the geolocation data (e.g. latitide, longitude), or an exception that should be handled by the caller app.

### Add a watch for periodic location updates

```kotlin
fun addWatch(
activity: Activity,
options: OSGLOCLocationOptions,
watchId: String
): Flow<Result<List<OSGLOCLocationResult>>>
```

The method is composed of the following input parameters:
- **activity**: the `Activity` from the app using the library to use when obtaining the location updates.
- **options**: `OSGLOCLocationOptions` with the options with which to make the location updates request with (e.g. timeout).
- **watchId**: a unique id identifying the watch to add, so that it can be removed later.

The method returns a Flow in which the location updates will be emitted to.

### Clear a watch that was added previously

```kotlin
fun clearWatch(id: String): Boolean
```

The method is composed of the following input parameters:
- **id**: the `watchId` identigying the watch to remove.

The method returns a Boolean indicating if the watch was cleared or not (in case the watch isn't found).
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ android {
compileSdk 35

defaultConfig {
minSdk 26
minSdk 23
targetSdk 35
versionCode 1
versionName "1.0"
Expand Down
11 changes: 0 additions & 11 deletions docs/CHANGELOG.md

This file was deleted.

21 changes: 0 additions & 21 deletions docs/LICENSE

This file was deleted.

50 changes: 0 additions & 50 deletions docs/README.md

This file was deleted.

Binary file removed docs/assets/createRepositoryButton.png
Binary file not shown.
Binary file removed docs/assets/repositoryNameExample.png
Binary file not shown.
Binary file removed docs/assets/useThisTemplateButton.png
Binary file not shown.
32 changes: 0 additions & 32 deletions docs/pull_request_template.md

This file was deleted.

8 changes: 5 additions & 3 deletions scripts/publish-android.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ LOG_OUTPUT=./tmp/publish-android.txt
THE_VERSION=`sed -n 's/.*<version>\(.*\)<\/version>.*/\1/p' ../pom.xml`

# Get latest io.ionic:portals XML version info
PUBLISHED_URL="https://repo1.maven.org/maven2/com/capacitorjs/geolocationlib-android/maven-metadata.xml"
PUBLISHED_URL="https://repo1.maven.org/maven2/io/ionic/libs/osgeolocation-android/maven-metadata.xml"
PUBLISHED_DATA=$(curl -s $PUBLISHED_URL)
PUBLISHED_VERSION="$(perl -ne 'print and last if s/.*<latest>(.*)<\/latest>.*/\1/;' <<< $PUBLISHED_DATA)"

Expand All @@ -20,8 +20,10 @@ else
export SHOULD_PUBLISH=true

printf %"s\n" "Attempting to build and publish version $THE_VERSION"
"$ANDROID_PATH"/gradlew clean build publishReleasePublicationToSonatypeRepository closeAndReleaseSonatypeStagingRepository --no-daemon --max-workers 1 -b "$ANDROID_PATH"/build.gradle -Pandroid.useAndroidX=true > $LOG_OUTPUT 2>&1
# "$ANDROID_PATH"/gradlew clean build publishReleasePublicationToSonatypeRepository --no-daemon --max-workers 1 -b "$ANDROID_PATH"/build.gradle -Pandroid.useAndroidX=true > $LOG_OUTPUT 2>&1
# Publish a release to the Maven repo
# "$ANDROID_PATH"/gradlew clean build publishReleasePublicationToSonatypeRepository closeAndReleaseSonatypeStagingRepository --no-daemon --max-workers 1 -b "$ANDROID_PATH"/build.gradle -Pandroid.useAndroidX=true > $LOG_OUTPUT 2>&1
# Stage a version
"$ANDROID_PATH"/gradlew clean build publishReleasePublicationToSonatypeRepository --no-daemon --max-workers 1 -b "$ANDROID_PATH"/build.gradle -Pandroid.useAndroidX=true > $LOG_OUTPUT 2>&1

echo $RESULT

Expand Down
27 changes: 11 additions & 16 deletions scripts/publish-module.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,29 +5,24 @@ def LIB_VERSION = System.getenv('THE_VERSION')

task androidSourcesJar(type: Jar) {
archiveClassifier.set('sources')
//if (project.plugins.findPlugin("com.android.library")) {
from android.sourceSets.main.java.srcDirs
from android.sourceSets.main.kotlin.srcDirs
//} else {
// from sourceSets.main.java.srcDirs
// from sourceSets.main.kotlin.srcDirs
//}
from android.sourceSets.main.java.srcDirs
from android.sourceSets.main.kotlin.srcDirs
}

artifacts {
archives androidSourcesJar
}

group = 'com.capacitorjs'
group = 'io.ionic.libs'
version = LIB_VERSION

afterEvaluate {
publishing {
publications {
release(MavenPublication) {
// Coordinates
groupId 'com.capacitorjs'
artifactId 'osgeolocationlib-android'
groupId 'io.ionic.libs'
artifactId 'osgeolocation-android'
version LIB_VERSION

// Two artifacts, the `aar` (or `jar`) and the sources
Expand All @@ -41,13 +36,13 @@ afterEvaluate {

// POM Data
pom {
name = 'geolocationlib-android'
name = 'osgeolocation-android'
description = 'Geolocation Android Lib'
url = 'https://github.com/ionic-team/outsystems-geolocation/packages/android-lib'
url = 'https://github.com/ionic-team/OSGeolocationLib-Android'
licenses {
license {
name = 'License'
url = 'https://github.com/ionic-team/outsystems-geolocation/blob/main/packages/android-lib/LICENSE'
url = 'https://github.com/ionic-team/OSGeolocationLib-Android/blob/main/docs/LICENSE'
}
}
developers {
Expand All @@ -59,9 +54,9 @@ afterEvaluate {

// Version Control Info
scm {
connection = 'scm:git:github.com:ionic-team/outsystems-geolocation.git'
developerConnection = 'scm:git:ssh://github.com:ionic-team/outsystems-geolocation.git'
url = 'https://github.com/ionic-team/outsystems-geolocation/tree/main'
connection = 'scm:git:github.com:ionic-team/OSGeolocationLib-Android.git'
developerConnection = 'scm:git:ssh://github.com:ionic-team/OSGeolocationLib-Android.git'
url = 'https://github.com/ionic-team/OSGeolocationLib-Android/tree/main'
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion scripts/publish-root.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,5 @@ nexusPublishing {
snapshotRepositoryUrl.set(uri("https://s01.oss.sonatype.org/content/repositories/snapshots/"))
}
}
repositoryDescription = 'OSGeolocation Lib v' + System.getenv('THE_VERSION')
repositoryDescription = 'OSGeolocation Android Lib v' + System.getenv('THE_VERSION')
}
Loading