Skip to content
Snippets Groups Projects
Commit 7bc1db18 authored by steven.liatti's avatar steven.liatti
Browse files

Initial commit

parents
No related branches found
No related tags found
No related merge requests found
target
.vscode
.classpath
.project
.settings
# Numeric
Ce repository contient l'énoncé du TP "numeric" et un squelette maven.
Nous vous conseillons de vous abonner aux notifications (watch) pour ne pas manquer des annonces ou des changements.
Après avoir choisi votre groupe, vous devrez **impérativement** :
- "Forker" ce repository dans votre namespace, le passer en **privé** et ajouter les autres membres du groupe (un seul repository par groupe).
- Ajouter ce repository comme deuxième remote (différent de `origin`, nommé `base` par exemple : `git remote add base ssh://git@ssh.hesge.ch:10572/steven.liatti/poo2019numeric.git`).
- Ajouter Joel Cavat (@joel.cavat), Jeremy Gobet (@jeremy.gobet) et Steven Liatti (@steven.liatti) en tant que *Reporter* de votre repository.
- Lire attentivement l'énoncé.
# Maven
Maven est un gestionnaire de projets et d'automatisation de production pour l'écosystème Java.
Le fichier `pom.xml` décrit le projet avec ses dépendances.
### Exécutez votre projet
- compilation et téléchargement des dépendances. Produit un `jar` dans le dossier `target`.
```
mvn package
```
- exécutez à l'aide de java et du classpath:
```
java -cp target/my-app-0.1.jar ch.hepia.my_app.App
```
- ou, à l'aide du plugin `exec-maven-plugin`:
```
mvn exec:java
```
### Exécutez les tests uniquement
```
mvn test
```
### Notes
Le plugin `maven-assembly-plugin` est configuré et permet d'embarquer les dépendances dans un seul `jar`.
pom.xml 0 → 100644
<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>ch.hepia.numeric</groupId>
<artifactId>numeric</artifactId>
<packaging>jar</packaging>
<version>0.1</version>
<name>numeric</name>
<properties>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.5.2</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.6.0</version>
<executions>
<execution>
<goals>
<goal>java</goal>
</goals>
</execution>
</executions>
<configuration>
<!-- Point here to your main class -->
<mainClass>ch.hepia.numeric.App</mainClass>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.2</version>
<configuration>
<excludes>
<exclude>some test to exclude here</exclude>
</excludes>
</configuration>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>3.1.1</version>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
<executions>
<execution>
<id>make-assembly</id> <!-- this is used for inheritance merges -->
<phase>package</phase> <!-- bind to the packaging phase -->
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
package ch.hepia.my_app;
/**
* Hello world!
*
*/
public class App
{
public static void main( String[] args )
{
System.out.println( "Hello World!" );
}
}
package ch.hepia.my_app;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.assertFalse;
/**
* Unit test for simple App.
*/
class AppTest {
@Test
void dummyTest() {
assertTrue(true);
}
}
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