From 3ef8712f2fec2fed9dcbcbe08fe59013de52ba6d Mon Sep 17 00:00:00 2001 From: Mike Cifelli Date: Sat, 20 Jan 2018 08:34:31 -0500 Subject: [PATCH] Use maven version in greeting --- pom.xml | 35 ++++++++++++++++++++++++++++++++--- src/main/LispMain.java | 9 +++++++-- test/main/MainTest.java | 10 +++++++--- 3 files changed, 46 insertions(+), 8 deletions(-) diff --git a/pom.xml b/pom.xml index 4e15482..3de3c43 100644 --- a/pom.xml +++ b/pom.xml @@ -1,11 +1,18 @@ - + + 4.0.0 - org.bitbucket + + com.gitlab transcendental-lisp - 0.0.1-SNAPSHOT + 1.2.0 + src test + test @@ -14,6 +21,7 @@ + maven-compiler-plugin @@ -23,6 +31,7 @@ 1.8 + org.apache.maven.plugins maven-shade-plugin @@ -43,32 +52,50 @@ + + + org.apache.maven.plugins + maven-jar-plugin + + + + true + true + + + + + com.googlecode.lanterna lanterna 3.0.0 + junit junit 4.12 test + org.hamcrest hamcrest-all 1.3 test + org.fitnesse fitnesse 20161106 test + com.github.stefanbirkner system-rules @@ -76,7 +103,9 @@ test + UTF-8 + \ No newline at end of file diff --git a/src/main/LispMain.java b/src/main/LispMain.java index 6a0200b..80b0574 100644 --- a/src/main/LispMain.java +++ b/src/main/LispMain.java @@ -1,6 +1,7 @@ package main; import static com.googlecode.lanterna.terminal.IOSafeTerminalAdapter.createRuntimeExceptionConvertingAdapter; +import static java.text.MessageFormat.format; import static terminal.LispTerminal.END_OF_SEGMENT; import java.io.IOException; @@ -22,7 +23,7 @@ import terminal.TerminalConfiguration; public class LispMain { - public static final String GREETING = "Transcendental Lisp - Version 1.2.0"; + public static final String GREETING = "Transcendental Lisp - Version {0}"; public static final String ANSI_RESET = "\u001B[0m"; public static final String ANSI_RED = "\u001B[31m"; @@ -91,10 +92,14 @@ public class LispMain { } private void printGreeting() { - output.println(GREETING); + output.println(format(GREETING, getVersion())); output.println(); } + private String getVersion() { + return getClass().getPackage().getImplementationVersion(); + } + private LispInterpreter buildInteractiveInterpreter() { builder.setInput(inputReader, "terminal"); builder.setOutput(output); diff --git a/test/main/MainTest.java b/test/main/MainTest.java index b829961..7ef6d74 100644 --- a/test/main/MainTest.java +++ b/test/main/MainTest.java @@ -1,5 +1,6 @@ package main; +import static com.googlecode.lanterna.input.KeyType.Enter; import static java.text.MessageFormat.format; import static main.LispMain.ANSI_GREEN; import static main.LispMain.ANSI_PURPLE; @@ -19,7 +20,6 @@ import org.junit.contrib.java.lang.system.ExpectedSystemExit; import org.junit.contrib.java.lang.system.SystemErrRule; import org.junit.contrib.java.lang.system.SystemOutRule; -import com.googlecode.lanterna.input.KeyType; import com.googlecode.lanterna.terminal.virtual.DefaultVirtualTerminal; import environment.RuntimeEnvironment; @@ -76,6 +76,10 @@ public class MainTest { return systemErrRule.getLogWithNormalizedLineSeparator(); } + private String getExpectedGreeting() { + return format(GREETING, getClass().getPackage().getImplementationVersion()); + } + @Rule public ExpectedSystemExit exit = ExpectedSystemExit.none(); @@ -123,10 +127,10 @@ public class MainTest { terminal.waitForPrompt(); terminal.enterCharacters("'hi"); - terminal.pressKey(KeyType.Enter); + terminal.pressKey(Enter); terminal.waitForPrompt(); terminal.assertCursorPosition(2, 5); - terminal.assertScreenText(GREETING, " ", "~ 'hi ", " ", "HI ", "~ "); + terminal.assertScreenText(getExpectedGreeting(), " ", "~ 'hi ", " ", "HI ", "~ "); terminal.enterControlCharacter('d'); terminal.assertInputStreamClosed();