Skip to content

Commit 7159712

Browse files
🆕 setup gradle releases to maven central
1 parent a688249 commit 7159712

File tree

11 files changed

+216
-31
lines changed

11 files changed

+216
-31
lines changed

.bumpversion.cfg

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
[bumpversion]
2+
current_version = 0.0.1
3+
commit = True
4+
tag = True
5+
6+
[bumpversion:file:README.md]
7+
[bumpversion:file:gradle.properties]
8+
9+
search = {current_version}
10+
replace = {new_version}

.github/CONTRIBUTING.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ please ask a question on [dW Answers][dw] or [Stack Overflow][stackoverflow].
66
# Issues
77

88
If you encounter an issue with the Watson Spring Boot support, you are welcome to submit a
9-
[bug report](https://github.com/watson-developer-cloud/watson-spring/issues).
9+
[bug report](https://github.com/watson-developer-cloud/spring-boot-starter/issues).
1010
Before that, please search for similar issues. It's possible somebody has encountered this issue already.
1111

1212
# Pull Requests
@@ -19,7 +19,7 @@ If you want to contribute to the repository, here's a quick guide:
1919
* Create minimal diffs - disable on save actions like reformat source code or organize imports. If you feel the source code should be reformatted create a separate PR for this change.
2020
* Check for unnecessary whitespace with git diff --check before committing.
2121
3. Make the test pass
22-
4. Commit your changes:
22+
4. Commit your changes:
2323
* Use the present tense (`"Add feature"` not `"Added Feature"`)
2424
* Use the imperative mood (`"Move cursor to…"` not `"Moves cursor to…"`)
2525
* Include relevant Emoji from our [Emoji cheatsheet](#emoji-cheatsheet)

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,5 @@ target
2727
*.ipr
2828
*.iws
2929

30+
/bin/
31+
scripts/secring.gpg

.travis.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,46 @@ language: java
22
jdk:
33
- oraclejdk8
44

5+
6+
before_cache:
7+
- rm -f $HOME/.gradle/caches/modules-2/modules-2.lock
8+
- rm -fr $HOME/.gradle/caches/*/plugin-resolution/
9+
10+
cache:
11+
directories:
12+
- $HOME/.m2
13+
- $HOME/.gradle/caches/
14+
- $HOME/.gradle/wrapper/
15+
16+
before_install:
17+
- sed -i.bak -e 's|https://nexus.codehaus.org/snapshots/|https://oss.sonatype.org/content/repositories/codehaus-snapshots/|g' ~/.m2/settings.xml
18+
519
script:
620
- ./gradlew check
721
- ./gradlew install -x check
22+
- ./gradlew checkstyleMain
23+
- ./gradlew checkstyleTest
824
- ./gradlew codeCoverageReport --continue
925

1026
after_success:
1127
- bash <(curl -s https://codecov.io/bash)
1228

29+
deploy:
30+
- provider: script
31+
script: scripts/deploy.sh
32+
skip_cleanup: true
33+
on:
34+
repo: watson-developer-cloud/spring-boot-starter
35+
jdk: oraclejdk8
36+
37+
- provider: releases
38+
api_key: ${GITHUB_TOKEN}
39+
file: spring-boot-starter/build/libs/spring-boot-starter-${TRAVIS_BRANCH}-jar-with-dependencies.jar
40+
skip_cleanup: true
41+
on:
42+
repo: watson-developer-cloud/spring-boot-starter
43+
jdk: oraclejdk8
44+
tags: true
45+
1346
notifications:
1447
email: true

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# Watson Spring Boot
22

3-
[![Build Status](https://travis-ci.org/watson-developer-cloud/watson-spring.svg?branch=master)](https://travis-ci.org/watson-developer-cloud/watson-spring)
4-
[![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.ibm.watson.developer_cloud/watson-spring/badge.svg)](https://maven-badges.herokuapp.com/maven-central/com.ibm.watson.developer_cloud/watson-spring)
5-
[![CLA assistant](https://cla-assistant.io/readme/badge/watson-developer-cloud/watson-spring)](https://cla-assistant.io/watson-developer-cloud/watson-spring)
3+
[![Build Status](https://travis-ci.org/watson-developer-cloud/spring-boot-starter.svg?branch=master)](https://travis-ci.org/watson-developer-cloud/spring-boot-starter)
4+
[![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.ibm.watson.developer_cloud/spring-boot-starter/badge.svg)](https://maven-badges.herokuapp.com/maven-central/com.ibm.watson.developer_cloud/spring-boot-starter)
5+
[![CLA assistant](https://cla-assistant.io/readme/badge/watson-developer-cloud/spring-boot-starter)](https://cla-assistant.io/watson-developer-cloud/spring-boot-starter)
66

77
This project adds Spring Boot support for the Watson services.
88

@@ -20,13 +20,13 @@ All you need to do is:
2020
<dependency>
2121
<groupId>com.ibm.watson.developer_cloud</groupId>
2222
<artifactId>spring-boot-starter</artifactId>
23-
<version>4.2.1</version>
23+
<version>0.0.1</version>
2424
</dependency>
2525
```
2626
2727
or in your gradle `build.gradle`, in the dependencies stanza, add
2828
```
29-
compile 'com.ibm.watson.developer_cloud:spring-boot-starter:4.2.1'
29+
compile 'com.ibm.watson.developer_cloud:spring-boot-starter:0.0.1'
3030
```
3131
3232
2. Add your Watson service(s) credentials and version info to your application

RELEASES.md

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# Release Process
2+
3+
* code: https://github.com/watson-developer-cloud/spring-boot-starter
4+
* maven: http://search.maven.org/#search%7Cga%7C1%7Ca%3A%22spring-boot-starter%22
5+
6+
## Guide to uploading artifacts to the Central Repository
7+
8+
We use Sonatype as repository manager, it's used as the input channel for the Central Repository running the Sonatype Open Source Repository Hosting(OSSRH) service.
9+
10+
### Prerequisites
11+
12+
If you are not familiar with Sonatype and/or the maven release process please read the following material:
13+
14+
* Releasing artifacts to Sonatype using Gradle: http://central.sonatype.org/pages/gradle.html
15+
* Install GPG, and create a public key. More info: http://central.sonatype.org/pages/working-with-pgp-signatures.html
16+
17+
### Release steps
18+
19+
1. Update all READMEs to include the new version number
20+
21+
This can be done using [bumpversion]. If necessary, it can be installed with the following command:
22+
23+
```bash
24+
pip install bumpversion
25+
```
26+
27+
To then update all version numbers, simply run:
28+
29+
```bash
30+
bumpversion major|minor|patch
31+
```
32+
33+
1. Perform a release deployment to OSSRH (Staging) with:
34+
35+
```bash
36+
gradle release
37+
```
38+
39+
You will have to answer prompts for versions and tags. That will tag and commit a new version into your repository automatically.
40+
41+
42+
### Travis setup
43+
44+
Travis should have the following environment variables setup:
45+
* `CI_DEPLOY_USERNAME`: JIRA username with write permission
46+
* `CI_DEPLOY_PASSWORD`: JIRA password for the username above
47+
* `SIGNING_KEY`: PGP public key id
48+
* `SIGNING_PASSWORD`: PGP public key password
49+
* `SIGNING_KEYRING_PATH`: Relative path to the public key
50+
* `GITHUB_TOKEN`: Github token
51+
[bumpversion]: https://pypi.python.org/pypi/bumpversion

VERSION

Lines changed: 0 additions & 1 deletion
This file was deleted.

build.gradle

Lines changed: 101 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -21,27 +21,49 @@ buildscript {
2121
}
2222
}
2323

24+
2425
plugins {
25-
id 'net.researchgate.release' version '2.6.0'
26+
id 'com.github.johnrengelman.shadow' version '1.2.4'
27+
id 'io.codearte.nexus-staging' version '0.11.0'
2628
}
2729

2830
apply plugin: 'java'
2931
apply plugin: 'checkstyle'
32+
apply plugin: 'signing'
33+
apply plugin: 'maven'
34+
3035
apply plugin: 'eclipse'
3136
apply plugin: 'idea'
3237

3338
apply plugin: 'propdeps'
3439
apply plugin: 'propdeps-maven'
3540

36-
archivesBaseName = 'spring-boot-starter'
41+
import org.apache.tools.ant.filters.*
3742

43+
archivesBaseName = 'spring-boot-starter'
3844
description = 'Spring Boot Starter for the IBM Watson Services'
3945

40-
group = 'com.ibm.watson.developer_cloud'
41-
version = new File(rootDir, 'VERSION').text.trim()
46+
task sourcesJar(type: Jar) {
47+
classifier = 'sources'
48+
from sourceSets.main.allSource
49+
}
4250

43-
// If the version says "snapshot" anywhere assume it is not a release
44-
ext.isReleaseVersion = !version.toUpperCase(Locale.ENGLISH).contains("SNAPSHOT")
51+
task javadocJar(type: Jar) {
52+
classifier = 'javadoc'
53+
from javadoc
54+
}
55+
56+
shadowJar {
57+
classifier = 'jar-with-dependencies'
58+
}
59+
60+
artifacts {
61+
archives sourcesJar
62+
archives javadocJar
63+
archives shadowJar
64+
}
65+
66+
project.tasks.assemble.dependsOn project.tasks.shadowJar
4567

4668
checkstyle {
4769
configFile = rootProject.file('checkstyle.xml')
@@ -56,26 +78,19 @@ checkstyleTest {
5678
ignoreFailures = false
5779
}
5880

59-
task copyJars(type: Copy) {
60-
from subprojects.collect { it.tasks.withType(Jar) }
61-
into "$buildDir/allJars"
62-
}
63-
64-
task signJars(type: Copy) {
65-
from subprojects.collect { it.tasks.withType(Sign) }
66-
into "$buildDir/allJars"
67-
}
68-
6981
sourceCompatibility = 1.8
7082
targetCompatibility = 1.8
7183

7284
repositories {
7385
mavenCentral()
7486
}
7587

76-
ext.watsonVersion = '4.2.1'
77-
ext.springVersion = '4.3.12.RELEASE'
78-
ext.springBootVersion = '1.5.9.RELEASE'
88+
processResources {
89+
filter ReplaceTokens, tokens: [
90+
'pom.version': project.version,
91+
'build.date' : getDate()
92+
]
93+
}
7994

8095
dependencies {
8196
// Watson Java SDK
@@ -99,8 +114,8 @@ compileJava.dependsOn(processResources)
99114

100115
test {
101116
testLogging {
102-
events "failed"
103-
exceptionFormat "full"
117+
events 'failed'
118+
exceptionFormat 'full'
104119
}
105120
}
106121

@@ -118,7 +133,70 @@ task codeCoverageReport(type: JacocoReport, dependsOn: test) {
118133
}
119134
}
120135

121-
release {
122-
tagTemplate = 'watson-spring-boot-$version'
136+
signing {
137+
sign configurations.archives
138+
}
139+
140+
signArchives {
141+
onlyIf { Task task ->
142+
def shouldExec = false
143+
for (myArg in project.gradle.startParameter.taskRequests[0].args) {
144+
if (myArg.toLowerCase().contains('signjars') || myArg.toLowerCase().contains('uploadarchives')) {
145+
shouldExec = true
146+
}
147+
}
148+
return shouldExec
149+
}
150+
}
151+
152+
uploadArchives {
153+
repositories {
154+
mavenDeployer {
155+
beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }
156+
157+
repository(url: "http://oss.sonatype.org/service/local/staging/deploy/maven2/") {
158+
authentication(userName: System.env.CI_DEPLOY_USERNAME, password: System.env.CI_DEPLOY_PASSWORD)
159+
}
160+
snapshotRepository(url: "https://oss.sonatype.org/content/repositories/snapshots/"){
161+
authentication(userName: System.env.CI_DEPLOY_USERNAME, password: System.env.CI_DEPLOY_PASSWORD)
162+
}
163+
pom.project {
164+
name 'IBM Watson Spring boot starter'
165+
packaging 'jar'
166+
description 'Spring Boot Starter for the IBM Watson Services'
167+
url 'https://www.ibm.com/watson/developer'
168+
169+
scm {
170+
connection 'scm:git:[email protected]:watson-developer-cloud/spring-boot-starter.git'
171+
developerConnection 'scm:git:[email protected]:watson-developer-cloud/spring-boot-starter.git'
172+
url 'https://github.com/watson-developer-cloud/spring-boot-starter'
173+
}
174+
175+
licenses {
176+
license {
177+
name 'The Apache License, Version 2.0'
178+
url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
179+
}
180+
}
181+
182+
developers {
183+
developer {
184+
id 'german'
185+
name 'German Attanasio'
186+
187+
}
188+
}
189+
}
190+
}
191+
}
192+
}
193+
194+
def getDate() {
195+
def date = new Date()
196+
def formattedDate = date.format('yyyyMMddHHmmss')
197+
return formattedDate
123198
}
124199

200+
ext {
201+
getDate = this.&getDate
202+
}

gradle.properties

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
version=0.0.1
2+
group = com.ibm.watson.developer_cloud
3+
watsonVersion = 4.2.1
4+
springVersion = 4.3.12.RELEASE
5+
springBootVersion = 1.5.9.RELEASE

scripts/deploy.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/usr/bin/env bash
2+
3+
if [ "$TRAVIS_PULL_REQUEST" == "false" ] && [ "$TRAVIS_BRANCH" == "master" ]; then
4+
openssl aes-256-cbc -K $encrypted_c32defe8b915_key -iv $encrypted_c32defe8b915_iv -in secring.gpg.enc -out scripts/secring.gpg -d
5+
./gradlew uploadArchives -Psigning.keyId=$SIGNING_KEY -Psigning.password=$SIGNING_PASSWORD -Psigning.secretKeyRingFile=./scripts/secring.gpg
6+
./gradlew closeAndReleaseRepository
7+
fi

0 commit comments

Comments
 (0)