Skip to content

Commit 713ec2d

Browse files
committed
rgb-lib-kotlin is here
0 parents  commit 713ec2d

18 files changed

+808
-0
lines changed

Diff for: .gitignore

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
/.idea
2+
/local.properties
3+
**/.gradle
4+
**/build
5+
/android/src/main/jniLibs
6+
/android/src/main/kotlin

Diff for: .gitmodules

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule "rgb-lib"]
2+
path = rgb-lib
3+
url = https://github.com/RGB-Tools/rgb-lib.git

Diff for: LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2022 RGB-Tools developers
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.

Diff for: README.md

+63
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
# RGB Lib Kotlin bindings
2+
3+
This project builds an Android library, `rgb-lib-android`, for the [rgb-lib]
4+
Rust library, which is included as a git submodule. The bindings are created by
5+
the [rgb-lib-ffi] project, which in located inside the rgb-lib submodule.
6+
7+
## Usage
8+
9+
To use the Kotlin library add the following to your project gradle dependencies:
10+
11+
```groovy
12+
repositories {
13+
mavenCentral()
14+
}
15+
16+
dependencies {
17+
implementation 'org.rgbtools:rgb-lib-android:<version>'
18+
}
19+
```
20+
21+
## Contributing
22+
23+
### Build
24+
25+
In order to build the project, setup the following environment variables:
26+
- `ANDROID_SDK_ROOT` (e.g. `export ANDROID_SDK_ROOT=~/Android/Sdk`)
27+
- `ANDROID_NDK_ROOT` (e.g. `export ANDROID_NDK_ROOT=$ANDROID_SDK_ROOT/ndk/21.<NDK_VERSION>`)
28+
29+
Then, clone this project and run:
30+
31+
```bash
32+
git submodule update --init
33+
./gradlew :android:buildAndroidLib
34+
```
35+
36+
### Publish
37+
38+
#### To local Maven repository
39+
40+
In order to publish the library to your local Maven repository:
41+
42+
```bash
43+
./gradlew :android:publishToMavenLocal --exclude-task signMavenPublication
44+
```
45+
46+
#### To Maven Central repository (project maintainers only)
47+
48+
Set your `~/.gradle/gradle.properties` signing key values and SONATYPE login
49+
```properties
50+
signing.gnupg.keyName=<YOUR_GNUPG_ID>
51+
signing.gnupg.passphrase=<YOUR_GNUPG_PASSPHRASE>
52+
53+
ossrhUserName=<YOUR_SONATYPE_USERNAME>
54+
ossrhPassword=<YOUR_SONATYPE_PASSWORD>
55+
```
56+
and then publish by running:
57+
```shell
58+
./gradlew :android:publishToSonatype closeAndReleaseSonatypeStagingRepository
59+
```
60+
61+
62+
[rgb-lib]: https://github.com/RGB-Tools/rgb-lib
63+
[rgb-lib-ffi]: https://github.com/RGB-Tools/rgb-lib/tree/master/rgb-lib-ffi

Diff for: android/build.gradle.kts

+92
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
plugins {
2+
id("com.android.library")
3+
id("kotlin-android")
4+
id("maven-publish")
5+
id("signing")
6+
7+
// Custom plugin to generate the native libs and bindings file
8+
id("org.rgbtools.plugins.generate-android-bindings")
9+
}
10+
11+
android {
12+
compileSdk = 31
13+
14+
defaultConfig {
15+
minSdk = 21
16+
targetSdk = 31
17+
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
18+
consumerProguardFiles("consumer-rules.pro")
19+
}
20+
21+
buildTypes {
22+
getByName("release") {
23+
isMinifyEnabled = false
24+
proguardFiles(file("proguard-android-optimize.txt"), file("proguard-rules.pro"))
25+
}
26+
}
27+
28+
publishing {
29+
singleVariant("release") {
30+
withSourcesJar()
31+
withJavadocJar()
32+
}
33+
}
34+
}
35+
36+
dependencies {
37+
implementation("net.java.dev.jna:jna:5.8.0@aar")
38+
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk7")
39+
implementation("androidx.appcompat:appcompat:1.4.0")
40+
implementation("androidx.core:core-ktx:1.7.0")
41+
api("org.slf4j:slf4j-api:1.7.30")
42+
43+
androidTestImplementation("com.github.tony19:logback-android:2.0.0")
44+
androidTestImplementation("androidx.test.ext:junit:1.1.3")
45+
androidTestImplementation("androidx.test.espresso:espresso-core:3.4.0")
46+
androidTestImplementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.4.1")
47+
}
48+
49+
afterEvaluate {
50+
publishing {
51+
publications {
52+
create<MavenPublication>("maven") {
53+
groupId = "org.rgbtools"
54+
artifactId = "rgb-lib-android"
55+
version = "0.1.0-SNAPSHOT"
56+
from(components["release"])
57+
pom {
58+
name.set("rgb-lib-android")
59+
description.set("RGB Lib Kotlin language bindings.")
60+
licenses {
61+
license {
62+
name.set("MIT")
63+
url.set("https://spdx.org/licenses/MIT.html")
64+
}
65+
}
66+
developers {
67+
developer {
68+
id.set("zoedberg")
69+
name.set("Zoe Faltibà")
70+
email.set("[email protected]")
71+
}
72+
developer {
73+
id.set("nicbus")
74+
name.set("Nicola Busanello")
75+
email.set("[email protected]")
76+
}
77+
}
78+
scm {
79+
connection.set("scm:git:github.com/RGB-Tools/rgb-lib-kotlin.git")
80+
developerConnection.set("scm:git:ssh://github.com/RGB-Tools/rgb-lib-kotlin.git")
81+
url.set("https://github.com/RGB-Tools/rgb-lib-kotlin")
82+
}
83+
}
84+
}
85+
}
86+
}
87+
}
88+
89+
signing {
90+
useGpgCmd()
91+
sign(publishing.publications)
92+
}

Diff for: android/proguard-rules.pro

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Add project specific ProGuard rules here.
2+
# You can control the set of applied configuration files using the
3+
# proguardFiles setting in build.gradle.
4+
#
5+
# For more details, see
6+
# http://developer.android.com/guide/developing/tools/proguard.html
7+
8+
# If your project uses WebView with JS, uncomment the following
9+
# and specify the fully qualified class name to the JavaScript interface
10+
# class:
11+
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12+
# public *;
13+
#}
14+
15+
# Uncomment this to preserve the line number information for
16+
# debugging stack traces.
17+
#-keepattributes SourceFile,LineNumberTable
18+
19+
# If you keep the line number information, uncomment this to
20+
# hide the original source file name.
21+
#-renamesourcefileattribute SourceFile
22+
23+
# for JNA
24+
-dontwarn java.awt.*
25+
-keep class com.sun.jna.* { *; }
26+
-keep class org.rgbtools.* { *; }
27+
-keepclassmembers class * extends org.rgbtools.* { public *; }
28+
-keepclassmembers class * extends com.sun.jna.* { public *; }

Diff for: android/src/main/AndroidManifest.xml

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
2+
package="org.rgbtools">
3+
4+
<uses-permission android:name="android.permission.INTERNET" />
5+
6+
</manifest>

Diff for: build.gradle.kts

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
buildscript {
2+
repositories {
3+
google()
4+
mavenCentral()
5+
}
6+
dependencies {
7+
classpath("com.android.tools.build:gradle:7.1.2")
8+
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.10")
9+
}
10+
}
11+
12+
plugins {
13+
id("signing")
14+
id("maven-publish")
15+
id("io.github.gradle-nexus.publish-plugin") version "1.1.0"
16+
}
17+
18+
signing {
19+
val signingKey: String? by project
20+
val signingPassword: String? by project
21+
useInMemoryPgpKeys(signingKey, signingPassword)
22+
sign(publishing.publications)
23+
}
24+
25+
group = "org.rgbtools"
26+
27+
nexusPublishing {
28+
repositories {
29+
create("sonatype") {
30+
nexusUrl.set(uri("https://s01.oss.sonatype.org/service/local/"))
31+
snapshotRepositoryUrl.set(uri("https://s01.oss.sonatype.org/content/repositories/snapshots/"))
32+
33+
val ossrhUsername: String? by project
34+
val ossrhPassword: String? by project
35+
username.set(ossrhUsername)
36+
password.set(ossrhPassword)
37+
}
38+
}
39+
}
40+
41+
allprojects {
42+
repositories {
43+
google()
44+
mavenCentral()
45+
}
46+
}

Diff for: buildSrc/build.gradle.kts

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
plugins {
2+
`kotlin-dsl`
3+
}
4+
5+
repositories {
6+
mavenCentral()
7+
}
+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package org.rgbtools.plugins
2+
3+
4+
val operatingSystem: OS = when {
5+
System.getProperty("os.name").contains("mac", ignoreCase = true) -> OS.MAC
6+
System.getProperty("os.name").contains("linux", ignoreCase = true) -> OS.LINUX
7+
else -> OS.OTHER
8+
}
9+
10+
enum class OS {
11+
MAC,
12+
LINUX,
13+
OTHER,
14+
}

0 commit comments

Comments
 (0)