Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable unit tests in gradle build #29

Merged
merged 4 commits into from
Nov 10, 2019
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
8 changes: 7 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,14 @@ env:
- GRADLE_OPTS=-Dorg.gradle.daemon=false
- TERM=dumb

# https://docs.travis-ci.com/user/languages/java/#caching
before_cache:
- rm -f $HOME/.gradle/caches/modules-2/modules-2.lock
- rm -fr $HOME/.gradle/caches/*/plugin-resolution/
cache:
directories:
- /home/travis/.gradle/
- $HOME/.gradle/caches/
- $HOME/.gradle/wrapper/

language: shell

Expand All @@ -24,6 +29,7 @@ install:
- if [[ "$TRAVIS_OS_NAME" == "windows" ]]; then choco install windows-sdk-7.1 kb2519277; fi

script:
- if [[ "$TRAVIS_OS_NAME" == "windows" ]]; then JAVA_HOME="C:/Program Files/Java/jdk1.8.0_221" ./gradlew check; else ./gradlew check; fi
# JAR is equal on Linux and Windows. So just build on Linux
- if [[ "$TRAVIS_OS_NAME" != "windows" ]]; then ./gradlew shadowJar; fi
# build native executable (windows: adr.exe, linux: adr)
Expand Down
7 changes: 7 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,10 @@ task releaseJar(dependsOn: "shadowJar", type: Copy) {
//file("$buildDir/releases/adr-j-${project.version}.jar").setExecutable(true, false)
file("$buildDir/releases/adr-j.jar").setExecutable(true, false)
}

tasks.withType(Test).configureEach {
useJUnitPlatform()
testLogging {
exceptionFormat = 'full'
}
}
7 changes: 7 additions & 0 deletions settings.gradle
Original file line number Diff line number Diff line change
@@ -1 +1,8 @@
rootProject.name = 'adr-j'

buildCache {
// force travis to use different build caches for each OS
local {
directory = "${settingsDir}/.gradle/caches/build-cache-${System.properties['os.name'].substring(0, 4).toLowerCase(Locale.ROOT)}"
}
}
1 change: 0 additions & 1 deletion src/main/java/org/doble/adr/ADRProperties.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ public ADRProperties(Environment env) {
/**
* Reads the .adr properties file at the root directory of the project.
*
* @return A Properties object with the data contained in the properties file
* @throws ADRException if the properties file cannot be read
*/
public void load() throws ADRException {
Expand Down
10 changes: 6 additions & 4 deletions src/main/java/org/doble/adr/TemplateProvider.java
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,8 @@ private Path getResourcePath(String templateFileName) throws URISyntaxException,
} else {
// Assume that the system resource is a normal file (e.g. we are running in an IDE).
String pathName = uri.getSchemeSpecificPart();
// If there is a leading '/' then remove it so we have a correct path specification.
if (pathName.startsWith("/")) {
// If there is a leading '/' then remove it if we run on Windows so we have a correct path specification.
if (runsOnWindows() && pathName.startsWith("/")) {
pathName = pathName.substring(1);
}
// The resource file is in the default file system and not any file system
Expand All @@ -119,6 +119,8 @@ private Path getResourcePath(String templateFileName) throws URISyntaxException,
}
return templatePath;
}



private boolean runsOnWindows() {
return System.getProperty("os.name").regionMatches(true, 0, "win", 0, 3);
}
}
4 changes: 2 additions & 2 deletions src/main/java/org/doble/commands/CommandInit.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
@Command(name = "init",
description = "Initialises the directory of architecture decision records:\n" +
" * creates a subdirectory of the current working directory\n" +
" * creates the first ADR in that subdirectory, recording the decision to\n" +
" record architectural decisions with ADRs."
" * creates the first ADR in that subdirectory, recording the decision to" +
" record architectural decisions with ADRs."
)
public class CommandInit implements Callable<Integer> {

Expand Down