Skip to content

Commit

Permalink
move to sonatype maven central
Browse files Browse the repository at this point in the history
  • Loading branch information
jaredsburrows committed Sep 11, 2021
1 parent 86c2414 commit 95ad48a
Show file tree
Hide file tree
Showing 7 changed files with 74 additions and 124 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
26 changes: 13 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Also, for Android projects the license HTML file will be copied to `<project>/sr
```groovy
buildscript {
repositories {
jcenter()
mavenCentral()
google()
}
Expand All @@ -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()
}
Expand All @@ -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

Expand Down Expand Up @@ -89,27 +89,27 @@ Design,null,26.1.0,null,null,null,The Apache Software License,http://www.apache.
<dt>Copyright &copy; 20xx The original author or authors</dt>
</dl>
</li>
<a name="0"></a>
<pre>No license found</pre>
<br>
<a name="0"></a>
<pre>No license found</pre>
<br>
<hr>
<li><a href="#1783810846">Android GIF Drawable Library (1.2.3)</a>
<dl>
<dt>Copyright &copy; 20xx Karol Wrótniak</dt>
</dl>
</li>
<a name="1783810846"></a>
<pre>mit.txt here</pre>
<br>
<a name="1783810846"></a>
<pre>mit.txt here</pre>
<br>
<hr>
<li><a href="#1934118923">Design (26.1.0)</a>
<dl>
<dt>Copyright &copy; 20xx The original author or authors</dt>
</dl>
</li>
<a name="1934118923"></a>
<pre>apache-2.0.txt here</pre>
<br>
<a name="1934118923"></a>
<pre>apache-2.0.txt here</pre>
<br>
<hr>
</ul>
</body>
Expand Down
5 changes: 3 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}

Expand Down
1 change: 0 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,5 @@ POM_DEVELOPER_ID=jaredsburrows
POM_DEVELOPER_NAME=Jared Burrows
POM_DEVELOPER_EMAIL[email protected]

BINTRAY_GITHUB_REPO=jaredsburrows/gradle-license-plugin
PLUGIN_NAME=com.jaredsburrows.license
PLUGIN_NAME_CLASS=com.jaredsburrows.license.LicensePlugin
2 changes: 1 addition & 1 deletion gradle/dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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': [
Expand Down
156 changes: 53 additions & 103 deletions gradle/publish.gradle
Original file line number Diff line number Diff line change
@@ -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) {
Expand Down Expand Up @@ -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 {
Expand All @@ -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 {
Expand All @@ -162,19 +115,16 @@ pluginBundle {
website = POM_URL
vcsUrl = POM_URL
description = POM_DESCRIPTION
tags = bintray.pkg.labels

plugins {
licensePlugin {
displayName = POM_NAME
}
}
}
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.'
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ final class LicensePluginAndroidSpec extends Specification {
"""
buildscript {
repositories {
jcenter()
mavenCentral()
google()
}
Expand Down

0 comments on commit 95ad48a

Please sign in to comment.