Skip to content
This repository has been archived by the owner on Sep 26, 2019. It is now read-only.

Upload jars to bintray as part of releases #1608

Merged
merged 19 commits into from
Jun 30, 2019
Merged
Changes from 12 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
127 changes: 95 additions & 32 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,31 @@ def _strListCmdArg(name, defaultValue) {
if (!project.hasProperty(name))
return defaultValue

return ((String)project.property(name)).tokenize(',')
return ((String) project.property(name)).tokenize(',')
}

def _strListCmdArg(name) {
return _strListCmdArg(name, null)
}

apply plugin: 'com.jfrog.bintray'

def bintrayUser = project.hasProperty('bintrayUser') ? project.property('bintrayUser') : System.getenv('BINTRAY_USER')
def bintrayKey = project.hasProperty('bintrayApiKey') ? project.property('bintrayApiKey') : System.getenv('BINTRAY_KEY')
def bintrayPackage = bintray.pkg {
repo = 'pegasys-repo'
name = 'pantheon'
userOrg = 'consensys'
licenses = ['Apache-2.0']
websiteUrl = 'https://github.com/PegaSysEng/pantheon'
issueTrackerUrl = 'https://github.com/PegaSysEng/pantheon/issues'
vcsUrl = 'https://github.com/PegaSysEng/pantheon.git'

version {
name = project.version
released = new Date()
}
}

allprojects {
apply plugin: 'java-library'
Expand All @@ -82,6 +100,16 @@ allprojects {
}
}

task sourcesJar(type: Jar, dependsOn: classes) {
classifier = 'sources'
from sourceSets.main.allSource
}

task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = 'javadoc'
from javadoc.destinationDir
}

sourceCompatibility = '1.8'
targetCompatibility = '1.8'

Expand All @@ -93,7 +121,7 @@ allprojects {
jcenter()
mavenCentral()
mavenLocal()
maven { url "https://consensys.bintray.com/pegasys-repo" }
maven { url "https://consensys.bintray.com/pegasys-repo" }
}
}

Expand Down Expand Up @@ -249,6 +277,54 @@ task deploy() {}

subprojects {

if (file('src/main/java').directory) {
apply plugin: 'com.jfrog.bintray'
apply plugin: 'maven-publish'

publishing {
publications {
mavenJava(MavenPublication) {
groupId "tech.pegasys.${project.group}"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(a) do we really want each sob jar to be it's own maven group? Since they are all needed in pantheon and only used in pantheon and can't be severed from pantheon (except for two cases: metrics and plugins api) wouldn't one group make more sense? Could we all put them in to one group and let the artifact name do the work?

(b) regardless of (a) should the group name include something like "internal" or "unstable" to make it clear it's not a stable API?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Everything in tech.pegasys.pantheon makes sense to me.

Including 'internal' probably makes sense. We may need to find a way to override some of this info on a per-package basis (eg would be nice if metrics wasn't marked internal) but starting with everything internal and then some migrating out if/when we work out how to do that makes sense to me.

version "${project.version}"
from components.java
artifact sourcesJar
artifact javadocJar
versionMapping {
usage('java-api') { fromResolutionOf('runtimeClasspath') }
usage('java-runtime') { fromResolutionResult() }
}
pom {
name = "Pantheon - ${project.name}"
url = 'http://github.com/PegaSysEng/pantheon'
licenses {
license {
name = 'The Apache License, Version 2.0'
url = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
}
}
scm {
connection = 'scm:git:git://github.com/PegaSysEng/pantheon.git'
developerConnection = 'scm:git:ssh://github.com/PegaSysEng/pantheon.git'
url = 'https://github.com/PegaSysEng/pantheon'
}
}
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think if you add a repository block you may get the maven metadata

  repositories {
    maven {
      // change URLs to point to your repos, e.g. http://my.org/repo
      def releasesRepoUrl = "$buildDir/repos/releases"
      def snapshotsRepoUrl = "$buildDir/repos/snapshots"
      url = version.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl
    }
  }

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No luck. But I've tested with both gradle and maven depending on these publish jars and it works even without the metadata.

}

bintray {
user = bintrayUser
key = bintrayKey

publications = ['mavenJava']
override = version.endsWith('SNAPSHOT')

publish = true

pkg = bintrayPackage
}
}

tasks.withType(Test) {
// If GRADLE_MAX_TEST_FORKS is not set, use half the available processors
maxParallelForks = (System.getenv('GRADLE_MAX_TEST_FORKS') ?: (Runtime.runtime.availableProcessors().intdiv(2) ?: 1)).toInteger()
Expand All @@ -258,7 +334,6 @@ subprojects {
options.fork = true
options.incremental = true
}
apply plugin: 'maven-publish'

sourceSets {
// test-support can be consumed as a library by other projects in their tests
Expand Down Expand Up @@ -286,7 +361,7 @@ subprojects {
testSupportArtifacts
}

task testSupportJar (type: Jar) {
task testSupportJar(type: Jar) {
baseName = "${project.name}-support-test"
from sourceSets.testSupport.output
}
Expand All @@ -296,7 +371,7 @@ subprojects {
integrationTestImplementation sourceSets.testSupport.output
}

task integrationTest(type: Test, dependsOn:["compileTestJava"]){
task integrationTest(type: Test, dependsOn: ["compileTestJava"]) {
group = "verification"
description = "Runs the Pantheon integration tests"

Expand Down Expand Up @@ -343,7 +418,9 @@ applicationDefaultJvmArgs = [
run {
args project.hasProperty("pantheon.run.args") ? project.property("pantheon.run.args").toString().split("\\s+") : []
doFirst {
applicationDefaultJvmArgs = applicationDefaultJvmArgs.collect{it.replace('PANTHEON_HOME', "$buildDir/pantheon")}
applicationDefaultJvmArgs = applicationDefaultJvmArgs.collect {
it.replace('PANTHEON_HOME', "$buildDir/pantheon")
}
}
}

Expand Down Expand Up @@ -412,7 +489,7 @@ tasks.register("dockerDistUntar") {
new File(dockerBuildDir).mkdir()
copy {
from tarTree(distTarFile)
into (dockerBuildDir)
into(dockerBuildDir)
}
file("${dockerBuildDir}/${distTarFileName}").renameTo("${dockerBuildDir}/pantheon")
}
Expand Down Expand Up @@ -446,7 +523,7 @@ configurations { annotationProcessor }

// Prevent errorprone-checks being dependent upon errorprone-checks!
// However, ensure all subprojects comply with the custom rules.
configure(subprojects.findAll {it.name != 'errorprone-checks'}) {
configure(subprojects.findAll { it.name != 'errorprone-checks' }) {
dependencies { annotationProcessor project(":errorprone-checks") }

tasks.withType(JavaCompile) {
Expand Down Expand Up @@ -488,16 +565,16 @@ def getCheckedOutGitCommitHash() {
def head = new File(gitFolder + "HEAD").text.split(":") // .git/HEAD
def isCommit = head.length == 1 // e5a7c79edabbf7dd39888442df081b1c9d8e88fd

if(isCommit) return head[0].trim().take(takeFromHash) // e5a7c79edabb
if (isCommit) return head[0].trim().take(takeFromHash) // e5a7c79edabb

def refHead = new File(gitFolder + head[1].trim()) // .git/refs/heads/master
refHead.text.trim().take takeFromHash
}

apply plugin: 'net.researchgate.release'

task releaseIntegrationTest(type: Test){
for(TaskContainer taskList : subprojects.tasks){
task releaseIntegrationTest(type: Test) {
for (TaskContainer taskList : subprojects.tasks) {
def subProjectIntegrationTask = taskList.findByName('integrationTest')

if (subProjectIntegrationTask != null) {
Expand All @@ -506,14 +583,14 @@ task releaseIntegrationTest(type: Test){
}
}

task releaseReferenceTest(type: Test, dependsOn : [
task releaseReferenceTest(type: Test, dependsOn: [
':ethereum:core:referenceTests',
':ethereum:rlp:referenceTests',
':ethereum:trie:referenceTests'
]){
]) {
}

task releaseAcceptanceTest(type: Test, dependsOn : ':acceptance-tests:acceptanceTest') {}
task releaseAcceptanceTest(type: Test, dependsOn: ':acceptance-tests:acceptanceTest') {}

release {
preTagCommitMessage = '[Gradle Release Plugin] - pre tag commit: '
Expand All @@ -533,11 +610,9 @@ release {
}
}

apply plugin: 'com.jfrog.bintray'

bintray {
user = project.hasProperty('bintrayUser') ? project.property('bintrayUser') : System.getenv('BINTRAY_USER')
key = project.hasProperty('bintrayApiKey') ? project.property('bintrayApiKey') : System.getenv('BINTRAY_KEY')
user = bintrayUser
key = bintrayKey

filesSpec {
from distTar.destinationDir.path
Expand All @@ -546,21 +621,9 @@ bintray {
}

publish = true
override = version.endsWith('SNAPSHOT')

pkg {
repo = 'pegasys-repo'
name = 'pantheon'
userOrg = 'consensys'
licenses = ['Apache-2.0']
websiteUrl = 'https://github.com/PegaSysEng/pantheon'
issueTrackerUrl = 'https://github.com/PegaSysEng/pantheon/issues'
vcsUrl = 'https://github.com/PegaSysEng/pantheon.git'

version {
name = project.version
released = new Date()
}
}
pkg = bintrayPackage
}

afterReleaseBuild.dependsOn bintrayUpload
Expand Down