Skip to content

Commit a688249

Browse files
Merge pull request #2 from watson-developer-cloud/mdk/build-and-test-improvements
Build and test improvements
2 parents 13d2d94 + c8c72e6 commit a688249

13 files changed

+119
-61
lines changed

.travis.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
language: java
2+
jdk:
3+
- oraclejdk8
4+
5+
script:
6+
- ./gradlew check
7+
- ./gradlew install -x check
8+
- ./gradlew codeCoverageReport --continue
9+
10+
after_success:
11+
- bash <(curl -s https://codecov.io/bash)
12+
13+
notifications:
14+
email: true

build.gradle

Lines changed: 7 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ buildscript {
2222
}
2323

2424
plugins {
25-
id 'net.researchgate.release' version '2.4.0'
25+
id 'net.researchgate.release' version '2.6.0'
2626
}
2727

2828
apply plugin: 'java'
@@ -33,8 +33,6 @@ apply plugin: 'idea'
3333
apply plugin: 'propdeps'
3434
apply plugin: 'propdeps-maven'
3535

36-
import org.apache.tools.ant.filters.*
37-
3836
archivesBaseName = 'spring-boot-starter'
3937

4038
description = 'Spring Boot Starter for the IBM Watson Services'
@@ -45,10 +43,6 @@ version = new File(rootDir, 'VERSION').text.trim()
4543
// If the version says "snapshot" anywhere assume it is not a release
4644
ext.isReleaseVersion = !version.toUpperCase(Locale.ENGLISH).contains("SNAPSHOT")
4745

48-
javadoc {
49-
source = 'src/main/java'
50-
}
51-
5246
checkstyle {
5347
configFile = rootProject.file('checkstyle.xml')
5448
ignoreFailures = false
@@ -62,10 +56,6 @@ checkstyleTest {
6256
ignoreFailures = false
6357
}
6458

65-
task docs(type: Javadoc) {
66-
destinationDir = file("$buildDir/docs/all")
67-
}
68-
6959
task copyJars(type: Copy) {
7060
from subprojects.collect { it.tasks.withType(Jar) }
7161
into "$buildDir/allJars"
@@ -101,6 +91,7 @@ dependencies {
10191

10292
// testing
10393
testCompile group: 'junit', name: 'junit', version: '4.12'
94+
testCompile 'com.github.stefanbirkner:system-rules:1.16.0'
10495
testCompile group: 'org.springframework.boot', name: 'spring-boot-starter-test', version: springBootVersion
10596
}
10697

@@ -113,49 +104,20 @@ test {
113104
}
114105
}
115106

116-
afterEvaluate {
117-
if (plugins.hasPlugin(JavaPlugin)) {
118-
rootProject.tasks.docs {
119-
source += files(sourceSets.main.allJava)
120-
classpath += files(sourceSets*.compileClasspath)
121-
}
122-
}
123-
}
124-
125107
apply plugin: 'jacoco'
126108

127-
task codeCoverageReport(type: JacocoReport) {
128-
// Gather execution data from all sub projects
129-
// (change this if you e.g. want to calculate unit test/integration test coverage separately)
109+
task codeCoverageReport(type: JacocoReport, dependsOn: test) {
130110
executionData fileTree(project.rootDir.absolutePath).include("**/build/jacoco/*.exec")
131-
132-
// Add all relevant source sets from the sub projects
133-
subprojects.each {
134-
sourceSets it.sourceSets.main
135-
}
111+
sourceDirectories = files(sourceSets.main.allSource.srcDirs)
112+
classDirectories = files(sourceSets.main.output)
136113

137114
reports {
138-
xml.enabled true
139-
xml.destination file("${buildDir}/reports/jacoco/report.xml")
140-
html.enabled true
141-
html.destination file("${buildDir}/reports/jacoco")
142115
csv.enabled false
116+
html.destination file("${buildDir}/reports/jacoco")
117+
xml.destination file("${buildDir}/reports/jacoco/report.xml")
143118
}
144119
}
145120

146-
// always run the tests before generating the report
147-
codeCoverageReport.dependsOn {
148-
subprojects*.test
149-
testReport
150-
}
151-
152-
task testReport(type: TestReport) {
153-
destinationDir = file("$buildDir/reports/allTests")
154-
155-
// Include the results from the `test` task in all subprojects
156-
reportOn subprojects*.test
157-
}
158-
159121
release {
160122
tagTemplate = 'watson-spring-boot-$version'
161123
}

src/test/java/com/ibm/watson/developer_cloud/spring/boot/test/ConversationAutoConfigTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,11 @@ public void conversationBeanConfig() {
6161
try {
6262
Field apiKeyField = WatsonService.class.getDeclaredField("apiKey");
6363
apiKeyField.setAccessible(true);
64-
assertEquals(Credentials.basic(username, password), (String) apiKeyField.get(conversation));
64+
assertEquals(Credentials.basic(username, password), apiKeyField.get(conversation));
6565

6666
Field versionField = Conversation.class.getDeclaredField("versionDate");
6767
versionField.setAccessible(true);
68-
assertEquals(versionDate, (String) versionField.get(conversation));
68+
assertEquals(versionDate, versionField.get(conversation));
6969
} catch (NoSuchFieldException | IllegalAccessException ex) {
7070
// This shouldn't happen
7171
assert false;

src/test/java/com/ibm/watson/developer_cloud/spring/boot/test/DiscoveryAutoConfigTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,11 @@ public void discoveryBeanConfig() {
6161
try {
6262
Field apiKeyField = WatsonService.class.getDeclaredField("apiKey");
6363
apiKeyField.setAccessible(true);
64-
assertEquals(Credentials.basic(username, password), (String) apiKeyField.get(discovery));
64+
assertEquals(Credentials.basic(username, password), apiKeyField.get(discovery));
6565

6666
Field versionField = Discovery.class.getDeclaredField("versionDate");
6767
versionField.setAccessible(true);
68-
assertEquals(versionDate, (String) versionField.get(discovery));
68+
assertEquals(versionDate, versionField.get(discovery));
6969
} catch (NoSuchFieldException | IllegalAccessException ex) {
7070
// This shouldn't happen
7171
assert false;

src/test/java/com/ibm/watson/developer_cloud/spring/boot/test/LanguageTranslatorAutoConfigTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public void languageTranslatorBeanConfig() {
5959
try {
6060
Field apiKeyField = WatsonService.class.getDeclaredField("apiKey");
6161
apiKeyField.setAccessible(true);
62-
assertEquals(Credentials.basic(username, password), (String) apiKeyField.get(languageTranslator));
62+
assertEquals(Credentials.basic(username, password), apiKeyField.get(languageTranslator));
6363
} catch (NoSuchFieldException | IllegalAccessException ex) {
6464
// This shouldn't happen
6565
assert false;

src/test/java/com/ibm/watson/developer_cloud/spring/boot/test/NaturalLanguageClassifierAutoConfigTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public void naturalLanguageClassifierBeanConfig() {
6060
try {
6161
Field apiKeyField = WatsonService.class.getDeclaredField("apiKey");
6262
apiKeyField.setAccessible(true);
63-
assertEquals(Credentials.basic(username, password), (String) apiKeyField.get(naturalLanguageClassifier));
63+
assertEquals(Credentials.basic(username, password), apiKeyField.get(naturalLanguageClassifier));
6464
} catch (NoSuchFieldException | IllegalAccessException ex) {
6565
// This shouldn't happen
6666
assert false;

src/test/java/com/ibm/watson/developer_cloud/spring/boot/test/NaturalLanguageUnderstandingAutoConfigTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,11 @@ public void naturalLanguageUnderstandingBeanConfig() {
6262
try {
6363
Field apiKeyField = WatsonService.class.getDeclaredField("apiKey");
6464
apiKeyField.setAccessible(true);
65-
assertEquals(Credentials.basic(username, password), (String) apiKeyField.get(naturalLanguageUnderstanding));
65+
assertEquals(Credentials.basic(username, password), apiKeyField.get(naturalLanguageUnderstanding));
6666

6767
Field versionField = NaturalLanguageUnderstanding.class.getDeclaredField("versionDate");
6868
versionField.setAccessible(true);
69-
assertEquals(versionDate, (String) versionField.get(naturalLanguageUnderstanding));
69+
assertEquals(versionDate, versionField.get(naturalLanguageUnderstanding));
7070
} catch (NoSuchFieldException | IllegalAccessException ex) {
7171
// This shouldn't happen
7272
assert false;

src/test/java/com/ibm/watson/developer_cloud/spring/boot/test/PersonalityInsightsAutoConfigTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,11 @@ public void personalityInsightsBeanConfig() {
6161
try {
6262
Field apiKeyField = WatsonService.class.getDeclaredField("apiKey");
6363
apiKeyField.setAccessible(true);
64-
assertEquals(Credentials.basic(username, password), (String) apiKeyField.get(personalityInsights));
64+
assertEquals(Credentials.basic(username, password), apiKeyField.get(personalityInsights));
6565

6666
Field versionField = PersonalityInsights.class.getDeclaredField("versionDate");
6767
versionField.setAccessible(true);
68-
assertEquals(versionDate, (String) versionField.get(personalityInsights));
68+
assertEquals(versionDate, versionField.get(personalityInsights));
6969
} catch (NoSuchFieldException | IllegalAccessException ex) {
7070
// This shouldn't happen
7171
assert false;

src/test/java/com/ibm/watson/developer_cloud/spring/boot/test/SpeechToTextAutoConfigTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public void speechToTextBeanConfig() {
5959
try {
6060
Field apiKeyField = WatsonService.class.getDeclaredField("apiKey");
6161
apiKeyField.setAccessible(true);
62-
assertEquals(Credentials.basic(username, password), (String) apiKeyField.get(speechToText));
62+
assertEquals(Credentials.basic(username, password), apiKeyField.get(speechToText));
6363
} catch (NoSuchFieldException | IllegalAccessException ex) {
6464
// This shouldn't happen
6565
assert false;

src/test/java/com/ibm/watson/developer_cloud/spring/boot/test/TextToSpeechAutoConfigTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public void textToSpeechBeanConfig() {
5959
try {
6060
Field apiKeyField = WatsonService.class.getDeclaredField("apiKey");
6161
apiKeyField.setAccessible(true);
62-
assertEquals(Credentials.basic(username, password), (String) apiKeyField.get(textToSpeech));
62+
assertEquals(Credentials.basic(username, password), apiKeyField.get(textToSpeech));
6363
} catch (NoSuchFieldException | IllegalAccessException ex) {
6464
// This shouldn't happen
6565
assert false;

0 commit comments

Comments
 (0)