Skip to content

Commit 4f88daa

Browse files
Merge pull request #5 from watson-developer-cloud/gradle-release
Setup gradle releases to maven central
2 parents a688249 + fb12c72 commit 4f88daa

File tree

11 files changed

+205
-33
lines changed

11 files changed

+205
-33
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: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,20 @@ 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
@@ -10,5 +24,23 @@ script:
1024
after_success:
1125
- bash <(curl -s https://codecov.io/bash)
1226

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

README.md

Lines changed: 7 additions & 7 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/watson-spring-boot-starter/badge.svg)](https://maven-badges.herokuapp.com/maven-central/com.ibm.watson.developer_cloud/watson-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

@@ -13,20 +13,20 @@ using the standard Spring autoconfiguration framework.
1313

1414
All you need to do is:
1515

16-
1. Add the Watson spring-boot-starter dependency to your Spring Boot app:
16+
1. Add the Watson `watson-spring-boot-starter` dependency to your Spring Boot app:
1717

1818
In your maven `pom.xml`
1919
```
2020
<dependency>
2121
<groupId>com.ibm.watson.developer_cloud</groupId>
22-
<artifactId>spring-boot-starter</artifactId>
23-
<version>4.2.1</version>
22+
<artifactId>watson-spring-boot-starter</artifactId>
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:watson-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: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
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%22watson-spring-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+
### Travis setup
34+
35+
Travis should have the following environment variables setup:
36+
* `CI_DEPLOY_USERNAME`: JIRA username with write permission
37+
* `CI_DEPLOY_PASSWORD`: JIRA password for the username above
38+
* `SIGNING_KEY`: PGP public key id
39+
* `SIGNING_PASSWORD`: PGP public key password
40+
* `SIGNING_KEYRING_PATH`: Relative path to the public key
41+
* `GITHUB_TOKEN`: Github token
42+
[bumpversion]: https://pypi.python.org/pypi/bumpversion

VERSION

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

build.gradle

Lines changed: 100 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -22,26 +22,47 @@ buildscript {
2222
}
2323

2424
plugins {
25-
id 'net.researchgate.release' version '2.6.0'
25+
id 'com.github.johnrengelman.shadow' version '1.2.4'
26+
id 'io.codearte.nexus-staging' version '0.11.0'
2627
}
2728

2829
apply plugin: 'java'
2930
apply plugin: 'checkstyle'
31+
apply plugin: 'signing'
32+
apply plugin: 'maven'
33+
3034
apply plugin: 'eclipse'
3135
apply plugin: 'idea'
3236

3337
apply plugin: 'propdeps'
3438
apply plugin: 'propdeps-maven'
3539

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

42+
archivesBaseName = 'watson-spring-boot-starter'
3843
description = 'Spring Boot Starter for the IBM Watson Services'
3944

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

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

4667
checkstyle {
4768
configFile = rootProject.file('checkstyle.xml')
@@ -56,26 +77,19 @@ checkstyleTest {
5677
ignoreFailures = false
5778
}
5879

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-
6980
sourceCompatibility = 1.8
7081
targetCompatibility = 1.8
7182

7283
repositories {
7384
mavenCentral()
7485
}
7586

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

8094
dependencies {
8195
// Watson Java SDK
@@ -99,8 +113,8 @@ compileJava.dependsOn(processResources)
99113

100114
test {
101115
testLogging {
102-
events "failed"
103-
exceptionFormat "full"
116+
events 'failed'
117+
exceptionFormat 'full'
104118
}
105119
}
106120

@@ -118,7 +132,70 @@ task codeCoverageReport(type: JacocoReport, dependsOn: test) {
118132
}
119133
}
120134

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

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

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: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/usr/bin/env bash
2+
3+
openssl aes-256-cbc -K $encrypted_c32defe8b915_key -iv $encrypted_c32defe8b915_iv -in scripts/secring.gpg.enc -out scripts/secring.gpg -d
4+
./gradlew uploadArchives -Psigning.keyId=$SIGNING_KEY -Psigning.password=$SIGNING_PASSWORD -Psigning.secretKeyRingFile=./scripts/secring.gpg
5+
./gradlew closeAndReleaseRepository -PnexusUsername=$CI_DEPLOY_USERNAME -PnexusPassword=$CI_DEPLOY_PASSWORD

0 commit comments

Comments
 (0)