Adding the original version from the blog.

This commit is contained in:
shing19m 2013-07-23 20:10:47 +02:00
parent 634e4614f7
commit fa2f2f7d7a
5 changed files with 117 additions and 0 deletions

1
.gitignore vendored
View File

@ -4,3 +4,4 @@
*.jar *.jar
*.war *.war
*.ear *.ear
/target/

73
pom.xml Normal file
View File

@ -0,0 +1,73 @@
<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>
<groupId>de.lusiardi.maven</groupId>
<artifactId>mavenExecutableJarFiles</artifactId>
<packaging>jar</packaging>
<version>0.1</version>
<name>Ausführbare Jar-Dateien mit Maven</name>
<build>
<plugins>
<plugin>
<groupId>
org.apache.maven.plugins
</groupId>
<artifactId>
maven-compiler-plugin
</artifactId>
<version>2.1</version>
<configuration>
<source>
1.5
</source>
<target>
1.5
</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>1.4</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>b1.Main</mainClass>
</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.8.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>jline</groupId>
<artifactId>jline</artifactId>
<version>0.9.9</version>
</dependency>
</dependencies>
<repositories>
<repository>
<id>jline</id>
<name>JLine Project Repository</name>
<url>http://jline.sourceforge.net/m2repo</url>
</repository>
</repositories>
</project>

View File

@ -0,0 +1,23 @@
package b1;
import java.io.IOException;
import java.io.PrintWriter;
import jline.ConsoleReader;
public class Main {
public static void main(String[] args) throws IOException {
ConsoleReader reader = new ConsoleReader();
String line;
PrintWriter out = new PrintWriter(System.out);
while ((line = reader.readLine("number or quit> ")) != null) {
if (line.equalsIgnoreCase("quit")) {
break;
}
int i = Integer.parseInt(line);
System.out.println(
Math.square(i) + " ist " + i + " quadriert");
out.flush();
}
}
}

View File

@ -0,0 +1,8 @@
package b1;
public class Math {
public static int square(int a) {
return a * a;
}
}

View File

@ -0,0 +1,12 @@
package b1;
import org.junit.Assert;
import org.junit.Test;
public class MathTest {
@Test
public void testSqure() {
Assert.assertEquals(16, Math.square(4));
}
}