Skip to content
This repository was archived by the owner on Dec 5, 2024. It is now read-only.

Update plublish process to publish to sonatype #1

Merged
merged 1 commit into from
Feb 24, 2021
Merged
Show file tree
Hide file tree
Changes from all 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
20 changes: 5 additions & 15 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -1,21 +1,11 @@
#!groovy
@Library('github.com/wooga/[email protected]') _

withCredentials([usernamePassword(credentialsId: 'github_integration', passwordVariable: 'githubPassword', usernameVariable: 'githubUser'),
usernamePassword(credentialsId: 'github_integration_2', passwordVariable: 'githubPassword2', usernameVariable: 'githubUser2'),
string(credentialsId: 'spock_github_extension_coveralls_token', variable: 'coveralls_token')]) {

def testEnvironment = [ 'osx':
[
"ATLAS_GITHUB_INTEGRATION_USER=${githubUser}",
"ATLAS_GITHUB_INTEGRATION_PASSWORD=${githubPassword}"
],
'windows':
[
"ATLAS_GITHUB_INTEGRATION_USER=${githubUser2}",
"ATLAS_GITHUB_INTEGRATION_PASSWORD=${githubPassword2}"
]
]

buildJavaLibrary plaforms: ['osx','windows'], coverallsToken: coveralls_token, testEnvironment: testEnvironment
def testEnvironment = [
"ATLAS_GITHUB_INTEGRATION_USER=${githubUser}",
"ATLAS_GITHUB_INTEGRATION_PASSWORD=${githubPassword}"
]
buildJavaLibraryOSSRH coverallsToken: coveralls_token, testEnvironment: testEnvironment
}
150 changes: 76 additions & 74 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,15 @@ plugins {
id 'java-library'
id 'groovy'
id 'maven-publish'
id 'com.jfrog.bintray' version '1.8.4'
id 'nebula.release' version '6.3.5'
id 'signing'
id 'nebula.release' version '15.2.0'
id 'jacoco'
id 'com.github.kt3k.coveralls' version '2.8.2'
id 'io.codearte.nexus-staging' version '0.22.0'
id "de.marcphilipp.nexus-publish" version "0.4.0"
}

group "com.wooga.spock.extensions"

List<String> cliTasks = project.rootProject.gradle.startParameter.taskNames
if (cliTasks.contains("rc")) {
cliTasks.remove("rc")
Expand All @@ -35,74 +36,27 @@ if (cliTasks.contains("rc")) {
}

dependencies {
compile 'org.codehaus.groovy:groovy-all:2.4.15'
compile 'org.kohsuke:github-api:1.95'
compile('org.spockframework:spock-core:1.2-groovy-2.4')
implementation 'org.codehaus.groovy:groovy-all:2.4.15'
api 'org.kohsuke:github-api:1.95'
implementation('org.spockframework:spock-core:1.2-groovy-2.4')

testCompile 'net.bytebuddy:byte-buddy:1.9.12'
testCompile 'com.github.stefanbirkner:system-rules:1.18.0'
testImplementation 'net.bytebuddy:byte-buddy:[1.9,2)'
testImplementation 'com.github.stefanbirkner:system-rules:[1.18,2)'
}

repositories {
jcenter()
mavenCentral()
}

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

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

artifacts {
archives sourcesJar
archives javadocJar
}

bintray {
user = project.hasProperty('bintrayUser') ? project.property('bintray.user') : System.getenv('BINTRAY_USER')
key = project.hasProperty('bintrayApiKey') ? project.property('bintray.key') : System.getenv('BINTRAY_API_KEY')
publish = true
publications = ['Bintray']
pkg {
repo = 'maven'
name = project.name
userOrg = 'wooga'
licenses = ['Apache-2.0']
vcsUrl = 'https://github.com/wooga/spock-github-extension.git'
labels = ['test', 'spock', 'github']
version {
name = project.version.toString()
vcsTag = project.version.toString()
released = new Date()
}
}
}


def pomConfig = {
licenses {
license {
name "The Apache Software License, Version 2.0"
url "http://www.apache.org/licenses/LICENSE-2.0.txt"
distribution "repo"
}
}
developers {
developer {
id "manfred.endres"
name "Manfred Endres"
email "[email protected]"
}
}

scm {
url "https://github.com/wooga/spock-github-extension.git"
}
task javadocJar(type: Jar) {
archiveClassifier.set('javadoc')
from javadoc
}

jacocoTestReport {
Expand All @@ -112,29 +66,77 @@ jacocoTestReport {
}
}

artifacts {
archives sourcesJar
archives javadocJar
}

publishing {
publications {
Bintray(MavenPublication) {
from components.java
main(MavenPublication) {
artifactId = project.name
from(components["java"])
artifact sourcesJar {
classifier "sources"
}
artifact javadocJar {
classifier "javadoc"
}

groupId project.group
artifactId project.name
version project.version.toString()
pom.withXml {
def root = asNode()
root.appendNode('description', 'A extension for Spock to create Github repositories during test.')
root.appendNode('name', 'Spock GitHub extension')
root.appendNode('url', 'https://github.com/thombergs/myAwesomeLib')
root.children().last() + pomConfig
pom {
name = 'Spock GitHub extension'
description = 'A extension for Spock to create Github repositories during test.'
url = 'https://github.com/wooga/spock-github-extension'

artifactId = project.name
inceptionYear = "2019"

scm {
connection = 'scm:git:https://github.com/wooga/spock-github-extension.git'
developerConnection = 'scm:git:https://github.com/wooga/spock-github-extension.git'
url = 'https://github.com/wooga/spock-github-extension.git'
}

licenses {
license {
name = 'The Apache License, Version 2.0'
url = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
}
}

developers {
developer {
id = 'manfred.endres'
name = 'Manfred Endres'
email = '[email protected]'
}
}
}
}
}
}

[finalSetup, candidateSetup, snapshotSetup].each { it.dependsOn(build)}
nexusPublishing {
repositories {
sonatype()
}
}

nexusStaging {
username = project.hasProperty('ossrhUsername') ? project.property('ossrhUsername') : System.getenv('OSSRH_USERNAME')
password = project.hasProperty('ossrhPassword') ? project.property('ossrhPassword') : System.getenv('OSSRH_PASSWORD')
packageGroup = "com.wooga"
}

signing {
def signingKeyId = project.hasProperty("signingKeyId") ? project.property('signingKeyId') : System.getenv('OSSRH_SIGNING_KEY_ID')
def signingKey = project.hasProperty("signingKey") ? project.property('signingKey') : System.getenv('OSSRH_SIGNING_KEY')
def signingPassword = project.hasProperty('signingPassphrase') ? project.property('signingPassphrase') : System.getenv("OSSRH_SIGNING_PASSPHRASE")
useInMemoryPgpKeys(signingKeyId.toString(), signingKey.toString(), signingPassword.toString())
sign publishing.publications.main
}

postRelease.dependsOn(tasks.publish)
tasks."final".dependsOn(tasks.closeAndReleaseRepository)
tasks."candidate".dependsOn(tasks.closeAndReleaseRepository)
tasks.closeAndReleaseRepository.mustRunAfter(tasks.postRelease)
tasks.publish.mustRunAfter(tasks.release)
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.2-all.zip
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ class Repository {
void captureResetRefs() {
try {
resetRefs = repository.refs
} catch(HttpException e) {
if(!e.message.contains("Git Repository is empty.")) {
} catch (HttpException e) {
if (!e.message.contains("Git Repository is empty.")) {
throw e
}
resetRefs = []
Expand Down Expand Up @@ -112,7 +112,8 @@ class Repository {
commitBuilder.message(message)
commitBuilder.tree(commit.tree.getSha())
commitBuilder.parent(commit.getSHA1())
commitBuilder.author(repository.owner.name, repository.owner.email, new Date())
def email = repository.owner.email ?: "[email protected]"
commitBuilder.author(repository.owner.name, email, new Date())
GHCommit newCommit = commitBuilder.create()

GHRef branchRef = getBranchRef(branchName)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@ package com.wooga.spock.extensions.github

import org.kohsuke.github.GHIssueState
import org.kohsuke.github.GHPullRequest
import spock.lang.Retry
import spock.lang.Specification

@Retry(delay = 2000, count = 2, mode = Retry.Mode.SETUP_FEATURE_CLEANUP)
abstract class BaseGithubRepositorySpec extends Specification {

abstract Repository getTestRepository()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,12 @@ package com.wooga.spock.extensions.github

import org.junit.Rule
import org.junit.contrib.java.lang.system.EnvironmentVariables
import spock.lang.Retry
import spock.lang.Shared
import spock.lang.Specification
import spock.lang.Unroll

@Retry(delay = 2000, count = 2, mode = Retry.Mode.SETUP_FEATURE_CLEANUP)
class FeatureAnnotation extends Specification {

@Rule
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,10 @@ import org.kohsuke.github.GHException
import org.kohsuke.github.GHFileNotFoundException
import org.kohsuke.github.GHPullRequest
import org.kohsuke.github.HttpException
import spock.lang.Retry
import spock.lang.Specification

@Retry(delay = 2000, count = 2, mode = Retry.Mode.SETUP_FEATURE_CLEANUP)
class GithubRepositoryBuilderSpec extends Specification {

@Rule
Expand Down Expand Up @@ -84,7 +86,7 @@ class GithubRepositoryBuilderSpec extends Specification {
!repo.isPrivate()

and: "allows pull-request merge commits"
def pr1 = repo.setupPullRequestWithFileChange("Merge PR","","pr/merge")
def pr1 = repo.setupPullRequestWithFileChange("Merge PR", "", "pr/merge")

when:
sleep(200)
Expand All @@ -94,7 +96,7 @@ class GithubRepositoryBuilderSpec extends Specification {
noExceptionThrown()

and: "allows pull-request squash commits"
def pr2 = repo.setupPullRequestWithFileChange("Merge PR","","pr/squash")
def pr2 = repo.setupPullRequestWithFileChange("Merge PR", "", "pr/squash")

when:
sleep(200)
Expand All @@ -104,7 +106,7 @@ class GithubRepositoryBuilderSpec extends Specification {
noExceptionThrown()

and: "allows pull-request rebase commits"
def pr3 = repo.setupPullRequestWithFileChange("Merge PR","","pr/rebase")
def pr3 = repo.setupPullRequestWithFileChange("Merge PR", "", "pr/rebase")

when:
sleep(200)
Expand Down Expand Up @@ -183,7 +185,7 @@ class GithubRepositoryBuilderSpec extends Specification {
@GithubRepository(allowMergeCommit = false)
def "can disable merge commits"(Repository repo) {
given:
def pr1 = repo.setupPullRequestWithFileChange("Merge PR","","pr/merge")
def pr1 = repo.setupPullRequestWithFileChange("Merge PR", "", "pr/merge")

when:
sleep(200)
Expand All @@ -197,7 +199,7 @@ class GithubRepositoryBuilderSpec extends Specification {
@GithubRepository(allowSquashMerge = false)
def "can disable squash commits"(Repository repo) {
given:
def pr1 = repo.setupPullRequestWithFileChange("Merge PR","","pr/squash")
def pr1 = repo.setupPullRequestWithFileChange("Merge PR", "", "pr/squash")

when:
sleep(200)
Expand All @@ -211,7 +213,7 @@ class GithubRepositoryBuilderSpec extends Specification {
@GithubRepository(allowRebaseMerge = false)
def "can disable rebase commits"(Repository repo) {
given:
def pr1 = repo.setupPullRequestWithFileChange("Merge PR","","pr/rebase")
def pr1 = repo.setupPullRequestWithFileChange("Merge PR", "", "pr/rebase")

when:
sleep(200)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@

package com.wooga.spock.extensions.github

import spock.lang.Retry
import spock.lang.Shared

@Retry(delay = 2000, count = 2, mode = Retry.Mode.SETUP_FEATURE_CLEANUP)
class GithubRepositorySpec extends BaseGithubRepositorySpec {

@GithubRepository(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,11 @@

package com.wooga.spock.extensions.github

import spock.lang.Retry
import spock.lang.Shared
import spock.lang.Unroll

@Retry(delay = 2000, count = 2, mode = Retry.Mode.SETUP_FEATURE_CLEANUP)
class GithubSharedAutoResetRepositorySpec extends BaseGithubRepositorySpec {

@Shared
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,11 @@

package com.wooga.spock.extensions.github

import spock.lang.Retry
import spock.lang.Shared
import spock.lang.Unroll

@Retry(delay = 2000, count = 2, mode = Retry.Mode.SETUP_FEATURE_CLEANUP)
class GithubSharedRepositorySpec extends BaseGithubRepositorySpec {

@Shared
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,12 @@ import org.kohsuke.github.GHBranch
import org.kohsuke.github.GHCommit
import org.kohsuke.github.GHRef
import org.kohsuke.github.GHRepository
import spock.lang.Retry
import spock.lang.Shared
import spock.lang.Specification
import spock.lang.Subject

@Retry(delay = 2000, count = 2, mode = Retry.Mode.SETUP_FEATURE_CLEANUP)
class RepositorySpec extends Specification {

@Rule
Expand Down