diff --git a/.gitignore b/.gitignore index 119fe4f..35345fd 100644 --- a/.gitignore +++ b/.gitignore @@ -1,174 +1,13 @@ -# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider -# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 - -# User-specific stuff -.idea/**/workspace.xml -.idea/**/tasks.xml -.idea/**/usage.statistics.xml -.idea/**/dictionaries -.idea/**/shelf - -# Generated files -.idea/**/contentModel.xml - -# Sensitive or high-churn files -.idea/**/dataSources/ -.idea/**/dataSources.ids -.idea/**/dataSources.local.xml -.idea/**/sqlDataSources.xml -.idea/**/dynamic.xml -.idea/**/uiDesigner.xml -.idea/**/dbnavigator.xml - -# Gradle -.idea/**/gradle.xml -.idea/**/libraries -.gradle/ - -# Gradle and Maven with auto-import -# When using Gradle or Maven with auto-import, you should exclude module files, -# since they will be recreated, and may cause churn. Uncomment if using -# auto-import. -# .idea/artifacts -# .idea/compiler.xml -# .idea/jarRepositories.xml -# .idea/modules.xml -# .idea/*.iml -# .idea/modules -# *.iml -# *.ipr - -# CMake -cmake-build-*/ - -# Mongo Explorer plugin -.idea/**/mongoSettings.xml - -# File-based project format -*.iws - -# IntelliJ -out/ - -# mpeltonen/sbt-idea plugin -.idea_modules/ - -# JIRA plugin -atlassian-ide-plugin.xml - -# Cursive Clojure plugin -.idea/replstate.xml - -# Crashlytics plugin (for Android Studio and IntelliJ) -com_crashlytics_export_strings.xml -crashlytics.properties -crashlytics-build.properties -fabric.properties - -# Editor-based Rest Client -.idea/httpRequests - -# Android studio 3.1+ serialized cache file -.idea/caches/build_file_checksums.ser - -# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider -# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 - -# User-specific stuff -.idea/**/workspace.xml -.idea/**/tasks.xml -.idea/**/usage.statistics.xml -.idea/**/dictionaries -.idea/**/shelf - -# Generated files -.idea/**/contentModel.xml - -# Sensitive or high-churn files -.idea/**/dataSources/ -.idea/**/dataSources.ids -.idea/**/dataSources.local.xml -.idea/**/sqlDataSources.xml -.idea/**/dynamic.xml -.idea/**/uiDesigner.xml -.idea/**/dbnavigator.xml - -# Gradle -.idea/**/gradle.xml -.idea/**/libraries - -# Gradle and Maven with auto-import -# When using Gradle or Maven with auto-import, you should exclude module files, -# since they will be recreated, and may cause churn. Uncomment if using -# auto-import. -# .idea/artifacts -# .idea/compiler.xml -# .idea/jarRepositories.xml -# .idea/modules.xml -# .idea/*.iml -# .idea/modules -# *.iml -# *.ipr - -# CMake -cmake-build-*/ - -# Mongo Explorer plugin -.idea/**/mongoSettings.xml - -# File-based project format -*.iws - -# IntelliJ -out/ - -# mpeltonen/sbt-idea plugin -.idea_modules/ - -# JIRA plugin -atlassian-ide-plugin.xml - -# Cursive Clojure plugin -.idea/replstate.xml - -# Crashlytics plugin (for Android Studio and IntelliJ) -com_crashlytics_export_strings.xml -crashlytics.properties -crashlytics-build.properties -fabric.properties - -# Editor-based Rest Client -.idea/httpRequests - -# Android studio 3.1+ serialized cache file -.idea/caches/build_file_checksums.ser - -# Xcode -# -# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore - -## User settings +*.iml +.gradle +.idea +.DS_Store +build +*/build +captures +.externalNativeBuild +.cxx +local.properties xcuserdata/ - -## compatibility with Xcode 8 and earlier (ignoring not required starting Xcode 9) -*.xcscmblueprint -*.xccheckout - -## compatibility with Xcode 3 and earlier (ignoring not required starting Xcode 4) -build/ -DerivedData/ -*.moved-aside -*.pbxuser -!default.pbxuser -*.mode1v3 -!default.mode1v3 -*.mode2v3 -!default.mode2v3 -*.perspectivev3 -!default.perspectivev3 - -## Gcc Patch -/*.gcno - -# Cocoapods Pods/ +*.gpg \ No newline at end of file diff --git a/.gitmodules b/.gitmodules deleted file mode 100644 index c274d97..0000000 --- a/.gitmodules +++ /dev/null @@ -1,3 +0,0 @@ -[submodule "Reachability"] - path = Reachability - url = https://github.com/tonymillion/Reachability diff --git a/.idea/.gitignore b/.idea/.gitignore deleted file mode 100644 index 26d3352..0000000 --- a/.idea/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -# Default ignored files -/shelf/ -/workspace.xml diff --git a/.idea/artifacts/kotlin_connectivity_manager_jvm_1_0.xml b/.idea/artifacts/kotlin_connectivity_manager_jvm_1_0.xml deleted file mode 100644 index 1e42697..0000000 --- a/.idea/artifacts/kotlin_connectivity_manager_jvm_1_0.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - $PROJECT_DIR$/build/libs - - - - - \ No newline at end of file diff --git a/.idea/compiler.xml b/.idea/compiler.xml deleted file mode 100644 index 89959c8..0000000 --- a/.idea/compiler.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/jarRepositories.xml b/.idea/jarRepositories.xml deleted file mode 100644 index 0380d8d..0000000 --- a/.idea/jarRepositories.xml +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml deleted file mode 100644 index 4bc4fc6..0000000 --- a/.idea/misc.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - - \ No newline at end of file diff --git a/.idea/modules/kotlin-connectivity-manager.jvmMain.iml b/.idea/modules/kotlin-connectivity-manager.jvmMain.iml deleted file mode 100644 index e046a17..0000000 --- a/.idea/modules/kotlin-connectivity-manager.jvmMain.iml +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/modules/multiplatform-connectivity-status.iml b/.idea/modules/multiplatform-connectivity-status.iml deleted file mode 100644 index 23cf9d4..0000000 --- a/.idea/modules/multiplatform-connectivity-status.iml +++ /dev/null @@ -1,29 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/modules/untitled.commonMain.iml b/.idea/modules/untitled.commonMain.iml deleted file mode 100644 index e6ada46..0000000 --- a/.idea/modules/untitled.commonMain.iml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/modules/untitled.commonTest.iml b/.idea/modules/untitled.commonTest.iml deleted file mode 100644 index d5f5dcd..0000000 --- a/.idea/modules/untitled.commonTest.iml +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/modules/untitled.iosArm64Main.iml b/.idea/modules/untitled.iosArm64Main.iml deleted file mode 100644 index a6cdef1..0000000 --- a/.idea/modules/untitled.iosArm64Main.iml +++ /dev/null @@ -1,305 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/modules/untitled.iosArm64Test.iml b/.idea/modules/untitled.iosArm64Test.iml deleted file mode 100644 index a874b75..0000000 --- a/.idea/modules/untitled.iosArm64Test.iml +++ /dev/null @@ -1,322 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/modules/untitled.iosX64Main.iml b/.idea/modules/untitled.iosX64Main.iml deleted file mode 100644 index 5bb0860..0000000 --- a/.idea/modules/untitled.iosX64Main.iml +++ /dev/null @@ -1,305 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/modules/untitled.iosX64Test.iml b/.idea/modules/untitled.iosX64Test.iml deleted file mode 100644 index 0bf2f4a..0000000 --- a/.idea/modules/untitled.iosX64Test.iml +++ /dev/null @@ -1,322 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/multiplatform-connectivity-status.iml b/.idea/multiplatform-connectivity-status.iml deleted file mode 100644 index feede99..0000000 --- a/.idea/multiplatform-connectivity-status.iml +++ /dev/null @@ -1,106 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml deleted file mode 100644 index b311b04..0000000 --- a/.idea/vcs.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/README.md b/README.md index 7e27173..dc64f87 100644 --- a/README.md +++ b/README.md @@ -1,26 +1,22 @@ # Multiplatform connectivity status -This small Kotlin multiplatform mobile library allows monitoring the internet connection of the device. You can use it from shared code as well as directly from Android or iOS code. +This Kotlin multiplatform mobile utility library allows monitoring the internet connection status of the device. You can use it from shared code as well as directly from Android or iOS code. +The project structure is taken from [this well explained and detailed tutorial](https://dev.to/kotlin/how-to-build-and-publish-a-kotlin-multiplatform-library-creating-your-first-library-1bp8 +). ## Installation -Clone the repo and run the following command: -``` -./gradlew publishToMavenLocal -``` - -With that, you publish the library locally on your machine. Afterwards you need to add `mavenLocal` to your repositories: +Add `mavenCentral()` to your repositories: ``` kotlin buildscript { repositories { // ... other repositories mavenCentral() - mavenLocal() } } ``` -Then you can add the library to your project: +Add the library to your project: ``` kotlin kotlin { android() @@ -29,7 +25,7 @@ kotlin { sourceSets { val commonMain by getting { dependencies { - implementation("com.github.ln-12:multiplatform-connectivity-status:1.0") + implementation("com.github.ln-12:multiplatform-connectivity-status:1.0.0") } } } @@ -46,7 +42,7 @@ end ## Usage ``` kotlin -// get the satus object +// get the satus object, on Android provide a context val connectivityStatus = ConnectivityStatus() // output changes @@ -65,12 +61,7 @@ connectivityStatus.stop() ## Sample -To run the sample you need to clone the repo and run -``` -./gradlew publishToMavenLocal -``` - -Then run the sample apps inside the [sample](./sample) directory. +You can find a sample Android and iOS app inside the [sample](./sample) directory. ## License diff --git a/build.gradle.kts b/build.gradle.kts index b6af803..46743f9 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,12 +1,12 @@ plugins { id("com.android.library") - kotlin("multiplatform") version "1.4.21" - kotlin("native.cocoapods") version "1.4.21" - id("maven-publish") + kotlin("native.cocoapods") version "1.4.30" + kotlin("multiplatform") version "1.4.30" + id("convention.publication") } group = "com.github.ln-12" -version = "1.0" +version = "1.0.0" repositories { google() @@ -16,15 +16,18 @@ repositories { kotlin { android { - publishAllLibraryVariants() - } + compilations.all { + kotlinOptions.jvmTarget = "1.8" + } + publishLibraryVariants("release", "debug") + } ios() sourceSets { val commonMain by getting { dependencies { - api("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.4.2-native-mt") + implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.4.3-native-mt") } } val commonTest by getting { @@ -33,6 +36,7 @@ kotlin { implementation(kotlin("test-annotations-common")) } } + val androidMain by getting val androidTest by getting { dependencies { @@ -40,6 +44,7 @@ kotlin { implementation("junit:junit:4.13.1") } } + val iosMain by getting val iosTest by getting } @@ -70,55 +75,4 @@ kotlin.metadata { compilations.matching { it.name == "iosMain" }.all { compileKotlinTaskProvider.configure { enabled = false } } -} - -// taken from: https://serpro69.medium.com/publishing-a-kotlin-library-to-your-bintray-repo-using-gradle-kotlin-dsl-bdeaed54571a -val artifactName = project.name -val artifactGroup = project.group.toString() -val artifactVersion = project.version.toString() - -val pomUrl = "https://github.com/ln-12/multiplatform-connectivity-status" -val pomScmUrl = "https://github.com/ln-12/multiplatform-connectivity-status" -val pomIssueUrl = "https://github.com/ln-12/multiplatform-connectivity-status/issues" -val pomDesc = "A Kotlin multiplatform mobile library to monitor the connectivity status of the device" - -val githubRepoName = "ln-12/multiplatform-connectivity-status" -val githubReadme = "README.md" - -val pomLicenseName = "Apache-2.0" -val pomLicenseUrl = "http://www.apache.org/licenses/LICENSE-2.0" -val pomLicenseDist = "repo" - -val pomDeveloperId = "ln-12" -val pomDeveloperName = "Lorenzo Neumann" - -publishing { - publications { - publications.withType().all { - groupId = artifactGroup - artifactId = artifactName - version = artifactVersion - - pom.withXml { - asNode().apply { - appendNode("description", pomDesc) - appendNode("name", rootProject.name) - appendNode("url", pomUrl) - appendNode("licenses").appendNode("license").apply { - appendNode("name", pomLicenseName) - appendNode("url", pomLicenseUrl) - appendNode("distribution", pomLicenseDist) - } - appendNode("developers").appendNode("developer").apply { - appendNode("id", pomDeveloperId) - appendNode("name", pomDeveloperName) - } - appendNode("scm").apply { - appendNode("url", pomScmUrl) - } - } - } - } - } -} - +} \ No newline at end of file diff --git a/convention-plugins/build.gradle.kts b/convention-plugins/build.gradle.kts new file mode 100644 index 0000000..c5a80b7 --- /dev/null +++ b/convention-plugins/build.gradle.kts @@ -0,0 +1,7 @@ +plugins { + `kotlin-dsl` // Is needed to turn our build logic written in Kotlin into Gralde Plugin +} + +repositories { + gradlePluginPortal() // To use 'maven-publish' and 'signing' plugins in our own plugin +} \ No newline at end of file diff --git a/convention-plugins/src/main/kotlin/convention.publication.gradle.kts b/convention-plugins/src/main/kotlin/convention.publication.gradle.kts new file mode 100644 index 0000000..ac7f865 --- /dev/null +++ b/convention-plugins/src/main/kotlin/convention.publication.gradle.kts @@ -0,0 +1,91 @@ +import org.gradle.api.publish.maven.MavenPublication +import org.gradle.api.tasks.bundling.Jar +import org.gradle.kotlin.dsl.`maven-publish` +import org.gradle.kotlin.dsl.signing +import java.util.* + +plugins { + `maven-publish` + signing +} + +// Stub secrets to let the project sync and build without the publication values set up +ext["signing.keyId"] = null +ext["signing.password"] = null +ext["signing.secretKeyRingFile"] = null +ext["ossrhUsername"] = null +ext["ossrhPassword"] = null + +// Grabbing secrets from local.properties file or from environment variables, which could be used on CI +val secretPropsFile = project.rootProject.file("local.properties") +if (secretPropsFile.exists()) { + secretPropsFile.reader().use { + Properties().apply { + load(it) + } + }.onEach { (name, value) -> + ext[name.toString()] = value + } +} else { + ext["signing.keyId"] = System.getenv("SIGNING_KEY_ID") + ext["signing.password"] = System.getenv("SIGNING_PASSWORD") + ext["signing.secretKeyRingFile"] = System.getenv("SIGNING_SECRET_KEY_RING_FILE") + ext["ossrhUsername"] = System.getenv("OSSRH_USERNAME") + ext["ossrhPassword"] = System.getenv("OSSRH_PASSWORD") +} + +val javadocJar by tasks.registering(Jar::class) { + archiveClassifier.set("javadoc") +} + +fun getExtraString(name: String) = ext[name]?.toString() + +publishing { + // Configure maven central repository + repositories { + maven { + name = "sonatype" + setUrl("https://oss.sonatype.org/service/local/staging/deploy/maven2") + credentials { + username = getExtraString("ossrhUsername") + password = getExtraString("ossrhPassword") + } + } + } + + // Configure all publications + publications.withType { + + // Stub javadoc.jar artifact + artifact(javadocJar.get()) + + // Provide artifacts information requited by Maven Central + pom { + name.set("multiplatform-connectivity-status") + description.set("A Kotlin multiplatform mobile library to monitor the connectivity status of the device") + url.set("https://github.com/ln-12/multiplatform-connectivity-status") + + licenses { + license { + name.set("Apache-2.0") + url.set("http://www.apache.org/licenses/LICENSE-2.0") + } + } + developers { + developer { + id.set("LN-12") + name.set("Lorenzo Neumann") + email.set("lorenzo.neumann96@gmail.com") + } + } + scm { + url.set("https://github.com/ln-12/multiplatform-connectivity-status") + } + } + } +} + +// Signing artifacts. Signing.* extra properties values will be used +signing { + sign(publishing.publications) +} diff --git a/gradle.properties b/gradle.properties index b4b8ed2..b18e3ad 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,4 +1,4 @@ kotlin.code.style=official kotlin.mpp.enableGranularSourceSetsMetadata=true kotlin.native.enableDependencyPropagation=false -android.useAndroidX=true +kotlin.js.generate.executable.default=false diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index da9702f..12d38de 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-6.8-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-6.6.1-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/gradlew.bat b/gradlew.bat index 107acd3..ac1b06f 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -1,89 +1,89 @@ -@rem -@rem Copyright 2015 the original author or authors. -@rem -@rem Licensed under the Apache License, Version 2.0 (the "License"); -@rem you may not use this file except in compliance with the License. -@rem You may obtain a copy of the License at -@rem -@rem https://www.apache.org/licenses/LICENSE-2.0 -@rem -@rem Unless required by applicable law or agreed to in writing, software -@rem distributed under the License is distributed on an "AS IS" BASIS, -@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -@rem See the License for the specific language governing permissions and -@rem limitations under the License. -@rem - -@if "%DEBUG%" == "" @echo off -@rem ########################################################################## -@rem -@rem Gradle startup script for Windows -@rem -@rem ########################################################################## - -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal - -set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. -set APP_BASE_NAME=%~n0 -set APP_HOME=%DIRNAME% - -@rem Resolve any "." and ".." in APP_HOME to make it shorter. -for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi - -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" - -@rem Find java.exe -if defined JAVA_HOME goto findJavaFromJavaHome - -set JAVA_EXE=java.exe -%JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto execute - -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:findJavaFromJavaHome -set JAVA_HOME=%JAVA_HOME:"=% -set JAVA_EXE=%JAVA_HOME%/bin/java.exe - -if exist "%JAVA_EXE%" goto execute - -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:execute -@rem Setup the command line - -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar - - -@rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 - -:mainEnd -if "%OS%"=="Windows_NT" endlocal - -:omega +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + +@if "%DEBUG%" == "" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%" == "" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if "%ERRORLEVEL%" == "0" goto execute + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto execute + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* + +:end +@rem End local scope for the variables with windows NT shell +if "%ERRORLEVEL%"=="0" goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 +exit /b 1 + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/kotlin_connectivity_status.podspec b/kotlin_connectivity_status.podspec deleted file mode 100644 index 4df7bb8..0000000 --- a/kotlin_connectivity_status.podspec +++ /dev/null @@ -1,46 +0,0 @@ -Pod::Spec.new do |spec| - spec.name = 'kotlin_connectivity_status' - spec.version = '1.0' - spec.homepage = 'https://github.com/ln-12/multiplatform-connectivity-status' - spec.source = { :git => "Not Published", :tag => "Cocoapods/#{spec.name}/#{spec.version}" } - spec.authors = '' - spec.license = '' - spec.summary = 'A Kotlin multiplatform mobile library to monitor the connectivity status of the device' - - spec.static_framework = true - spec.vendored_frameworks = "build/cocoapods/framework/kotlin_connectivity_status.framework" - spec.libraries = "c++" - spec.module_name = "#{spec.name}_umbrella" - - - - spec.dependency 'Reachability', '3.2' - - spec.pod_target_xcconfig = { - 'KOTLIN_TARGET[sdk=iphonesimulator*]' => 'ios_x64', - 'KOTLIN_TARGET[sdk=iphoneos*]' => 'ios_arm', - 'KOTLIN_TARGET[sdk=watchsimulator*]' => 'watchos_x86', - 'KOTLIN_TARGET[sdk=watchos*]' => 'watchos_arm', - 'KOTLIN_TARGET[sdk=appletvsimulator*]' => 'tvos_x64', - 'KOTLIN_TARGET[sdk=appletvos*]' => 'tvos_arm64', - 'KOTLIN_TARGET[sdk=macosx*]' => 'macos_x64' - } - - spec.script_phases = [ - { - :name => 'Build kotlin_connectivity_status', - :execution_position => :before_compile, - :shell_path => '/bin/sh', - :script => <<-SCRIPT - set -ev - REPO_ROOT="$PODS_TARGET_SRCROOT" - "$REPO_ROOT/gradlew" -p "$REPO_ROOT" ::syncFramework \ - -Pkotlin.native.cocoapods.target=$KOTLIN_TARGET \ - -Pkotlin.native.cocoapods.configuration=$CONFIGURATION \ - -Pkotlin.native.cocoapods.cflags="$OTHER_CFLAGS" \ - -Pkotlin.native.cocoapods.paths.headers="$HEADER_SEARCH_PATHS" \ - -Pkotlin.native.cocoapods.paths.frameworks="$FRAMEWORK_SEARCH_PATHS" - SCRIPT - } - ] -end \ No newline at end of file diff --git a/local.properties b/local.properties deleted file mode 100644 index ae80e3e..0000000 --- a/local.properties +++ /dev/null @@ -1 +0,0 @@ -sdk.dir=/Users/lneumann/Library/Android/sdk diff --git a/multiplatform_connectivity_status.podspec b/multiplatform_connectivity_status.podspec index 2d024fd..d212e8d 100644 --- a/multiplatform_connectivity_status.podspec +++ b/multiplatform_connectivity_status.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |spec| spec.name = 'multiplatform_connectivity_status' - spec.version = '1.0' + spec.version = '1.0.0' spec.homepage = 'https://github.com/ln-12/multiplatform-connectivity-status' spec.source = { :git => "Not Published", :tag => "Cocoapods/#{spec.name}/#{spec.version}" } spec.authors = '' @@ -19,7 +19,7 @@ Pod::Spec.new do |spec| spec.pod_target_xcconfig = { 'KOTLIN_TARGET[sdk=iphonesimulator*]' => 'ios_x64', 'KOTLIN_TARGET[sdk=iphoneos*]' => 'ios_arm', - 'KOTLIN_TARGET[sdk=watchsimulator*]' => 'watchos_x86', + 'KOTLIN_TARGET[sdk=watchsimulator*]' => 'watchos_x64', 'KOTLIN_TARGET[sdk=watchos*]' => 'watchos_arm', 'KOTLIN_TARGET[sdk=appletvsimulator*]' => 'tvos_x64', 'KOTLIN_TARGET[sdk=appletvos*]' => 'tvos_arm64', diff --git a/sample/.idea/.gitignore b/sample/.idea/.gitignore deleted file mode 100644 index 26d3352..0000000 --- a/sample/.idea/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -# Default ignored files -/shelf/ -/workspace.xml diff --git a/sample/.idea/.name b/sample/.idea/.name deleted file mode 100644 index cdf9e23..0000000 --- a/sample/.idea/.name +++ /dev/null @@ -1 +0,0 @@ -ConnectivityStatusSample \ No newline at end of file diff --git a/sample/.idea/compiler.xml b/sample/.idea/compiler.xml deleted file mode 100644 index fb7f4a8..0000000 --- a/sample/.idea/compiler.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/sample/.idea/jarRepositories.xml b/sample/.idea/jarRepositories.xml deleted file mode 100644 index b728d5f..0000000 --- a/sample/.idea/jarRepositories.xml +++ /dev/null @@ -1,35 +0,0 @@ - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/sample/.idea/misc.xml b/sample/.idea/misc.xml deleted file mode 100644 index 54d5acd..0000000 --- a/sample/.idea/misc.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/sample/androidApp/build.gradle.kts b/sample/androidApp/build.gradle.kts index a462f76..d253e40 100644 --- a/sample/androidApp/build.gradle.kts +++ b/sample/androidApp/build.gradle.kts @@ -5,10 +5,10 @@ plugins { dependencies { implementation(project(":shared")) - implementation("com.google.android.material:material:1.2.1") + implementation("com.google.android.material:material:1.3.0") implementation("androidx.appcompat:appcompat:1.2.0") implementation("androidx.constraintlayout:constraintlayout:2.0.4") - implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.4.2") + implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.4.3") } android { diff --git a/sample/build.gradle.kts b/sample/build.gradle.kts index b869e24..5077cdc 100644 --- a/sample/build.gradle.kts +++ b/sample/build.gradle.kts @@ -1,13 +1,11 @@ buildscript { repositories { gradlePluginPortal() - jcenter() google() mavenCentral() - mavenLocal() } dependencies { - classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.4.21") + classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.4.31") classpath("com.android.tools.build:gradle:4.0.2") } } @@ -15,8 +13,6 @@ buildscript { allprojects { repositories { google() - jcenter() mavenCentral() - mavenLocal() } } \ No newline at end of file diff --git a/sample/iosApp/Podfile b/sample/iosApp/Podfile index 26e5299..58cdfed 100644 --- a/sample/iosApp/Podfile +++ b/sample/iosApp/Podfile @@ -5,6 +5,6 @@ platform :ios, '14.0' install! 'cocoapods', :deterministic_uuids => false target 'iosApp' do -# pod 'Reachability' + pod 'Reachability' pod 'shared', :path => '../shared/' end diff --git a/sample/iosApp/Podfile.lock b/sample/iosApp/Podfile.lock index 6a68e65..17bf13e 100644 --- a/sample/iosApp/Podfile.lock +++ b/sample/iosApp/Podfile.lock @@ -1,16 +1,23 @@ PODS: + - Reachability (3.2) - shared (1.0) DEPENDENCIES: + - Reachability - shared (from `../shared/`) +SPEC REPOS: + trunk: + - Reachability + EXTERNAL SOURCES: shared: :path: "../shared/" SPEC CHECKSUMS: - shared: 9994551cb5a07252dbedc71dabb023220d3f4a5e + Reachability: 33e18b67625424e47b6cde6d202dce689ad7af96 + shared: b350daf742bc386fb19f713cb7965b3c541d4a11 -PODFILE CHECKSUM: 5623017cfcaca48511e4f252a3bc1b413f740ecb +PODFILE CHECKSUM: a68f2a76f185354c10da6a9c12b5083ec4e79e2a -COCOAPODS: 1.10.0 +COCOAPODS: 1.10.1 diff --git a/sample/iosApp/iosApp.xcodeproj/project.pbxproj b/sample/iosApp/iosApp.xcodeproj/project.pbxproj index 0a7fb65..6857189 100644 --- a/sample/iosApp/iosApp.xcodeproj/project.pbxproj +++ b/sample/iosApp/iosApp.xcodeproj/project.pbxproj @@ -3,7 +3,7 @@ archiveVersion = 1; classes = { }; - objectVersion = 51; + objectVersion = 50; objects = { /* Begin PBXBuildFile section */ @@ -186,6 +186,7 @@ 7555FF78242A565900829871 /* Frameworks */, 7555FF79242A565900829871 /* Resources */, 7555FFB4242A642300829871 /* Embed Frameworks */, + CB0C5E1CCE0A8F1423C1FDF3 /* [CP] Embed Pods Frameworks */, ); buildRules = ( ); @@ -240,7 +241,7 @@ attributes = { LastSwiftUpdateCheck = 1130; LastUpgradeCheck = 1130; - ORGANIZATIONNAME = orgName; + ORGANIZATIONNAME = "com.github.ln-12"; TargetAttributes = { 7555FF7A242A565900829871 = { CreatedOnToolsVersion = 11.3.1; @@ -324,6 +325,23 @@ shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; showEnvVarsInLog = 0; }; + CB0C5E1CCE0A8F1423C1FDF3 /* [CP] Embed Pods Frameworks */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + "${PODS_ROOT}/Target Support Files/Pods-iosApp/Pods-iosApp-frameworks-${CONFIGURATION}-input-files.xcfilelist", + ); + name = "[CP] Embed Pods Frameworks"; + outputFileListPaths = ( + "${PODS_ROOT}/Target Support Files/Pods-iosApp/Pods-iosApp-frameworks-${CONFIGURATION}-output-files.xcfilelist", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-iosApp/Pods-iosApp-frameworks.sh\"\n"; + showEnvVarsInLog = 0; + }; /* End PBXShellScriptBuildPhase section */ /* Begin PBXSourcesBuildPhase section */ @@ -490,6 +508,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CODE_SIGN_STYLE = Automatic; DEVELOPMENT_ASSET_PATHS = "\"iosApp/Preview Content\""; + DEVELOPMENT_TEAM = GP9TGX8B6F; ENABLE_PREVIEWS = YES; FRAMEWORK_SEARCH_PATHS = "$(inherited)"; INFOPLIST_FILE = iosApp/Info.plist; @@ -497,7 +516,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - PRODUCT_BUNDLE_IDENTIFIER = orgIdentifier.iosApp; + PRODUCT_BUNDLE_IDENTIFIER = "com.github.ln-12.multiplatform-connectivity-status"; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = "1,2"; @@ -511,6 +530,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CODE_SIGN_STYLE = Automatic; DEVELOPMENT_ASSET_PATHS = "\"iosApp/Preview Content\""; + DEVELOPMENT_TEAM = GP9TGX8B6F; ENABLE_PREVIEWS = YES; FRAMEWORK_SEARCH_PATHS = "$(inherited)"; INFOPLIST_FILE = iosApp/Info.plist; @@ -518,7 +538,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - PRODUCT_BUNDLE_IDENTIFIER = orgIdentifier.iosApp; + PRODUCT_BUNDLE_IDENTIFIER = "com.github.ln-12.multiplatform-connectivity-status"; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = "1,2"; diff --git a/sample/settings.gradle.kts b/sample/settings.gradle.kts index 98f8b07..2afa107 100644 --- a/sample/settings.gradle.kts +++ b/sample/settings.gradle.kts @@ -1,10 +1,8 @@ pluginManagement { repositories { google() - jcenter() gradlePluginPortal() mavenCentral() - mavenLocal() } } diff --git a/sample/shared/build.gradle.kts b/sample/shared/build.gradle.kts index 21eb790..0b9c30e 100644 --- a/sample/shared/build.gradle.kts +++ b/sample/shared/build.gradle.kts @@ -1,5 +1,3 @@ -import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget - plugins { id("com.android.library") kotlin("multiplatform") @@ -20,8 +18,8 @@ kotlin { sourceSets { val commonMain by getting { dependencies { - implementation("com.github.ln12:kotlin-connectivity-status:1.0") - implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.4.2-native-mt") + implementation("com.github.ln-12:multiplatform-connectivity-status:1.0.0") + implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.4.3-native-mt") } } val commonTest by getting { @@ -32,7 +30,7 @@ kotlin { } val androidMain by getting { dependencies { - implementation("com.google.android.material:material:1.2.1") + implementation("com.google.android.material:material:1.3.0") } } val androidTest by getting { diff --git a/sample/shared/shared.podspec b/sample/shared/shared.podspec index 4eeacb0..31ed2ec 100644 --- a/sample/shared/shared.podspec +++ b/sample/shared/shared.podspec @@ -19,7 +19,7 @@ Pod::Spec.new do |spec| spec.pod_target_xcconfig = { 'KOTLIN_TARGET[sdk=iphonesimulator*]' => 'ios_x64', 'KOTLIN_TARGET[sdk=iphoneos*]' => 'ios_arm', - 'KOTLIN_TARGET[sdk=watchsimulator*]' => 'watchos_x86', + 'KOTLIN_TARGET[sdk=watchsimulator*]' => 'watchos_x64', 'KOTLIN_TARGET[sdk=watchos*]' => 'watchos_arm', 'KOTLIN_TARGET[sdk=appletvsimulator*]' => 'tvos_x64', 'KOTLIN_TARGET[sdk=appletvos*]' => 'tvos_arm64', diff --git a/sample/shared/src/androidMain/AndroidManifest.xml b/sample/shared/src/androidMain/AndroidManifest.xml index a2d1b9a..ea98eb3 100644 --- a/sample/shared/src/androidMain/AndroidManifest.xml +++ b/sample/shared/src/androidMain/AndroidManifest.xml @@ -1,5 +1,5 @@ - - + \ No newline at end of file diff --git a/sample/shared/src/androidMain/kotlin/com/github/ln12/connectivitystatussample/shared/SharedStatus.kt b/sample/shared/src/androidMain/kotlin/com/github/ln12/connectivitystatussample/shared/SharedStatus.kt index 65305b7..4d7842d 100644 --- a/sample/shared/src/androidMain/kotlin/com/github/ln12/connectivitystatussample/shared/SharedStatus.kt +++ b/sample/shared/src/androidMain/kotlin/com/github/ln12/connectivitystatussample/shared/SharedStatus.kt @@ -2,11 +2,7 @@ package com.github.ln12.connectivitystatussample.shared import android.content.Context -import android.net.ConnectivityManager -import android.net.Network -import android.util.Log -import com.github.ln12.library.ConnectivityStatus -import kotlinx.coroutines.flow.MutableStateFlow +import com.github.`ln-12`.library.ConnectivityStatus actual class SharedStatus(context: Context) { private val connectivityStatus = ConnectivityStatus(context) diff --git a/sample/shared/src/iosMain/kotlin/com/github/ln12/connectivitystatussample/shared/SharedStatus.kt b/sample/shared/src/iosMain/kotlin/com/github/ln12/connectivitystatussample/shared/SharedStatus.kt index 4d6a778..78e5f0f 100644 --- a/sample/shared/src/iosMain/kotlin/com/github/ln12/connectivitystatussample/shared/SharedStatus.kt +++ b/sample/shared/src/iosMain/kotlin/com/github/ln12/connectivitystatussample/shared/SharedStatus.kt @@ -1,13 +1,14 @@ package com.github.ln12.connectivitystatussample.shared -import com.github.ln12.library.ConnectivityStatus +import com.github.`ln-12`.library.ConnectivityStatus import kotlinx.coroutines.MainScope -import kotlinx.coroutines.launch +import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.collect +import kotlinx.coroutines.launch actual class SharedStatus { - private val connectivityStatus = ConnectivityStatus() - actual val current = connectivityStatus.isNetworkConnected + private val connectivityStatus: ConnectivityStatus = ConnectivityStatus() + actual val current: MutableStateFlow = connectivityStatus.isNetworkConnected actual fun start() { connectivityStatus.start() diff --git a/settings.gradle.kts b/settings.gradle.kts index a5c5f7a..5d5fd20 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -12,4 +12,6 @@ pluginManagement { } } } -rootProject.name = "multiplatform-connectivity-status" \ No newline at end of file + +includeBuild("convention-plugins") +rootProject.name = "multiplatform-connectivity-status" diff --git a/src/androidTest/kotlin/com/github/ln-12/library/androidTest.kt b/src/androidTest/kotlin/com/github/ln-12/library/androidTest.kt deleted file mode 100644 index 8caf7ad..0000000 --- a/src/androidTest/kotlin/com/github/ln-12/library/androidTest.kt +++ /dev/null @@ -1,11 +0,0 @@ -package com.github.`ln-12`.library - -import org.junit.Test - -class AndroidGreetingTest { - - @Test - fun testExample() { - //assertTrue("Check Android is mentioned", Greeting().greeting().contains("Android")) - } -} \ No newline at end of file diff --git a/src/iosTest/kotlin/com/github/ln-12/library/iosTest.kt b/src/iosTest/kotlin/com/github/ln-12/library/iosTest.kt deleted file mode 100644 index 9d92aa7..0000000 --- a/src/iosTest/kotlin/com/github/ln-12/library/iosTest.kt +++ /dev/null @@ -1,11 +0,0 @@ -package com.github.`ln-12`.library - -import kotlin.test.Test - -class IosGreetingTest { - - @Test - fun testExample() { - //assertTrue(Greeting().greeting().contains("iOS"), "Check iOS is mentioned") - } -} \ No newline at end of file