Skip to content
Snippets Groups Projects
Commit 0b1c113d authored by Anya Helene Bagge's avatar Anya Helene Bagge
Browse files

update for 2022

parent a39aa894
No related branches found
No related tags found
No related merge requests found
...@@ -23,5 +23,18 @@ target ...@@ -23,5 +23,18 @@ target
.idea .idea
*.iml *.iml
# Eclipse stuff
bin
.project
.classpath
.settings
# OS stuff
.DS_Store
__MACOSX
._*
Desktop.ini
Thumbs.db
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid* hs_err_pid*
...@@ -3,3 +3,79 @@ Simple skeleton with libgdx. ...@@ -3,3 +3,79 @@ Simple skeleton with libgdx.
## Known bugs ## Known bugs
# Maven Setup
This project comes with a working Maven `pom.xml` file. You should be able to import it into Eclipse using *File → Import → Maven → Existing Maven Projects* (or *Check out Maven Projects from SCM* to do Git cloning as well). You can also build the project from the command line with `mvn compile` and test it with `mvn test`.
Pay attention to these folders:
* `src/main/java` – Java source files go here (as usual for Maven)
* `src/main/resources` – data files go here
* `src/test/java` – JUnit tests
* `target/classes` – compiled Java class files
You should probably edit the `pom.xml` and fill in details such as the project `name` and `artifactId`:
```xml
< !-- FIXME - set group id -->
<groupId>inf112.skeleton.app</groupId>
< !-- FIXME - set artifact name -->
<artifactId>mvn-app</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
< !-- FIXME - set app name -->
<name>mvn-app</name>
< !-- FIXME change it to the project's website -->
<url>http://www.example.com</url>
```
## Running
You can run the project from Eclipse, or with Maven using `mvn exec:java`. Change the main class by modifying the `main.class` setting in `pom.xml`:
```
<main.class>inf112.skeleton.app.Main</main.class>
```
If you run `mvn package` you'll get a everything bundled up into a JAR file
* `target/*.jar` – your compiled project, packaged in a JAR file
#### POM snippets
If you're setting up / adding ANTLR4 to your own project, you can cut and paste these lines into your `pom.xml`file.
* You should make sure that both the parser generator and the runtime use the same version, so define the version number in `<properties>…</properties>`:
```xml
<antlr4.version>4.8-1</antlr4.version>
```
* The ANTLR4 runtime is needed to run the compiled parser; add it in the `<depencencies>…</dependencies>` section:
```xml
<!-- https://mvnrepository.com/artifact/org.antlr/antlr4-runtime -->
<dependency>
<groupId>org.antlr</groupId>
<artifactId>antlr4-runtime</artifactId>
<version>${antlr4.version}</version>
</dependency>
```
* The ANTLR4 maven plugin includes the ANTLR4 tool, and is needed to generate parser during compilation; add it to `<build><plugins>…</plugins></build>`:
```xml
<plugin>
<groupId>org.antlr</groupId>
<artifactId>antlr4-maven-plugin</artifactId>
<version>${antlr4.version}</version>
<executions>
<execution>
<goals>
<goal>antlr4</goal>
</goals>
</execution>
</executions>
</plugin>
```
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" <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">
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>inf112.skeleton.app</groupId> <!-- FIXME - set group id -->
<artifactId>mvn-app</artifactId> <groupId>inf112.skeleton.app</groupId>
<version>1.0-SNAPSHOT</version> <!-- FIXME - set artifact name -->
<artifactId>mvn-app</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>mvn-app</name> <!-- FIXME - set app name -->
<!-- FIXME change it to the project's website --> <name>mvn-app</name>
<url>http://www.example.com</url> <!-- FIXME change it to the project's website -->
<url>http://www.example.com</url>
<properties> <properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.release>9</maven.compiler.release> <maven.compiler.release>17</maven.compiler.release>
</properties> <libgdx.version>1.10.0</libgdx.version>
<!-- FIXME - set to app's main class' -->
<main.class>inf112.skeleton.app.Main</main.class>
</properties>
<dependencies> <dependencies>
<!-- https://mvnrepository.com/artifact/com.badlogicgames.gdx/gdx --> <!--libGDX graphics library – https://libgdx.com/ -->
<dependency> <dependency>
<groupId>com.badlogicgames.gdx</groupId> <groupId>com.badlogicgames.gdx</groupId>
<artifactId>gdx</artifactId> <artifactId>gdx</artifactId>
<version>1.9.10</version> <version>${libgdx.version}</version>
</dependency> </dependency>
<dependency> <!-- Platform-specific libraries -->
<groupId>com.badlogicgames.gdx</groupId> <dependency>
<artifactId>gdx-platform</artifactId> <groupId>com.badlogicgames.gdx</groupId>
<version>1.9.10</version> <artifactId>gdx-platform</artifactId>
<classifier>natives-desktop</classifier> <version>${libgdx.version}</version>
</dependency> <classifier>natives-desktop</classifier>
</dependency>
<dependency> <dependency>
<groupId>com.badlogicgames.gdx</groupId> <groupId>com.badlogicgames.gdx</groupId>
<artifactId>gdx-backend-lwjgl3</artifactId> <artifactId>gdx-backend-lwjgl3</artifactId>
<version>1.9.10</version> <version>${libgdx.version}</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>junit</groupId> <groupId>org.junit.jupiter</groupId>
<artifactId>junit</artifactId> <artifactId>junit-jupiter</artifactId>
<version>4.11</version> <version>5.5.2</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
</dependencies> </dependencies>
<build> <build>
<pluginManagement><!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) --> <plugins>
<plugins> <!-- Run app through Maven -->
<!-- clean lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#clean_Lifecycle --> <plugin>
<plugin> <groupId>org.codehaus.mojo</groupId>
<artifactId>maven-clean-plugin</artifactId> <artifactId>exec-maven-plugin</artifactId>
<version>3.1.0</version> <configuration>
</plugin> <mainClass>${main.class}</mainClass>
<!-- default lifecycle, jar packaging: see https://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_jar_packaging --> </configuration>
<plugin> </plugin>
<artifactId>maven-resources-plugin</artifactId> <!-- Build a fat uber-jar with all dependencies -->
<version>3.0.2</version> <plugin>
</plugin> <groupId>org.apache.maven.plugins</groupId>
<plugin> <artifactId>maven-shade-plugin</artifactId>
<artifactId>maven-compiler-plugin</artifactId> <version>2.3</version>
<version>3.8.0</version> <executions>
</plugin> <execution>
<plugin> <phase>package</phase>
<artifactId>maven-surefire-plugin</artifactId> <goals>
<version>2.22.1</version> <goal>shade</goal>
</plugin> </goals>
<plugin> <configuration>
<artifactId>maven-jar-plugin</artifactId> <transformers>
<version>3.0.2</version> <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
</plugin> <manifestEntries>
<plugin> <Main-Class>${main.class}</Main-Class>
<artifactId>maven-install-plugin</artifactId> </manifestEntries>
<version>2.5.2</version> </transformer>
</plugin> <transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer" />
<plugin> </transformers>
<artifactId>maven-deploy-plugin</artifactId> <artifactSet></artifactSet>
<version>2.8.2</version> <outputFile>${project.build.directory}/${project.artifactId}-${project.version}-fat.jar</outputFile>
</plugin> </configuration>
<!-- site lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#site_Lifecycle --> </execution>
<plugin> </executions>
<artifactId>maven-site-plugin</artifactId> </plugin>
<version>3.7.1</version> </plugins>
</plugin> <pluginManagement>
<plugin> <!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) -->
<artifactId>maven-project-info-reports-plugin</artifactId> <plugins>
<version>3.0.0</version> <plugin>
</plugin> <artifactId>maven-clean-plugin</artifactId>
</plugins> <version>3.1.0</version>
</pluginManagement> </plugin>
</build> <plugin>
</project> <artifactId>maven-site-plugin</artifactId>
<version>3.7.1</version>
</plugin>
<plugin>
<artifactId>maven-project-info-reports-plugin</artifactId>
<version>3.0.0</version>
</plugin>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>3.0.2</version>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M5</version>
<configuration>
<useModulePath>false</useModulePath>
<argLine></argLine>
</configuration>
</plugin>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<version>3.0.2</version>
</plugin>
<plugin>
<artifactId>maven-install-plugin</artifactId>
<version>2.5.2</version>
</plugin>
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.2</version>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.6.0</version>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>
\ No newline at end of file
package inf112.skeleton.app; package inf112.skeleton.app;
import static org.junit.Assert.assertTrue; import static org.junit.jupiter.api.Assertions.*;
import org.junit.Test;
import org.junit.jupiter.api.*;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.CsvSource;
/**
* Unit test for simple App.
*/
public class AppTest { public class AppTest {
/** /**
* Rigorous Test :-) * Static method run before everything else
*/ */
@Test @BeforeAll
public void shouldAnswerWithTrue() { static void setUpBeforeAll() {
assertTrue(true); }
}
} /**
* Setup method called before each of the test methods
*/
@BeforeEach
void setUpBeforeEach() {
}
/**
* Simple test case
*/
@Test
void dummy1() {
// Expected result is the first argument, value to be tested is the second.
// The message is optional.
assertEquals("foo", "f".concat("oo"), "fooo?");
}
/**
* Simple test case
*/
@Test
void dummy2() {
// For floats and doubles it's best to use assertEquals with a delta, since
// floating-point numbers are imprecise
float a = 100000;
a = a + 0.1f;
assertEquals(100000.1, a, 0.01);
}
/**
* Parameterized test case, reading arguments from comma-separated strings
*
* @param a
* @param b
* @param c
*/
@CsvSource(value = { "1,1,2", "1,2,3", "2,3,5", "3,5,8", "5,8,13", "8,13,21" })
@ParameterizedTest(name = "{0}+{1} == {2}")
void addTest(int a, int b, int c) {
assertEquals(c, a + b);
}
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment