Skip to content

Commit 0b1362c

Browse files
feat: bring full implementation of library from outsystems-geolocation repo
References: https://outsystemsrd.atlassian.net/browse/RMET-3771
1 parent 628534b commit 0b1362c

File tree

40 files changed

+1241
-364
lines changed

40 files changed

+1241
-364
lines changed

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2024 OutSystems
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# OSGeolocationLib-Android
2+
3+
The `OSGeolocationLib-Android` is a library built using `Kotlin`.

build.gradle

Lines changed: 72 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,58 @@
11
buildscript {
2-
ext.kotlin_version = "1.5.21"
2+
ext.kotlin_version = "1.9.24"
33
ext.jacocoVersion = '0.8.7'
44
repositories {
55
google()
66
mavenCentral()
7+
maven {
8+
url = uri("https://plugins.gradle.org/m2/")
9+
}
710
}
811
dependencies {
9-
classpath 'com.android.tools.build:gradle:7.1.2'
12+
if (System.getenv("SHOULD_PUBLISH") == "true") {
13+
classpath("io.github.gradle-nexus:publish-plugin:1.1.0")
14+
}
15+
classpath 'com.android.tools.build:gradle:8.2.2'
1016
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
1117
classpath "org.jacoco:org.jacoco.core:$jacocoVersion"
1218
}
1319
}
1420

21+
plugins {
22+
id "org.sonarqube" version "3.5.0.2730"
23+
}
24+
25+
sonarqube {
26+
properties {
27+
property "sonar.projectKey", "OutSystems_OSGeolocationLib-Android"
28+
property "sonar.organization", "outsystemsrd"
29+
property "sonar.host.url", "https://sonarcloud.io"
30+
}
31+
}
32+
33+
if (System.getenv("SHOULD_PUBLISH") == "true") {
34+
apply plugin: "io.github.gradle-nexus.publish-plugin"
35+
apply from: file("./scripts/publish-root.gradle")
36+
}
37+
1538
apply plugin: "com.android.library"
1639
apply plugin: "kotlin-android"
1740
apply plugin: "jacoco"
1841

1942
android {
20-
compileSdk 32
43+
namespace "com.outsystems.plugins.osgeolocation"
44+
compileSdk 35
2145

2246
defaultConfig {
2347
minSdk 26
24-
targetSdk 32
48+
targetSdk 35
2549
versionCode 1
2650
versionName "1.0"
2751

2852
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
53+
vectorDrawables {
54+
useSupportLibrary true
55+
}
2956
}
3057

3158
buildTypes {
@@ -35,23 +62,23 @@ android {
3562
}
3663
}
3764
compileOptions {
38-
sourceCompatibility JavaVersion.VERSION_1_8
39-
targetCompatibility JavaVersion.VERSION_1_8
65+
sourceCompatibility JavaVersion.VERSION_17
66+
targetCompatibility JavaVersion.VERSION_17
4067
}
4168
kotlinOptions {
42-
jvmTarget = '1.8'
69+
jvmTarget = '17'
4370
}
4471

4572
task jacocoTestReport(type: JacocoReport, dependsOn: ['testDebugUnitTest']) {
4673

4774
reports {
48-
xml.enabled = true
49-
html.enabled = true
75+
xml.getRequired().set(true)
76+
html.getRequired().set(true)
5077
}
5178

5279
def fileFilter = ['**/BuildConfig.*', '**/Manifest*.*']
53-
def debugTree = fileTree(dir: "${buildDir}/tmp/kotlin-classes/debugUnitTest", excludes: fileFilter)
54-
def mainSrc = "${project.projectDir}/src/main/java"
80+
def debugTree = fileTree(dir: "${buildDir}/tmp/kotlin-classes/debug", excludes: fileFilter)
81+
def mainSrc = "${project.projectDir}/src/main/kotlin"
5582

5683
sourceDirectories.setFrom(files([mainSrc]))
5784
classDirectories.setFrom(files([debugTree]))
@@ -60,6 +87,24 @@ android {
6087
"outputs/code-coverage/connected/*coverage.ec"
6188
]))
6289
}
90+
91+
packaging {
92+
resources {
93+
excludes += '/META-INF/{AL2.0,LGPL2.1}'
94+
}
95+
}
96+
97+
testOptions {
98+
unitTests.returnDefaultValues = true
99+
}
100+
101+
lintOptions {
102+
abortOnError false
103+
}
104+
105+
publishing {
106+
singleVariant("release")
107+
}
63108
}
64109

65110
repositories {
@@ -68,12 +113,22 @@ repositories {
68113
}
69114

70115
dependencies {
116+
implementation 'androidx.core:core-ktx:1.13.1'
117+
118+
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.4'
119+
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.7.3'
120+
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-play-services:1.6.4'
121+
implementation 'com.google.android.gms:play-services-location:21.3.0'
122+
implementation 'com.google.android.gms:play-services-base:18.5.0'
123+
implementation 'androidx.activity:activity:1.6.0'
124+
implementation 'androidx.activity:activity-ktx:1.9.3'
71125

72-
implementation 'androidx.core:core-ktx:1.7.0'
73-
implementation 'androidx.appcompat:appcompat:1.4.1'
74-
implementation 'com.google.android.material:material:1.5.0'
75-
implementation 'androidx.constraintlayout:constraintlayout:2.1.3'
76126
testImplementation 'junit:junit:4.13.2'
77-
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
78-
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
127+
testImplementation 'io.mockk:mockk:1.13.4'
128+
testImplementation 'app.cash.turbine:turbine:1.2.0'
129+
testImplementation 'org.jetbrains.kotlinx:kotlinx-coroutines-test:1.7.3'
79130
}
131+
132+
if (System.getenv("SHOULD_PUBLISH") == "true") {
133+
apply from: file("./scripts/publish-module.gradle")
134+
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#Fri Apr 08 08:58:08 WEST 2022
22
distributionBase=GRADLE_USER_HOME
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.2-bin.zip
44
distributionPath=wrapper/dists
55
zipStorePath=wrapper/dists
66
zipStoreBase=GRADLE_USER_HOME

pom.xml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?xml version="1.0" encoding="iso-8859-1"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
4+
http://maven.apache.org/maven-v4_0_0.xsd">
5+
6+
<modelVersion>4.0.0</modelVersion>
7+
<groupId>com.outsystems</groupId>
8+
<artifactId>osgeolocation-android</artifactId>
9+
<version>0.0.1</version>
10+
</project>

pull_request_template.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
## Description
2+
<!--- Describe your changes in detail -->
3+
4+
## Context
5+
<!--- Why is this change required? What problem does it solve? -->
6+
<!--- Place the link to the issue here -->
7+
8+
## Type of changes
9+
<!--- What types of changes does your code introduce? Put an `x` in all the boxes that apply -->
10+
- [ ] Fix (non-breaking change which fixes an issue)
11+
- [ ] Feature (non-breaking change which adds functionality)
12+
- [ ] Refactor (cosmetic changes)
13+
- [ ] Breaking change (change that would cause existing functionality to not work as expected)
14+
15+
## Platforms affected
16+
- [ ] Android
17+
- [ ] iOS
18+
- [ ] JavaScript
19+
20+
## Tests
21+
<!--- Describe how you tested your changes in detail -->
22+
<!--- Include details of your test environment if relevant -->
23+
24+
## Screenshots (if appropriate)
25+
26+
## Checklist
27+
<!--- Go over all the following items and put an `x` in all the boxes that apply -->
28+
- [ ] Pull request title follows the format `RNMT-XXXX <title>`
29+
- [ ] Code follows code style of this project
30+
- [ ] CHANGELOG.md file is correctly updated
31+
- [ ] Changes require an update to the documentation
32+
- [ ] Documentation has been updated accordingly

scripts/publish-android.sh

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#!/usr/bin/env bash
2+
3+
ANDROID_PATH=../
4+
LOG_OUTPUT=./tmp/publish-android.txt
5+
THE_VERSION=`sed -n 's/.*<version>\(.*\)<\/version>.*/\1/p' ../pom.xml`
6+
7+
# Get latest io.ionic:portals XML version info
8+
PUBLISHED_URL="https://repo1.maven.org/maven2/com/capacitorjs/geolocationlib-android/maven-metadata.xml"
9+
PUBLISHED_DATA=$(curl -s $PUBLISHED_URL)
10+
PUBLISHED_VERSION="$(perl -ne 'print and last if s/.*<latest>(.*)<\/latest>.*/\1/;' <<< $PUBLISHED_DATA)"
11+
12+
if [[ "$THE_VERSION" == "$PUBLISHED_VERSION" ]]; then
13+
printf %"s\n\n" "Duplicate: a published version exists for $THE_VERSION, skipping..."
14+
else
15+
# Make log dir if doesnt exist
16+
mkdir -p ./tmp
17+
18+
# Export ENV variable used by Gradle for Versioning
19+
export THE_VERSION
20+
export SHOULD_PUBLISH=true
21+
22+
printf %"s\n" "Attempting to build and publish version $THE_VERSION"
23+
"$ANDROID_PATH"/gradlew clean build publishReleasePublicationToSonatypeRepository closeAndReleaseSonatypeStagingRepository --no-daemon --max-workers 1 -b "$ANDROID_PATH"/build.gradle -Pandroid.useAndroidX=true > $LOG_OUTPUT 2>&1
24+
# "$ANDROID_PATH"/gradlew clean build publishReleasePublicationToSonatypeRepository --no-daemon --max-workers 1 -b "$ANDROID_PATH"/build.gradle -Pandroid.useAndroidX=true > $LOG_OUTPUT 2>&1
25+
26+
echo $RESULT
27+
28+
if grep --quiet "BUILD SUCCESSFUL" $LOG_OUTPUT; then
29+
printf %"s\n" "Success: Published to MavenCentral."
30+
else
31+
printf %"s\n" "Error publishing, check $LOG_OUTPUT for more info! Manually review and release from the Sonatype Repository Manager may be necessary https://s01.oss.sonatype.org/"
32+
cat $LOG_OUTPUT
33+
exit 1
34+
fi
35+
36+
fi

scripts/publish-module.gradle

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
apply plugin: 'maven-publish'
2+
apply plugin: 'signing'
3+
4+
def LIB_VERSION = System.getenv('THE_VERSION')
5+
6+
task androidSourcesJar(type: Jar) {
7+
archiveClassifier.set('sources')
8+
//if (project.plugins.findPlugin("com.android.library")) {
9+
from android.sourceSets.main.java.srcDirs
10+
from android.sourceSets.main.kotlin.srcDirs
11+
//} else {
12+
// from sourceSets.main.java.srcDirs
13+
// from sourceSets.main.kotlin.srcDirs
14+
//}
15+
}
16+
17+
artifacts {
18+
archives androidSourcesJar
19+
}
20+
21+
group = 'com.capacitorjs'
22+
version = LIB_VERSION
23+
24+
afterEvaluate {
25+
publishing {
26+
publications {
27+
release(MavenPublication) {
28+
// Coordinates
29+
groupId 'com.capacitorjs'
30+
artifactId 'osgeolocationlib-android'
31+
version LIB_VERSION
32+
33+
// Two artifacts, the `aar` (or `jar`) and the sources
34+
if (project.plugins.findPlugin("com.android.library")) {
35+
from components.release
36+
} else {
37+
artifact("$buildDir/libs/${project.getName()}-${version}.jar")
38+
}
39+
40+
artifact androidSourcesJar
41+
42+
// POM Data
43+
pom {
44+
name = 'geolocationlib-android'
45+
description = 'Geolocation Android Lib'
46+
url = 'https://github.com/ionic-team/outsystems-geolocation/packages/android-lib'
47+
licenses {
48+
license {
49+
name = 'License'
50+
url = 'https://github.com/ionic-team/outsystems-geolocation/blob/main/packages/android-lib/LICENSE'
51+
}
52+
}
53+
developers {
54+
developer {
55+
name = 'Ionic'
56+
57+
}
58+
}
59+
60+
// Version Control Info
61+
scm {
62+
connection = 'scm:git:github.com:ionic-team/outsystems-geolocation.git'
63+
developerConnection = 'scm:git:ssh://github.com:ionic-team/outsystems-geolocation.git'
64+
url = 'https://github.com/ionic-team/outsystems-geolocation/tree/main'
65+
}
66+
}
67+
}
68+
}
69+
}
70+
}
71+
72+
signing {
73+
useInMemoryPgpKeys(
74+
rootProject.ext["signing.keyId"],
75+
rootProject.ext["signing.key"],
76+
rootProject.ext["signing.password"],
77+
)
78+
sign publishing.publications
79+
}

scripts/publish-root.gradle

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
// Create variables with empty default values
2+
ext["signing.keyId"] = ''
3+
ext["signing.key"] = ''
4+
ext["signing.password"] = ''
5+
ext["ossrhUsername"] = ''
6+
ext["ossrhPassword"] = ''
7+
ext["sonatypeStagingProfileId"] = ''
8+
9+
File secretPropsFile = file('./local.properties')
10+
if (secretPropsFile.exists()) {
11+
// Read local.properties file first if it exists
12+
Properties p = new Properties()
13+
new FileInputStream(secretPropsFile).withCloseable { is -> p.load(is) }
14+
p.each { name, value -> ext[name] = value }
15+
} else {
16+
// Use system environment variables
17+
ext["ossrhUsername"] = System.getenv('ANDROID_OSSRH_USERNAME')
18+
ext["ossrhPassword"] = System.getenv('ANDROID_OSSRH_PASSWORD')
19+
ext["sonatypeStagingProfileId"] = System.getenv('ANDROID_SONATYPE_STAGING_PROFILE_ID')
20+
ext["signing.keyId"] = System.getenv('ANDROID_SIGNING_KEY_ID')
21+
ext["signing.key"] = System.getenv('ANDROID_SIGNING_KEY')
22+
ext["signing.password"] = System.getenv('ANDROID_SIGNING_PASSWORD')
23+
}
24+
25+
// Set up Sonatype repository
26+
nexusPublishing {
27+
repositories {
28+
sonatype {
29+
stagingProfileId = sonatypeStagingProfileId
30+
username = ossrhUsername
31+
password = ossrhPassword
32+
nexusUrl.set(uri("https://s01.oss.sonatype.org/service/local/"))
33+
snapshotRepositoryUrl.set(uri("https://s01.oss.sonatype.org/content/repositories/snapshots/"))
34+
}
35+
}
36+
repositoryDescription = 'OSGeolocation Lib v' + System.getenv('THE_VERSION')
37+
}

0 commit comments

Comments
 (0)