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

Integrate Android example #275

Merged
merged 19 commits into from
May 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
cb6836c
Draft efforts to enable Android build
Nashatyrev May 10, 2023
ab98005
Update
Nashatyrev May 10, 2023
2890119
Builds but don't compile MainActivity.kt
Nashatyrev May 11, 2023
2720887
AndroidManifest.xml: remove deprecated package attribute
Nashatyrev May 11, 2023
adeae9b
Upgrade Gradle to 8.0
Nashatyrev May 11, 2023
7b40ccf
Update gradle builds. Running Android example with Java11 and Android…
Nashatyrev May 11, 2023
0727e73
Minor cleanup in the main build.gradle
Nashatyrev May 11, 2023
21fed29
[build+run] Upgrade com.android.application from 7.3.1 to 7.4.2 (get …
Nashatyrev May 11, 2023
94dbb70
Move repositories declaration to settings.gradle
Nashatyrev May 11, 2023
edbe457
Exclude common gradle configuration by property rather than project name
Nashatyrev May 11, 2023
2ab69dc
Set Kotlin jvm target for android module
Nashatyrev May 12, 2023
e6f37ce
com.android.application plugin 'apply' method works for some reason h…
Nashatyrev May 12, 2023
ba01810
Prevent build fail due to android.targetSdkVersion = 30
Nashatyrev May 12, 2023
31aee3a
Remove obsolete dependency
Nashatyrev May 12, 2023
5201210
Detect Android SDK and conditionally include :examples:android-chatte…
Nashatyrev May 15, 2023
9f738c6
Merge remote-tracking branch 'origin/develop' into feature/integrate-…
Nashatyrev May 15, 2023
4f569cc
Fix formatting
Nashatyrev May 15, 2023
8523756
Add GitHub action to setup Android SDK
Nashatyrev May 15, 2023
832f54e
Change line endings to LF
Nashatyrev May 15, 2023
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
3 changes: 3 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,8 @@ jobs:
- name: Setup Gradle
uses: gradle/gradle-build-action@v2

- name: Setup Android SDK
uses: android-actions/setup-android@v2

- name: Execute Gradle build
run: ./gradlew -s build dokkaJar
25 changes: 17 additions & 8 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ import java.net.URL
description = "a minimal implementation of libp2p for the jvm"

plugins {
kotlin("jvm").version("1.6.21")
val kotlinVersion = "1.6.21"

id("org.jetbrains.kotlin.jvm") version kotlinVersion apply false

id("com.github.ben-manes.versions").version("0.44.0")
id("idea")
Expand All @@ -19,28 +21,35 @@ plugins {
id("org.jmailen.kotlinter").version("3.10.0")
id("java-test-fixtures")
id("io.spring.dependency-management").version("1.1.0")

id("org.jetbrains.kotlin.android") version kotlinVersion apply false
id("com.android.application") version "7.4.2" apply false
}

allprojects {
fun Project.getBooleanPropertyOrFalse(propName: String) =
(this.properties[propName] as? String)?.toBoolean() ?: false

configure(
allprojects
.filterNot {
it.getBooleanPropertyOrFalse("libp2p.gradle.custom")
}
) {
group = "io.libp2p"
version = "develop"

apply(plugin = "kotlin")
apply(plugin = "idea")
apply(plugin = "io.gitlab.arturbosch.detekt")
apply(plugin = "java")

apply(plugin = "io.gitlab.arturbosch.detekt")
apply(plugin = "maven-publish")
apply(plugin = "org.jetbrains.dokka")
apply(plugin = "org.jmailen.kotlinter")
apply(plugin = "java-test-fixtures")
apply(plugin = "io.spring.dependency-management")
apply(from = "$rootDir/versions.gradle")

repositories {
mavenCentral()
maven("https://artifacts.consensys.net/public/maven/maven/")
}

dependencies {

implementation(kotlin("stdlib-jdk8"))
Expand Down
58 changes: 23 additions & 35 deletions examples/android-chatter/build.gradle
Original file line number Diff line number Diff line change
@@ -1,32 +1,16 @@
buildscript {
ext.kotlin_version = '1.3.50'
repositories {
google()
jcenter()
apply plugin: "com.android.application"
apply plugin: "org.jetbrains.kotlin.android"

}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.3'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}

repositories {
google()
}

apply plugin: 'com.android.application'

apply plugin: 'kotlin-android'

apply plugin: 'kotlin-android-extensions'
apply plugin: "io.spring.dependency-management"
apply from: "$rootDir/versions.gradle"

android {
compileSdkVersion 28
namespace = "io.libp2p.example.chat"
compileSdkVersion 30
defaultConfig {
applicationId "io.libp2p.example.chatter"
minSdkVersion 28
targetSdkVersion 28
applicationId "io.libp2p.example.chat"
minSdkVersion 26
targetSdkVersion 30
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
Expand All @@ -38,20 +22,24 @@ android {
}
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/io.netty.versions.properties'
exclude 'META-INF/INDEX.LIST'
}
kotlinOptions {
jvmTarget = "11"
}
compileOptions {
sourceCompatibility = 1.8
targetCompatibility = 1.8
sourceCompatibility = 1.11
targetCompatibility = 1.11
}
lint {
abortOnError = false
}
}

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation"org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.core:core-ktx:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation project(':chatter')
annotationProcessor 'org.apache.logging.log4j:log4j-core:2.11.2'
implementation("androidx.appcompat:appcompat:1.2.0")
implementation("com.google.android.material:material:1.2.0")
implementation("androidx.constraintlayout:constraintlayout:2.0.4")
implementation project(':examples:chatter')
}
1 change: 1 addition & 0 deletions examples/android-chatter/gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
libp2p.gradle.custom = true
3 changes: 1 addition & 2 deletions examples/android-chatter/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="io.libp2p.example.chat">
<manifest xmlns:android="http://schemas.android.com/apk/res/android">

<application
android:allowBackup="true"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import android.widget.TextView
import androidx.appcompat.app.AppCompatActivity
import java.util.concurrent.CompletableFuture.runAsync


class MainActivity : AppCompatActivity() {
private lateinit var chatScroller: ScrollView
private lateinit var chatWindow: TextView
Expand Down
3 changes: 2 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
kotlin.code.style=official

org.gradle.jvmargs=-Xmx1G
org.gradle.jvmargs=-Xmx1G
android.useAndroidX=true
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Thu May 11 18:05:55 GST 2023
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionSha256Sum=7ba68c54029790ab444b39d7e293d3236b2632631fb5f2e012bb28b4ff669e4b
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Loading