Skip to content

Commit

Permalink
update to maven-publish plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
lbergelson committed Feb 12, 2019
1 parent 9d02da9 commit 1217308
Showing 1 changed file with 36 additions and 45 deletions.
81 changes: 36 additions & 45 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ buildscript {
plugins {
id 'java'
id 'scala'
id 'maven'
id 'maven-publish'
id 'signing'
id 'jacoco'
id 'com.palantir.git-version' version '0.11.0'
Expand All @@ -22,7 +22,6 @@ repositories {
jacocoTestReport {
group = "Reporting"
description = "Generate Jacoco coverage reports after running tests."
getAdditionalSourceDirs().from(sourceSets.main.allJava.srcDirs)

reports {
xml.enabled = true // codecov depends on xml format report
Expand Down Expand Up @@ -58,6 +57,8 @@ group = 'com.github.samtools'

defaultTasks 'jar'



jar {
manifest {
attributes 'Implementation-Title': 'HTSJDK',
Expand Down Expand Up @@ -145,72 +146,62 @@ task sourcesJar(type: Jar) {
archiveClassifier.set('sources')
}

/**
*This specifies what artifacts will be built and uploaded when performing a maven upload.
*/
artifacts {
archives jar
archives javadocJar
archives sourcesJar
}

/**
* Sign non-snapshot releases with our secret key. This should never need to be invoked directly.
*/
signing {
required { isRelease && gradle.taskGraph.hasTask("uploadArchives") }
required { isRelease && gradle.taskGraph.hasTask("publishHtsjdkPublicationToMavenRepository") }
sign configurations.archives
}

/**
* Upload a release to sonatype. You must be an authorized uploader and have your sonatype
* username and password information in your gradle properties file. See the readme for more info.
*
* For releasing to your local maven repo, use gradle install
*/
uploadArchives {
repositories {
mavenDeployer {
beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }

repository(url: "https://oss.sonatype.org/service/local/staging/deploy/maven2/") {
authentication(userName: project.findProperty("sonatypeUsername"), password: project.findProperty("sonatypePassword"))
}
publishing {
publications {
htsjdk(MavenPublication) {
from components.java
artifact javadocJar
artifact sourcesJar

snapshotRepository(url: "https://broadinstitute.jfrog.io/broadinstitute/libs-snapshot-local/") {
authentication(userName: System.env.ARTIFACTORY_USERNAME, password: System.env.ARTIFACTORY_PASSWORD)
}

pom.project {
name 'HTSJDK'
packaging 'jar'
description 'A Java API for high-throughput sequencing data (HTS) formats'
url 'http://samtools.github.io/htsjdk/'
pom {
name = 'HTSJDK'
packaging = 'jar'
description = 'A Java API for high-throughput sequencing data (HTS) formats'
url = 'http://samtools.github.io/htsjdk/'

developers {
developer {
id 'picard'
name 'Picard Team'
url 'http://broadinstitute.github.io/picard'
id = 'picard'
name = 'Picard Team'
url = 'http://broadinstitute.github.io/picard'
}
}

scm {
url '[email protected]:samtools/htsjdk.git'
connection 'scm:git:[email protected]:samtools/htsjdk.git'
url = '[email protected]:samtools/htsjdk.git'
connection = 'scm:git:[email protected]:samtools/htsjdk.git'
}

licenses {
license {
name 'MIT License'
url 'http://opensource.org/licenses/MIT'
distribution 'repo'
name = 'MIT License'
url = 'http://opensource.org/licenses/MIT'
distribution = 'repo'
}
}
}
}
}
doFirst{
System.out.println("Uploading version $version")

repositories {
maven {
credentials {
username = isRelease ? project.findProperty("sonatypeUsername") : System.env.ARTIFACTORY_USERNAME
password = isRelease ? project.findProperty("sonatypePassword") : System.env.ARTIFACTORY_PASSWORD
}
def release = "https://oss.sonatype.org/service/local/staging/deploy/maven2/"
def snapshot = "https://broadinstitute.jfrog.io/broadinstitute/libs-snapshot-local/"
url = isRelease ? release : snapshot
}
}
}

task install(dependsOn:publishToMavenLocal)

0 comments on commit 1217308

Please sign in to comment.