diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 1456f11f..ccd5ac57 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -74,9 +74,9 @@ jobs: java-version: 1.8 - name: Publish - run: ./gradlew clean artifactoryPublish -s --scan + run: ./gradlew clean publishMavenPublicationToMavenRepository -s --scan env: - BINTRAY_API_KEY: ${{ secrets.BINTRAY_API_KEY }} - BINTRAY_USERNAME: ${{ secrets.BINTRAY_USERNAME }} + SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }} + SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }} GRADLE_KEY: ${{ secrets.GRADLE_KEY }} GRADLE_SECRET: ${{ secrets.GRADLE_SECRET }} diff --git a/README.md b/README.md index 84dc360e..8a3a408a 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ Also, for Android projects the license HTML file will be copied to `/sr ```groovy buildscript { repositories { - jcenter() + mavenCentral() google() } @@ -30,13 +30,13 @@ buildscript { apply plugin: 'com.android.application' // or 'java-library' apply plugin: 'com.jaredsburrows.license' ``` -Release versions are available in the [JFrog Bintray repository](https://jcenter.bintray.com/com/jaredsburrows/gradle-license-plugin/). +Release versions are available in the [Sonatype's release repository](https://repo1.maven.org/maven2/com/jaredsburrows/gradle-license-plugin/). **Snapshot:** ```groovy buildscript { repositories { - maven { url 'https://oss.jfrog.org/artifactory/oss-snapshot-local/' } + maven { url 'https://oss.sonatype.org/content/repositories/snapshots' } google() } @@ -48,7 +48,7 @@ buildscript { apply plugin: 'com.android.application' // or 'java-library' apply plugin: 'com.jaredsburrows.license' ``` -Snapshot versions are available in the [JFrog Artifactory repository](https://oss.jfrog.org/artifactory/libs-snapshot/com/jaredsburrows/gradle-license-plugin/). +Snapshot versions are available in the [Sonatype's snapshots repository](https://oss.sonatype.org/content/repositories/snapshots/com/jaredsburrows/gradle-license-plugin/). ## Tasks @@ -89,27 +89,27 @@ Design,null,26.1.0,null,null,null,The Apache Software License,http://www.apache.
Copyright © 20xx The original author or authors
- -
No license found
-
+ +
No license found
+

  • Android GIF Drawable Library (1.2.3)
    Copyright © 20xx Karol Wrótniak
  • - -
    mit.txt here
    -
    + +
    mit.txt here
    +

  • Design (26.1.0)
    Copyright © 20xx The original author or authors
  • - -
    apache-2.0.txt here
    -
    + +
    apache-2.0.txt here
    +

    diff --git a/build.gradle b/build.gradle index 8806db34..bcdacc16 100644 --- a/build.gradle +++ b/build.gradle @@ -6,13 +6,14 @@ plugins { id 'org.jetbrains.kotlin.jvm' version '1.5.30' id 'org.jetbrains.dokka' version '0.10.1' id 'org.jlleitschuh.gradle.ktlint' version '10.2.0' - id 'java-gradle-plugin' id 'groovy' + id 'java-gradle-plugin' id 'maven-publish' + id 'signing' } repositories { - jcenter() + mavenCentral() google() } diff --git a/gradle.properties b/gradle.properties index 3d3ff230..2391865a 100644 --- a/gradle.properties +++ b/gradle.properties @@ -22,6 +22,5 @@ POM_DEVELOPER_ID=jaredsburrows POM_DEVELOPER_NAME=Jared Burrows POM_DEVELOPER_EMAIL=jaredsburrows@gmail.com -BINTRAY_GITHUB_REPO=jaredsburrows/gradle-license-plugin PLUGIN_NAME=com.jaredsburrows.license PLUGIN_NAME_CLASS=com.jaredsburrows.license.LicensePlugin diff --git a/gradle/dependencies.gradle b/gradle/dependencies.gradle index 1b5d42bf..234bdffb 100644 --- a/gradle/dependencies.gradle +++ b/gradle/dependencies.gradle @@ -13,7 +13,7 @@ ext.deps = [ ], ], 'kotlinx': [ - 'html': 'org.jetbrains.kotlinx:kotlinx-html-jvm:0.7.2', + 'html': 'org.jetbrains.kotlinx:kotlinx-html-jvm:0.7.3', ], 'gson' : 'com.google.code.gson:gson:2.8.8', 'android': [ diff --git a/gradle/publish.gradle b/gradle/publish.gradle index 7a142b19..c0c21568 100644 --- a/gradle/publish.gradle +++ b/gradle/publish.gradle @@ -1,35 +1,5 @@ -def pomConfig = { - resolveStrategy = Closure.DELEGATE_FIRST - name POM_ARTIFACT_ID - description POM_DESCRIPTION - url POM_URL - - issueManagement { - system POM_ISSUE_SYSTEM - url POM_ISSUE_URL - } - - scm { - url POM_SCM_URL - connection POM_SCM_CONNECTION - developerConnection POM_SCM_DEV_CONNECTION - } - - licenses { - license { - name POM_LICENCE_NAME - url POM_LICENCE_URL - distribution POM_LICENCE_DIST - } - } - - developers { - developer { - id POM_DEVELOPER_ID - name POM_DEVELOPER_NAME - email POM_DEVELOPER_EMAIL - } - } +def isReleaseBuild() { + return !VERSION_NAME.contains('SNAPSHOT') } task docsJar(type: Jar, dependsOn: dokka) { @@ -60,10 +30,22 @@ task reportsZip(type: Zip, dependsOn: check) { from reporting.baseDir } -// Local published to ~/.m2 - mavenLocal() publishing { repositories { mavenLocal() + + maven { + credentials { + username project.properties['SONATYPE_USERNAME'] ?: System.getenv('SONATYPE_USERNAME') + password project.properties['SONATYPE_PASSWORD'] ?: System.getenv('SONATYPE_PASSWORD') + } + + if (isReleaseBuild()) { + url 'https://oss.sonatype.org/service/local/staging/deploy/maven2/' + } else { + url 'https://oss.sonatype.org/content/repositories/snapshots/' + } + } } publications { @@ -78,76 +60,47 @@ publishing { artifactId POM_ARTIFACT_ID version VERSION_NAME - pom.withXml { - // Add parent POM information - asNode().children().first() + pomConfig + pom { + name = POM_ARTIFACT_ID + packaging = POM_PACKAGING + description = POM_DESCRIPTION + url = POM_URL + + licenses { + license { + name = POM_LICENCE_NAME + url = POM_LICENCE_URL + distribution = POM_LICENCE_DIST + } + } + + developers { + developer { + id = POM_DEVELOPER_ID + name = POM_DEVELOPER_NAME + email = POM_DEVELOPER_EMAIL + } + } + + scm { + url = POM_SCM_URL + connection = POM_SCM_CONNECTION + developerConnection = POM_SCM_DEV_CONNECTION + } + + issueManagement { + system = POM_ISSUE_SYSTEM + url = POM_ISSUE_URL + } } } } } -publish.dependsOn jar, docsJar, sourcesJar, testsJar, reportsZip -publish.dependsOn 'generatePomFileForMavenPublication' - -// Snapshots published to JFrog Artifactory repository -artifactory { - contextUrl = 'https://oss.jfrog.org' - - publish { - repository { - repoKey = 'oss-snapshot-local' - username = project.properties['BINTRAY_USERNAME'] ?: System.getenv('BINTRAY_USERNAME') - password = project.properties['BINTRAY_API_KEY'] ?: System.getenv('BINTRAY_API_KEY') - } - - defaults { - publications 'maven' - } - } - resolve { - repository { - repoKey = 'libs-release' - } - } -} -artifactoryPublish.dependsOn jar, docsJar, sourcesJar, testsJar, reportsZip -artifactoryPublish.dependsOn 'generatePomFileForMavenPublication' - -// Publishes to JFrog Bintray's JCenter repository -bintray { - user = project.properties['BINTRAY_USERNAME'] ?: System.getenv('BINTRAY_USERNAME') - key = project.properties['BINTRAY_API_KEY'] ?: System.getenv('BINTRAY_API_KEY') - publications = ['maven'] - publish = true - - pkg { - repo = 'maven' - name = POM_ARTIFACT_ID - desc = POM_DESCRIPTION - websiteUrl = POM_URL - issueTrackerUrl = POM_ISSUE_URL - vcsUrl = POM_URL - labels = ['gradle', 'plugin', 'license'] - githubRepo = BINTRAY_GITHUB_REPO - githubReleaseNotesFile = 'README.md' - - version { - name = VERSION_NAME - desc = POM_DESCRIPTION - released = new Date() - vcsTag = VERSION_NAME - - mavenCentralSync { - sync = false - user = project.properties['SONATYPE_USERNAME'] ?: System.getenv('SONATYPE_USERNAME') - password = project.properties['SONATYPE_PASSWORD'] ?: System.getenv('SONATYPE_PASSWORD') - close = '1' - } - } - } +signing { + required { isReleaseBuild() && gradle.taskGraph.hasTask("release") } + sign publishing.publications.maven } -bintrayUpload.dependsOn jar, docsJar, sourcesJar, testsJar, reportsZip -bintrayUpload.dependsOn 'generatePomFileForMavenPublication' // Publishes to Gradle plugins repository gradlePlugin { @@ -162,7 +115,6 @@ pluginBundle { website = POM_URL vcsUrl = POM_URL description = POM_DESCRIPTION - tags = bintray.pkg.labels plugins { licensePlugin { @@ -170,11 +122,9 @@ pluginBundle { } } } -publishPlugins.dependsOn jar, docsJar, sourcesJar, testsJar, reportsZip -publishPlugins.dependsOn 'generatePomFileForMavenPublication' -// Publish to both Bintray and Gradle repositories -task release(dependsOn: [bintrayUpload, publishPlugins]) { +// Publish to both Maven Central and Gradle repositories +task release(dependsOn: [publishMavenPublicationToMavenRepository, publishPlugins]) { group = 'Publishing' - description = 'Publish to JFrog Jcenter\'s Brintray and Gradle Plugins Repositories.' + description = 'Publish to Maven Central and Gradle Plugins Repositories.' } diff --git a/src/test/groovy/com/jaredsburrows/license/LicensePluginAndroidSpec.groovy b/src/test/groovy/com/jaredsburrows/license/LicensePluginAndroidSpec.groovy index ae85f85c..b749ab7a 100644 --- a/src/test/groovy/com/jaredsburrows/license/LicensePluginAndroidSpec.groovy +++ b/src/test/groovy/com/jaredsburrows/license/LicensePluginAndroidSpec.groovy @@ -46,7 +46,7 @@ final class LicensePluginAndroidSpec extends Specification { """ buildscript { repositories { - jcenter() + mavenCentral() google() }