Use maven version in greeting

This commit is contained in:
Mike Cifelli 2018-01-20 08:34:31 -05:00
parent 735f1d584a
commit 3ef8712f2f
3 changed files with 46 additions and 8 deletions

35
pom.xml
View File

@ -1,11 +1,18 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <project
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>org.bitbucket</groupId>
<groupId>com.gitlab</groupId>
<artifactId>transcendental-lisp</artifactId> <artifactId>transcendental-lisp</artifactId>
<version>0.0.1-SNAPSHOT</version> <version>1.2.0</version>
<build> <build>
<sourceDirectory>src</sourceDirectory> <sourceDirectory>src</sourceDirectory>
<testSourceDirectory>test</testSourceDirectory> <testSourceDirectory>test</testSourceDirectory>
<testResources> <testResources>
<testResource> <testResource>
<directory>test</directory> <directory>test</directory>
@ -14,6 +21,7 @@
</excludes> </excludes>
</testResource> </testResource>
</testResources> </testResources>
<plugins> <plugins>
<plugin> <plugin>
<artifactId>maven-compiler-plugin</artifactId> <artifactId>maven-compiler-plugin</artifactId>
@ -23,6 +31,7 @@
<target>1.8</target> <target>1.8</target>
</configuration> </configuration>
</plugin> </plugin>
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId> <artifactId>maven-shade-plugin</artifactId>
@ -43,32 +52,50 @@
</execution> </execution>
</executions> </executions>
</plugin> </plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifest>
<addDefaultImplementationEntries>true</addDefaultImplementationEntries>
<addDefaultSpecificationEntries>true</addDefaultSpecificationEntries>
</manifest>
</archive>
</configuration>
</plugin>
</plugins> </plugins>
</build> </build>
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>com.googlecode.lanterna</groupId> <groupId>com.googlecode.lanterna</groupId>
<artifactId>lanterna</artifactId> <artifactId>lanterna</artifactId>
<version>3.0.0</version> <version>3.0.0</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>junit</groupId> <groupId>junit</groupId>
<artifactId>junit</artifactId> <artifactId>junit</artifactId>
<version>4.12</version> <version>4.12</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.hamcrest</groupId> <groupId>org.hamcrest</groupId>
<artifactId>hamcrest-all</artifactId> <artifactId>hamcrest-all</artifactId>
<version>1.3</version> <version>1.3</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.fitnesse</groupId> <groupId>org.fitnesse</groupId>
<artifactId>fitnesse</artifactId> <artifactId>fitnesse</artifactId>
<version>20161106</version> <version>20161106</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.github.stefanbirkner</groupId> <groupId>com.github.stefanbirkner</groupId>
<artifactId>system-rules</artifactId> <artifactId>system-rules</artifactId>
@ -76,7 +103,9 @@
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
</dependencies> </dependencies>
<properties> <properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties> </properties>
</project> </project>

View File

@ -1,6 +1,7 @@
package main; package main;
import static com.googlecode.lanterna.terminal.IOSafeTerminalAdapter.createRuntimeExceptionConvertingAdapter; import static com.googlecode.lanterna.terminal.IOSafeTerminalAdapter.createRuntimeExceptionConvertingAdapter;
import static java.text.MessageFormat.format;
import static terminal.LispTerminal.END_OF_SEGMENT; import static terminal.LispTerminal.END_OF_SEGMENT;
import java.io.IOException; import java.io.IOException;
@ -22,7 +23,7 @@ import terminal.TerminalConfiguration;
public class LispMain { 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_RESET = "\u001B[0m";
public static final String ANSI_RED = "\u001B[31m"; public static final String ANSI_RED = "\u001B[31m";
@ -91,10 +92,14 @@ public class LispMain {
} }
private void printGreeting() { private void printGreeting() {
output.println(GREETING); output.println(format(GREETING, getVersion()));
output.println(); output.println();
} }
private String getVersion() {
return getClass().getPackage().getImplementationVersion();
}
private LispInterpreter buildInteractiveInterpreter() { private LispInterpreter buildInteractiveInterpreter() {
builder.setInput(inputReader, "terminal"); builder.setInput(inputReader, "terminal");
builder.setOutput(output); builder.setOutput(output);

View File

@ -1,5 +1,6 @@
package main; package main;
import static com.googlecode.lanterna.input.KeyType.Enter;
import static java.text.MessageFormat.format; import static java.text.MessageFormat.format;
import static main.LispMain.ANSI_GREEN; import static main.LispMain.ANSI_GREEN;
import static main.LispMain.ANSI_PURPLE; 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.SystemErrRule;
import org.junit.contrib.java.lang.system.SystemOutRule; import org.junit.contrib.java.lang.system.SystemOutRule;
import com.googlecode.lanterna.input.KeyType;
import com.googlecode.lanterna.terminal.virtual.DefaultVirtualTerminal; import com.googlecode.lanterna.terminal.virtual.DefaultVirtualTerminal;
import environment.RuntimeEnvironment; import environment.RuntimeEnvironment;
@ -76,6 +76,10 @@ public class MainTest {
return systemErrRule.getLogWithNormalizedLineSeparator(); return systemErrRule.getLogWithNormalizedLineSeparator();
} }
private String getExpectedGreeting() {
return format(GREETING, getClass().getPackage().getImplementationVersion());
}
@Rule @Rule
public ExpectedSystemExit exit = ExpectedSystemExit.none(); public ExpectedSystemExit exit = ExpectedSystemExit.none();
@ -123,10 +127,10 @@ public class MainTest {
terminal.waitForPrompt(); terminal.waitForPrompt();
terminal.enterCharacters("'hi"); terminal.enterCharacters("'hi");
terminal.pressKey(KeyType.Enter); terminal.pressKey(Enter);
terminal.waitForPrompt(); terminal.waitForPrompt();
terminal.assertCursorPosition(2, 5); terminal.assertCursorPosition(2, 5);
terminal.assertScreenText(GREETING, " ", "~ 'hi ", " ", "HI ", "~ "); terminal.assertScreenText(getExpectedGreeting(), " ", "~ 'hi ", " ", "HI ", "~ ");
terminal.enterControlCharacter('d'); terminal.enterControlCharacter('d');
terminal.assertInputStreamClosed(); terminal.assertInputStreamClosed();