1// 2// Publish to Maven Central 3// 4 5apply plugin: 'maven-publish' 6apply plugin: 'maven' 7 8apply plugin: 'io.codearte.nexus-staging' 9 10nexusStaging { 11 packageGroup 'org.testng' 12 username System.getenv('SONATYPE_USER') 13 password System.getenv('SONATYPE_PASSWORD') 14} 15 16javadoc { 17 failOnError false 18} 19 20signing { 21 required { gradle.taskGraph.hasTask("uploadArchives") } 22 sign configurations.archives 23} 24 25publishing { 26 publications { 27 mavenCustom(MavenPublication) { 28 from components.java 29 artifact sourcesJar 30 31 groupId 'org.testng' 32 artifactId 'testng' 33 version project.version 34 } 35 } 36} 37 38// ./gradlew uploadArchives (upload snapshot to Maven Central's snapshot repo) 39uploadArchives { 40 repositories { 41 mavenDeployer { 42 beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) } 43 44 repository(url: "https://oss.sonatype.org/service/local/staging/deploy/maven2") { 45 authentication(userName: System.getenv('SONATYPE_USER'), password: System.getenv('SONATYPE_PASSWORD')) 46 } 47 snapshotRepository(url: "https://oss.sonatype.org/content/repositories/snapshots") { 48 authentication(userName: System.getenv('SONATYPE_USER'), password: System.getenv('SONATYPE_PASSWORD')) 49 } 50 pom { 51 version = project.version 52 artifactId = 'testng' 53 groupId = 'org.testng' 54 project { 55 name project.name 56 description 'Testing framework for Java' 57 url 'http://github.com/cbeust/testng' 58 scm { 59 connection 'scm:git:https://github.com/cbeust/testng.git' 60 developerConnection 'scm:git:git@github.com:cbeust/testng.git' 61 url 'https://github.com/cbeust/testng.git' 62 } 63 licenses { 64 license { 65 name 'Apache Version 2.0, January 2004' 66 distribution 'repo' 67 } 68 } 69 developers { 70 developer { 71 id = 'cbeust' 72 name = 'Cedric Beust' 73 email = 'cedric@beust.com' 74 } 75 } 76 } 77 } 78 } 79 } 80} 81 82uploadArchives.doLast { 83 if (! version.contains("SNAPSHOT")) { 84 println("Now go to https://oss.sonatype.org/index.html#stagingRepositories to close" + 85 " and publish the distribution") 86 } 87}