diff --git a/.github/workflows/deploy_library_releases.yml b/.github/workflows/deploy_library_releases.yml index a9252a5b..5e0daff5 100644 --- a/.github/workflows/deploy_library_releases.yml +++ b/.github/workflows/deploy_library_releases.yml @@ -23,10 +23,32 @@ jobs: echo '::set-output name=PROJECT::autofill-parser' fi - - name: Publish snapshot + - name: Setup secrets + run: | + # Using --batch doesn't prompt for a password for importing, which works + # out for us since we supply it to the Gradle plugin directly. + echo "${NEXUS_PUBLISH_GPG_KEY}" | base64 --decode | gpg --batch --import + + # Set environment variables + echo "SONATYPE_NEXUS_USERNAME=${NEXUS_PUBLISH_USERNAME}" >> $GITHUB_ENV + echo "SONATYPE_NEXUS_PASSWORD=${NEXUS_PUBLISH_PASSWORD}" >> $GITHUB_ENV + # The ORG_GRADLE_PROJECT_ prefixed properties are equivalent to ./gradlew -Pproperty.name=value + echo "ORG_GRADLE_PROJECT_signing.keyId=${NEXUS_PUBLISH_GPG_KEY_ID}" >> $GITHUB_ENV + echo "ORG_GRADLE_PROJECT_signing.password=${NEXUS_PUBLISH_GPG_KEY_PASSWORD}" >> $GITHUB_ENV + echo "ORG_GRADLE_PROJECT_signing.secretKeyRingFile=$HOME/.gnupg/secring.gpg" >> $GITHUB_ENV + env: + NEXUS_PUBLISH_GPG_KEY: ${{ secrets.NEXUS_PUBLISH_GPG_KEY }} + NEXUS_PUBLISH_USERNAME: ${{ secrets.NEXUS_PUBLISH_USERNAME }} + NEXUS_PUBLISH_PASSWORD: ${{ secrets.NEXUS_PUBLISH_PASSWORD }} + NEXUS_PUBLISH_GPG_KEY_ID: ${{ secrets.NEXUS_PUBLISH_GPG_KEY_ID }} + NEXUS_PUBLISH_GPG_KEY_PASSWORD: ${{ secrets.NEXUS_PUBLISH_GPG_KEY_PASSWORD }} + + - name: Upload binaries uses: burrunan/gradle-cache-action@03c71a8ba93d670980695505f48f49daf43704a6 with: - arguments: :${{ steps.task-select.outputs.PROJECT }}:publishApsPublicationToBintrayRepository - env: - MAVEN_USER: msfjarvis - MAVEN_PASSWORD: ${{ secrets.BINTRAY_TOKEN }} + arguments: :${{ steps.task-select.outputs.PROJECT }}:uploadArchives + + - name: Close and release repository + uses: burrunan/gradle-cache-action@03c71a8ba93d670980695505f48f49daf43704a6 + with: + arguments: closeAndReleaseRepository diff --git a/autofill-parser/build.gradle.kts b/autofill-parser/build.gradle.kts index 9a4d423a..e955d1c0 100644 --- a/autofill-parser/build.gradle.kts +++ b/autofill-parser/build.gradle.kts @@ -1,6 +1,6 @@ plugins { id("com.android.library") - id("maven-publish") + id("com.vanniktech.maven.publish") kotlin("android") `aps-plugin` } diff --git a/autofill-parser/gradle.properties b/autofill-parser/gradle.properties index 6aa624ad..b0a370fe 100644 --- a/autofill-parser/gradle.properties +++ b/autofill-parser/gradle.properties @@ -1,16 +1,17 @@ -GROUP=com.github.androidpasswordstore VERSION_NAME=1.1.0-SNAPSHOT POM_ARTIFACT_ID=autofill-parser -POM_ARTIFACT_DESCRIPTION=Android library for low-level parsing of Autofill structures +POM_NAME=autofill-parser +POM_DESCRIPTION=Android library for low-level parsing of Autofill structures +POM_INCEPTION_YEAR=2020 POM_URL=https://github.com/Android-Password-Store/android-password-store POM_SCM_URL=https://github.com/Android-Password-Store/android-password-store POM_SCM_CONNECTION=scm:git:https://github.com/Android-Password-Store/android-password-store.git POM_SCM_DEV_CONNECTION=scm:git:ssh://git@github.com:Android-Password-Store/android-password-store -POM_LICENSE_NAME=LGPL-3.0-only WITH LGPL-3.0-linking-exception -POM_LICENSE_URL=https://www.gnu.org/licenses/lgpl-3.0.txt -POM_LICENSE_DIST=repo +POM_LICENCE_NAME=LGPL-3.0-only WITH LGPL-3.0-linking-exception +POM_LICENCE_URL=https://www.gnu.org/licenses/lgpl-3.0.txt +POM_LICENCE_DIST=repo POM_DEVELOPER_ID=android-password-store POM_DEVELOPER_NAME=The Android Password Store Authors diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts index a38a4da3..dbf1218e 100644 --- a/buildSrc/build.gradle.kts +++ b/buildSrc/build.gradle.kts @@ -5,7 +5,7 @@ plugins { repositories { google() gradlePluginPortal() - jcenter() + mavenCentral() // For binary compatibility validator. maven { url = uri("https://kotlin.bintray.com/kotlinx") } } @@ -34,7 +34,9 @@ gradlePlugin { dependencies { implementation(Plugins.androidGradlePlugin) implementation(Plugins.binaryCompatibilityValidator) + implementation(Plugins.dokkaPlugin) implementation(Plugins.downloadTaskPlugin) implementation(Plugins.kotlinGradlePlugin) + implementation(Plugins.mavenPublishPlugin) implementation(Plugins.semver4j) } diff --git a/buildSrc/src/main/java/BaseProjectConfig.kt b/buildSrc/src/main/java/BaseProjectConfig.kt index d1944888..5a1c044c 100644 --- a/buildSrc/src/main/java/BaseProjectConfig.kt +++ b/buildSrc/src/main/java/BaseProjectConfig.kt @@ -38,7 +38,25 @@ internal fun Project.configureForRootProject() { internal fun Project.configureForAllProjects() { repositories { google() - jcenter() + mavenCentral() + jcenter() { + content { + // Direct dependencies + // https://github.com/zhanghai/AndroidFastScroll/issues/35 + includeModule("me.zhanghai.android.fastscroll", "library") + // https://github.com/open-keychain/open-keychain/issues/2645 + includeModule("org.sufficientlysecure", "sshauthentication-api") + + // Indirect dependencies + // https://youtrack.jetbrains.com/issue/IDEA-261387 + includeModule("org.jetbrains.trove4j", "trove4j") + + // https://github.com/Kotlin/dokka/issues/41 + includeGroup("org.jetbrains.dokka") + includeGroup("org.jetbrains.kotlinx") + includeModule("org.jetbrains", "markdown") + } + } maven { setUrl("https://jitpack.io") } } tasks.withType { diff --git a/buildSrc/src/main/java/BintrayPublishing.kt b/buildSrc/src/main/java/BintrayPublishing.kt deleted file mode 100644 index 1429b0cb..00000000 --- a/buildSrc/src/main/java/BintrayPublishing.kt +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Copyright © 2014-2020 The Android Password Store Authors. All Rights Reserved. - * SPDX-License-Identifier: GPL-3.0-only - */ - -import com.android.build.gradle.TestedExtension -import java.util.Locale -import org.gradle.api.Project -import org.gradle.api.publish.PublishingExtension -import org.gradle.api.publish.maven.MavenPublication -import org.gradle.jvm.tasks.Jar -import org.gradle.kotlin.dsl.create -import org.gradle.kotlin.dsl.register - -/** - * Register the `sourcesJar` task so that our published artifacts can include them. - */ -internal fun TestedExtension.registerSourcesJarTask(project: Project) { - project.tasks.register("sourcesJar") { - archiveClassifier.set("sources") - from(sourceSets.getByName("main").java.srcDirs) - } -} - -/** - * Configures the `apsMaven` and `bintray` repositories along with an `aps` publication - */ -internal fun PublishingExtension.configureMavenPublication(project: Project) { - repositories { - maven { - val artifactId = project.getKey("POM_ARTIFACT_ID") - name = "bintray" - url = project.uri("https://api.bintray.com/maven/android-password-store/$artifactId/$artifactId/;publish=1;override=0") - credentials { - username = project.getCredential("user") - password = project.getCredential("password") - } - } - } - publications { - create("aps") { - from(project.components.getByName("release")) - groupId = project.getKey("GROUP") - artifactId = project.getKey("POM_ARTIFACT_ID") - version = project.getKey("VERSION_NAME") - artifact(project.tasks.getByName("sourcesJar")) - configurePom(project) - } - } -} - -private fun Project.getCredential(type: String): String { - return when (type) { - // Attempt to find credentials passed by -Pmaven.$type= - "user", "password" -> (findProperty("maven.$type") - // Fall back to MAVEN_$type from env - ?: System.getenv("MAVEN_${type.toUpperCase(Locale.ROOT)}"))?.toString() - // Finally fallthrough to an empty string to let task configuration complete - // even if actual publishing is going to fail - ?: "" - else -> throw IllegalArgumentException("Invalid credential type: $type") - } -} - -private fun Project.getKey(propertyName: String): String { - return findProperty(propertyName)?.toString() - ?: error("Failed to find value for property: $propertyName") -} - -private fun MavenPublication.configurePom(project: Project) { - pom { - name.set(project.getKey("POM_ARTIFACT_ID")) - description.set(project.getKey("POM_ARTIFACT_DESCRIPTION")) - url.set(project.getKey("POM_URL")) - licenses { - license { - name.set(project.getKey("POM_LICENSE_NAME")) - url.set(project.getKey("POM_LICENSE_URL")) - } - } - developers { - developer { - id.set(project.getKey("POM_DEVELOPER_ID")) - name.set(project.getKey("POM_DEVELOPER_NAME")) - email.set(project.getKey("POM_DEVELOPER_EMAIL")) - } - } - scm { - connection.set(project.getKey("POM_SCM_CONNECTION")) - developerConnection.set(project.getKey("POM_SCM_DEV_CONNECTION")) - url.set(project.getKey("POM_SCM_URL")) - } - } -} diff --git a/buildSrc/src/main/java/Dependencies.kt b/buildSrc/src/main/java/Dependencies.kt index fd0a74c1..49d2e7a8 100644 --- a/buildSrc/src/main/java/Dependencies.kt +++ b/buildSrc/src/main/java/Dependencies.kt @@ -8,8 +8,10 @@ private const val KOTLIN_VERSION = "1.4.30" object Plugins { val androidGradlePlugin = "com.android.tools.build:gradle:4.1.1" val binaryCompatibilityValidator = "org.jetbrains.kotlinx:binary-compatibility-validator:0.2.4" + val dokkaPlugin = "org.jetbrains.dokka:dokka-gradle-plugin:1.4.20" val downloadTaskPlugin = "de.undercouch:gradle-download-task:4.1.1" val kotlinGradlePlugin = "org.jetbrains.kotlin:kotlin-gradle-plugin:$KOTLIN_VERSION" + val mavenPublishPlugin = "com.vanniktech:gradle-maven-publish-plugin:0.13.0" val semver4j = "com.vdurmont:semver4j:3.1.0" } @@ -61,7 +63,7 @@ object Dependencies { const val jgit = "org.eclipse.jgit:org.eclipse.jgit:3.7.1.201504261725-r" const val kotlin_result = "com.michael-bull.kotlin-result:kotlin-result:1.1.10" const val leakcanary = "com.squareup.leakcanary:leakcanary-android:2.6" - const val modern_android_prefs = "de.Maxr1998.android:modernpreferences:1.2.0-alpha1" + const val modern_android_prefs = "de.maxr1998:modernandroidpreferences:2.0" const val plumber = "com.squareup.leakcanary:plumber-android:2.6" const val sshj = "com.hierynomus:sshj:0.30.0" const val ssh_auth = "org.sufficientlysecure:sshauthentication-api:1.0" diff --git a/buildSrc/src/main/java/PasswordStorePlugin.kt b/buildSrc/src/main/java/PasswordStorePlugin.kt index 12cd764e..b8271f65 100644 --- a/buildSrc/src/main/java/PasswordStorePlugin.kt +++ b/buildSrc/src/main/java/PasswordStorePlugin.kt @@ -11,7 +11,6 @@ import org.gradle.api.Plugin import org.gradle.api.Project import org.gradle.api.plugins.JavaLibraryPlugin import org.gradle.api.plugins.JavaPlugin -import org.gradle.api.publish.PublishingExtension import org.gradle.api.tasks.compile.JavaCompile import org.gradle.kotlin.dsl.getByType import org.gradle.kotlin.dsl.withType @@ -36,10 +35,6 @@ class PasswordStorePlugin : Plugin { } is LibraryPlugin -> { project.extensions.getByType().configureCommonAndroidOptions() - project.extensions.getByType().registerSourcesJarTask(project) - project.afterEvaluate { - project.extensions.getByType().configureMavenPublication(project) - } } is AppPlugin -> { project.extensions.getByType().configureAndroidApplicationOptions(project) diff --git a/gradle.properties b/gradle.properties index ced8321c..bffddc4f 100644 --- a/gradle.properties +++ b/gradle.properties @@ -51,3 +51,11 @@ android.defaults.buildfeatures.shaders=false # Disable warnings about unsupported features, we know what we're doing android.suppressUnsupportedOptionWarnings=android.enableR8.fullMode,android.enableResourceOptimizations,android.nonTransitiveRClass,android.suppressUnsupportedOptionWarnings + +# Maven publishing +GROUP=com.github.android-password-store + +# OSSRH sometimes struggles with slow deployments, so this makes Gradle +# more tolerant to those delays. +systemProp.org.gradle.internal.http.connectionTimeout=500000 +systemProp.org.gradle.internal.http.socketTimeout=500000 diff --git a/openpgp-ktx/build.gradle.kts b/openpgp-ktx/build.gradle.kts index ad6d4da1..f286b2b7 100644 --- a/openpgp-ktx/build.gradle.kts +++ b/openpgp-ktx/build.gradle.kts @@ -1,6 +1,6 @@ plugins { id("com.android.library") - id("maven-publish") + id("com.vanniktech.maven.publish") kotlin("android") `aps-plugin` } diff --git a/openpgp-ktx/gradle.properties b/openpgp-ktx/gradle.properties index b510e282..462ec77d 100644 --- a/openpgp-ktx/gradle.properties +++ b/openpgp-ktx/gradle.properties @@ -1,16 +1,17 @@ -GROUP=com.github.androidpasswordstore VERSION_NAME=2.2.0 POM_ARTIFACT_ID=openpgp-ktx -POM_ARTIFACT_DESCRIPTION=Reimplementation of OpenKeychain's integration library in Kotlin +POM_NAME=openpgp-ktx +POM_DESCRIPTION=Reimplementation of OpenKeychain's integration library in Kotlin +POM_INCEPTION_YEAR=2020 POM_URL=https://github.com/Android-Password-Store/android-password-store POM_SCM_URL=https://github.com/Android-Password-Store/android-password-store POM_SCM_CONNECTION=scm:git:https://github.com/Android-Password-Store/android-password-store.git POM_SCM_DEV_CONNECTION=scm:git:ssh://git@github.com:Android-Password-Store/android-password-store -POM_LICENSE_NAME=LGPL-3.0-only WITH LGPL-3.0-linking-exception -POM_LICENSE_URL=https://www.gnu.org/licenses/lgpl-3.0.txt -POM_LICENSE_DIST=repo +POM_LICENCE_NAME=LGPL-3.0-only WITH LGPL-3.0-linking-exception +POM_LICENCE_URL=https://www.gnu.org/licenses/lgpl-3.0.txt +POM_LICENCE_DIST=repo POM_DEVELOPER_ID=android-password-store POM_DEVELOPER_NAME=The Android Password Store Authors diff --git a/settings.gradle.kts b/settings.gradle.kts index 4b00989e..50b7da32 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -9,6 +9,6 @@ include(":openpgp-ktx") pluginManagement { repositories { gradlePluginPortal() - jcenter() + mavenCentral() } }