From faab176f0d483afb721b295131d58b4a227e3656 Mon Sep 17 00:00:00 2001 From: Andriy Druk Date: Wed, 12 May 2021 12:03:08 +0300 Subject: [PATCH 1/2] Dev: migrate to Maven Central --- README.md | 22 +++--- app/build.gradle | 8 +- .../druk/dnssdsamples/MainActivity.java | 3 +- bintray-publish.gradle | 79 ------------------- build.gradle | 36 ++------- dnssd/build.gradle | 14 +++- gradle/wrapper/gradle-wrapper.properties | 2 +- publish-module.gradle | 76 ++++++++++++++++++ publish-root.gradle | 38 +++++++++ rx2dnssd/build.gradle | 15 ++-- rxdnssd/build.gradle | 15 ++-- 11 files changed, 171 insertions(+), 137 deletions(-) delete mode 100644 bintray-publish.gradle create mode 100644 publish-module.gradle create mode 100644 publish-root.gradle diff --git a/README.md b/README.md index 9a32d63..4ded113 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,6 @@ -# Android mDNSResponder [![Circle CI](https://circleci.com/gh/andriydruk/RxDNSSD.svg?style=shield&circle-token=5f0cb1ee907a20bdb08aa4b073b5690afbaaabe1)](https://circleci.com/gh/andriydruk/RxDNSSD) [![Download](https://api.bintray.com/packages/andriydruk/maven/dnssd/images/download.svg)](https://bintray.com/andriydruk/maven/rxdnssd/_latestVersion) [![Download](https://api.bintray.com/packages/andriydruk/maven/rxdnssd/images/download.svg)](https://bintray.com/andriydruk/maven/rxdnssd/_latestVersion)[ ![Download](https://api.bintray.com/packages/andriydruk/maven/rxdnssd/images/download.svg) ](https://bintray.com/andriydruk/maven/rxdnssd/_latestVersion) +# Android mDNSResponder [![Circle CI](https://circleci.com/gh/andriydruk/RxDNSSD.svg?style=shield&circle-token=5f0cb1ee907a20bdb08aa4b073b5690afbaaabe1)](https://circleci.com/gh/andriydruk/RxDNSSD) [![Download](https://img.shields.io/maven-central/v/com.github.andriydruk/dnssd?label=DNSSD)](https://search.maven.org/artifact/com.github.andriydruk/dnssd) [![Download](https://img.shields.io/maven-central/v/com.github.andriydruk/rxdnssd?label=RxDNSSD)](https://search.maven.org/artifact/com.github.andriydruk/rxdnssd) [![Download](https://img.shields.io/maven-central/v/com.github.andriydruk/rx2dnssd?label=Rx2DNSSD) ](https://search.maven.org/artifact/com.github.andriydruk/rx2dnssd) + + @@ -53,27 +55,27 @@ Embedded version: ``` -## Binaries +## Binaries on MavenCentral -My dnssd library: +DNSSD library: ```groovy -compile 'com.github.andriydruk:dnssd:0.9.13' +compile 'com.github.andriydruk:dnssd:0.9.15' ``` -My rxdnssd library: +RxDNSSD library: ```groovy -compile 'com.github.andriydruk:rxdnssd:0.9.13' +compile 'com.github.andriydruk:rxdnssd:0.9.15' ``` -My rx2dnssd library: +Rx2DNSSD library: ``` -compile 'com.github.andriydruk:rx2dnssd:0.9.13' +compile 'com.github.andriydruk:rx2dnssd:0.9.15' ``` -* It's built with Andorid NDK r18b for all platforms (1.7 MB). If you prefer another NDK version or subset of platforms, please build it from source with command: +* It's built with Andorid NDK 21 for all platforms (1.7 MB). If you prefer another NDK version or subset of platforms, please build it from source with command: ```groovy ./gradlew clean build @@ -234,7 +236,7 @@ browseDisposable = rxDnssd.browse("_http._tcp", "local.") License ------- - Copyright (C) 2016 Andriy Druk + Copyright (C) 2021 Andriy Druk Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/app/build.gradle b/app/build.gradle index 0360716..3a1aa34 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -26,15 +26,15 @@ android { targetCompatibility JavaVersion.VERSION_1_8 } - ndkVersion "21.3.6528147" + ndkVersion "21.4.7075529" } dependencies { implementation project(':rx2dnssd') - //implementation 'com.github.andriydruk:rx2dnssd:0.9.8-beta1' + implementation 'androidx.appcompat:appcompat:1.2.0' - implementation 'com.google.android.material:material:1.2.1' + implementation 'com.google.android.material:material:1.3.0' implementation 'androidx.constraintlayout:constraintlayout:2.0.4' - testImplementation 'junit:junit:4.13.1' + testImplementation 'junit:junit:4.13.2' } diff --git a/app/src/main/java/com/github/druk/dnssdsamples/MainActivity.java b/app/src/main/java/com/github/druk/dnssdsamples/MainActivity.java index 0842819..38a38b2 100644 --- a/app/src/main/java/com/github/druk/dnssdsamples/MainActivity.java +++ b/app/src/main/java/com/github/druk/dnssdsamples/MainActivity.java @@ -15,6 +15,7 @@ import com.github.druk.rx2dnssd.BonjourService; import com.github.druk.rx2dnssd.Rx2Dnssd; +import com.github.druk.rx2dnssd.Rx2DnssdBindable; import com.github.druk.rx2dnssd.Rx2DnssdEmbedded; import java.util.Objects; @@ -41,7 +42,7 @@ protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); - rxDnssd = new Rx2DnssdEmbedded(this); + rxDnssd = new Rx2DnssdBindable(this); findViewById(R.id.check_threads).setOnClickListener(v -> { /* diff --git a/bintray-publish.gradle b/bintray-publish.gradle deleted file mode 100644 index 636ceb4..0000000 --- a/bintray-publish.gradle +++ /dev/null @@ -1,79 +0,0 @@ -apply plugin: 'com.github.dcendents.android-maven' -apply plugin: 'com.jfrog.bintray' - -// Publishing -group = bintrayGroup -version = bintrayVersion - -install { - repositories.mavenInstaller { - // This generates POM.xml with proper parameters - pom { - project { - packaging bintrayPackaging - groupId bintrayGroup - artifactId project.name - - // Add your description here - name project.name - description bintrayLibraryDescription - - // Set your license - licenses { - license { - name bintrayLicenseName - url bintrayLicenseUrl - } - } - developers { - developer { - id bintrayDeveloperId - name bintrayDeveloperName - email bintrayDeveloperEmail - } - } - } - } - } -} - -if (project.hasProperty("BINTRAY_USER") && project.hasProperty("BINTRAY_KEY")) { - bintray { - // define this in ~/.gradle/gradle.properties - user = BINTRAY_USER - key = BINTRAY_KEY - configurations = bintrayConfigurations - pkg { - repo = bintrayRepo - name = project.name - userOrg = bintrayDeveloperId - licenses = bintrayAllLicenses - desc = bintrayLibraryDescription - websiteUrl = bintrayWebsiteUrl - issueTrackerUrl = bintrayIssueTrackerUrl - vcsUrl = binstrayVCSUrl - publish = true - } - } -} - -task sourcesJar(type: Jar) { - from android.sourceSets.main.java.srcDirs - classifier = 'sources' -} - -task javadoc(type: Javadoc) { - source = android.sourceSets.main.java.srcDirs - classpath += project.files(android.getBootClasspath().join(File.pathSeparator)) - failOnError false -} - -task javadocJar(type: Jar, dependsOn: javadoc) { - classifier = 'javadoc' - from javadoc.destinationDir -} - -artifacts { - archives javadocJar - archives sourcesJar -} diff --git a/build.gradle b/build.gradle index a95643f..4a54767 100644 --- a/build.gradle +++ b/build.gradle @@ -1,14 +1,14 @@ // Top-level build file where you can add configuration options common to all sub-projects/modules. - buildscript { repositories { - jcenter() google() + maven { + url "https://plugins.gradle.org/m2/" + } } dependencies { - classpath 'com.android.tools.build:gradle:4.1.1' - classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.4' - classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1' + classpath 'com.android.tools.build:gradle:4.2.0' + classpath 'io.github.gradle-nexus:publish-plugin:1.1.0' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files } @@ -16,8 +16,8 @@ buildscript { allprojects { repositories { - jcenter() google() + mavenCentral() } } @@ -37,25 +37,5 @@ task clean(type: Delete) { delete rootProject.buildDir } -ext { - bintrayRepo = 'maven' - bintrayPackaging = 'aar' - bintrayConfigurations = ['archives'] - - bintrayGroup = 'com.github.andriydruk' - bintrayVersion = '0.9.14' - - bintrayLibraryDescription = 'Android version of Apple DNSSD Java API' - - bintrayDeveloperId = 'andriydruk' - bintrayDeveloperName = 'Andriy Druk' - bintrayDeveloperEmail = 'andriy.druk@gmail.com' - - bintrayLicenseName = 'The Apache Software License, Version 2.0' - bintrayLicenseUrl = 'http://www.apache.org/licenses/LICENSE-2.0.txt' - bintrayAllLicenses = ["Apache-2.0"] - - bintrayWebsiteUrl = "https://github.com/andriydruk/RxDNSSD" - bintrayIssueTrackerUrl = "https://github.com/andriydruk/RxDNSSD/issues" - binstrayVCSUrl = "https://github.com/andriydruk/RxDNSSD.git" -} \ No newline at end of file +apply plugin: 'io.github.gradle-nexus.publish-plugin' +apply from: "${rootDir}/publish-root.gradle" \ No newline at end of file diff --git a/dnssd/build.gradle b/dnssd/build.gradle index 1d7a6cd..4e19844 100644 --- a/dnssd/build.gradle +++ b/dnssd/build.gradle @@ -5,11 +5,11 @@ repositories { } android { - compileSdkVersion 28 + compileSdkVersion 30 defaultConfig { minSdkVersion 14 - targetSdkVersion 28 + targetSdkVersion 30 versionCode 1 versionName "1.0" } @@ -36,7 +36,7 @@ android { } } - ndkVersion "21.3.6528147" + ndkVersion "21.4.7075529" } dependencies { @@ -53,4 +53,10 @@ dependencies { } } -apply from: rootProject.file('bintray-publish.gradle') +ext { + // Provide your own coordinates here + PUBLISH_GROUP_ID = 'com.github.andriydruk' + PUBLISH_ARTIFACT_ID = 'dnssd' +} + +apply from: "${rootProject.projectDir}/publish-module.gradle" diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index f314038..3c9c3b9 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-all.zip diff --git a/publish-module.gradle b/publish-module.gradle new file mode 100644 index 0000000..cca8725 --- /dev/null +++ b/publish-module.gradle @@ -0,0 +1,76 @@ +apply plugin: 'maven-publish' +apply plugin: 'signing' + +task androidSourcesJar(type: Jar) { + archiveClassifier.set('sources') + if (project.plugins.findPlugin("com.android.library")) { + // For Android libraries + from android.sourceSets.main.java.srcDirs + } +} + +artifacts { + archives androidSourcesJar +} + +group = PUBLISH_GROUP_ID +version = mavenCentralVersion + +afterEvaluate { + publishing { + publications { + release(MavenPublication) { + // The coordinates of the library, being set from variables that + // we'll set up later + groupId PUBLISH_GROUP_ID + artifactId PUBLISH_ARTIFACT_ID + version mavenCentralVersion + + // Two artifacts, the `aar` (or `jar`) and the sources + if (project.plugins.findPlugin("com.android.library")) { + from components.release + } else { + artifact("$buildDir/libs/${project.getName()}-${version}.jar") + } + + artifact androidSourcesJar + + // Mostly self-explanatory metadata + pom { + name = PUBLISH_ARTIFACT_ID + description = 'Android version of Apple DNSSD Java API' + url = 'https://github.com/andriydruk/RxDNSSD' + licenses { + license { + name = 'The Apache Software License, Version 2.0' + url = 'https://github.com/andriydruk/RxDNSSD/blob/master/LICENSE' + } + } + developers { + developer { + id = 'andriydruk' + name = 'Andrew Druk' + email = 'adriy.druk@gmail.com' + } + } + + // Version control info - if you're using GitHub, follow the + // format as seen here + scm { + connection = 'scm:git:github.com/andriydruk/RxDNSSD.git' + developerConnection = 'scm:git:ssh://github.com/andriydruk/RxDNSSD.git' + url = 'https://github.com/andriydruk/RxDNSSD/tree/master' + } + } + } + } + } +} + +ext["signing.keyId"] = rootProject.ext["signing.keyId"] +ext["signing.password"] = rootProject.ext["signing.password"] +ext["signing.secretKeyRingFile"] = rootProject.ext["signing.secretKeyRingFile"] + +signing { + sign publishing.publications +} \ No newline at end of file diff --git a/publish-root.gradle b/publish-root.gradle new file mode 100644 index 0000000..62ab958 --- /dev/null +++ b/publish-root.gradle @@ -0,0 +1,38 @@ +// Create variables with empty default values +ext["signing.keyId"] = '' +ext["signing.password"] = '' +ext["signing.secretKeyRingFile"] = '' +ext["ossrhUsername"] = '' +ext["ossrhPassword"] = '' +ext["sonatypeStagingProfileId"] = '' +ext["mavenCentralVersion"] = '' + +File secretPropsFile = project.rootProject.file('local.properties') +if (secretPropsFile.exists()) { + // Read local.properties file first if it exists + Properties p = new Properties() + new FileInputStream(secretPropsFile).withCloseable { is -> p.load(is) } + p.each { name, value -> ext[name] = value } +} else { + // Use system environment variables + ext["ossrhUsername"] = System.getenv('OSSRH_USERNAME') + ext["ossrhPassword"] = System.getenv('OSSRH_PASSWORD') + ext["sonatypeStagingProfileId"] = System.getenv('SONATYPE_STAGING_PROFILE_ID') + 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["mavenCentralVersion"] = System.getenv('PUBLISH_VERSION') +} + +// Set up Sonatype repository +nexusPublishing { + repositories { + sonatype { + stagingProfileId = sonatypeStagingProfileId + username = ossrhUsername + password = ossrhPassword + //nexusUrl.set(uri("https://s01.oss.sonatype.org/service/local/")) + //snapshotRepositoryUrl.set(uri("https://s01.oss.sonatype.org/content/repositories/snapshots/")) + } + } +} \ No newline at end of file diff --git a/rx2dnssd/build.gradle b/rx2dnssd/build.gradle index 763d532..963b2d5 100644 --- a/rx2dnssd/build.gradle +++ b/rx2dnssd/build.gradle @@ -1,11 +1,11 @@ apply plugin: 'com.android.library' android { - compileSdkVersion 28 + compileSdkVersion 30 defaultConfig { minSdkVersion 14 - targetSdkVersion 28 + targetSdkVersion 30 versionCode 1 versionName "1.0" } @@ -28,8 +28,8 @@ android { } dependencies { - api project(':dnssd') - //api "com.github.andriydruk:dnssd:$bintrayVersion" + //api project(':dnssd') + api "com.github.andriydruk:dnssd:$mavenCentralVersion" // Transitively export that dependencies to other modules api 'io.reactivex.rxjava2:rxandroid:2.1.1' @@ -49,4 +49,9 @@ dependencies { } } -apply from: rootProject.file('bintray-publish.gradle') +ext { + PUBLISH_GROUP_ID = 'com.github.andriydruk' + PUBLISH_ARTIFACT_ID = 'rx2dnssd' +} + +apply from: "${rootProject.projectDir}/publish-module.gradle" diff --git a/rxdnssd/build.gradle b/rxdnssd/build.gradle index 890129e..cbcd68c 100644 --- a/rxdnssd/build.gradle +++ b/rxdnssd/build.gradle @@ -1,11 +1,11 @@ apply plugin: 'com.android.library' android { - compileSdkVersion 28 + compileSdkVersion 30 defaultConfig { minSdkVersion 14 - targetSdkVersion 28 + targetSdkVersion 30 versionCode 1 versionName "1.0" } @@ -28,8 +28,8 @@ android { } dependencies { - api project(':dnssd') - //api "com.github.andriydruk:dnssd:$bintrayVersion" + //api project(':dnssd') + api "com.github.andriydruk:dnssd:$mavenCentralVersion" // Transitively export that dependencies to other modules api 'io.reactivex:rxandroid:1.2.1' @@ -49,4 +49,9 @@ dependencies { } } -apply from: rootProject.file('bintray-publish.gradle') +ext { + PUBLISH_GROUP_ID = 'com.github.andriydruk' + PUBLISH_ARTIFACT_ID = 'rxdnssd' +} + +apply from: "${rootProject.projectDir}/publish-module.gradle" From efd08b42a2dccbba0b827898d63d14064c9228a0 Mon Sep 17 00:00:00 2001 From: Andriy Druk Date: Wed, 12 May 2021 12:41:04 +0300 Subject: [PATCH 2/2] Dev: switch to local dependencies dnssd --- rx2dnssd/build.gradle | 4 ++-- rxdnssd/build.gradle | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/rx2dnssd/build.gradle b/rx2dnssd/build.gradle index 963b2d5..8b51515 100644 --- a/rx2dnssd/build.gradle +++ b/rx2dnssd/build.gradle @@ -28,8 +28,8 @@ android { } dependencies { - //api project(':dnssd') - api "com.github.andriydruk:dnssd:$mavenCentralVersion" + api project(':dnssd') + //api "com.github.andriydruk:dnssd:$mavenCentralVersion" // Transitively export that dependencies to other modules api 'io.reactivex.rxjava2:rxandroid:2.1.1' diff --git a/rxdnssd/build.gradle b/rxdnssd/build.gradle index cbcd68c..b7c9e5a 100644 --- a/rxdnssd/build.gradle +++ b/rxdnssd/build.gradle @@ -28,8 +28,8 @@ android { } dependencies { - //api project(':dnssd') - api "com.github.andriydruk:dnssd:$mavenCentralVersion" + api project(':dnssd') + //api "com.github.andriydruk:dnssd:$mavenCentralVersion" // Transitively export that dependencies to other modules api 'io.reactivex:rxandroid:1.2.1'