diff --git a/.travis.yml b/.travis.yml index 7d73d44..b6f6cb7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -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 @@ -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) diff --git a/build.gradle b/build.gradle index 6706061..edee1e2 100644 --- a/build.gradle +++ b/build.gradle @@ -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' + } +} diff --git a/settings.gradle b/settings.gradle index b6ad53d..0a5e425 100644 --- a/settings.gradle +++ b/settings.gradle @@ -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)}" + } +} diff --git a/src/main/java/org/doble/adr/ADRProperties.java b/src/main/java/org/doble/adr/ADRProperties.java index 2317423..bfc51f8 100644 --- a/src/main/java/org/doble/adr/ADRProperties.java +++ b/src/main/java/org/doble/adr/ADRProperties.java @@ -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 { diff --git a/src/main/java/org/doble/adr/TemplateProvider.java b/src/main/java/org/doble/adr/TemplateProvider.java index ef2cabe..76d2de8 100644 --- a/src/main/java/org/doble/adr/TemplateProvider.java +++ b/src/main/java/org/doble/adr/TemplateProvider.java @@ -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 @@ -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); + } } diff --git a/src/main/java/org/doble/commands/CommandInit.java b/src/main/java/org/doble/commands/CommandInit.java index 87f956d..5251df0 100644 --- a/src/main/java/org/doble/commands/CommandInit.java +++ b/src/main/java/org/doble/commands/CommandInit.java @@ -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 {