diff --git a/build.gradle b/build.gradle index 0b73c55..f4fa276 100644 --- a/build.gradle +++ b/build.gradle @@ -1,13 +1,15 @@ plugins { id 'java' - id 'maven-publish' + id 'maven' id 'org.unbroken-dome.test-sets' version '1.3.2' - id "com.diffplug.gradle.spotless" version '3.3.0' + id 'com.diffplug.gradle.spotless' version '3.3.0' + id 'signing' + id 'io.codearte.nexus-staging' version '0.9.0' } group = 'com.appnexus.grafana-client' - description = """A simple java client for interacting with Grafana using a fluent interface""" +version = '1.0.0' sourceCompatibility = 1.8 targetCompatibility = 1.8 @@ -15,6 +17,7 @@ targetCompatibility = 1.8 repositories { jcenter() mavenLocal() + mavenCentral() } ext { @@ -24,6 +27,9 @@ ext { retrofitVersion = '2.2.0' } +def ossrhUsername=project.properties['ossrhUsername'] ?: '' +def ossrhPassword=project.properties['ossrhPassword'] ?: '' + testSets { integrationTest { dirName = 'integration-test' } } @@ -41,25 +47,74 @@ dependencies { } task sourceJar(type: Jar) { + classifier = 'sources' from sourceSets.main.allJava } -publishing { - repositories { - mavenLocal() +task javadocJar(type: Jar, dependsOn: javadoc) { + classifier = 'javadoc' + from javadoc.destinationDir +} + +if (project.hasProperty('sign')) { + signing { + sign configurations.archives } +} + +artifacts { + archives javadocJar, sourceJar +} + +uploadArchives { + repositories { + mavenDeployer { + beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) } - publications { - mavenJava(MavenPublication) { - from components.java + repository(url: "https://oss.sonatype.org/service/local/staging/deploy/maven2/") { + authentication(userName: ossrhUsername, password: ossrhPassword) + } - artifact sourceJar { - classifier "sources" + snapshotRepository(url: "https://oss.sonatype.org/content/repositories/snapshots/") { + authentication(userName: ossrhUsername, password: ossrhPassword) + } + + pom.project { + name project.name + packaging 'jar' + description project.description + url 'https://github.com/appnexus/grafana-api-java-client' + + scm { + connection 'scm:git:https://github.com/appnexus/grafana-api-java-client.git' + developerConnection 'scm:git:git@github.com:appnexus/grafana-api-java-client.git' + url 'https://github.com/appnexus/grafana-api-java-client.git' + } + + licenses { + license { + name 'The Apache License, Version 2.0' + url 'http://www.apache.org/licenses/LICENSE-2.0.txt' + } + } + + developers { + developer { + id 'stevesample' + name 'Steve Sample' + email 'steve.sample22@gmail.com' + } + } } } } } +nexusStaging { + username = ossrhUsername + password = ossrhPassword +} + spotless { java { googleJavaFormat()