I would like to know how I define multiple containers in Maven, one for development and debugging and one for production. For instance:
- Embedded Glassfish with JUnit dependencies
- Deploying on Glassfish Server with no tests (no auto deploy is required, I just make a manual copy to the domain).
So when I shall run the JUnit tests, I would do something like:
mvn test -P junit
And for build a package to deploy
mvn package -P webapp
I am writing example with the -P switch, since I have come up with this pom.xml so far:
<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>se.while</groupId>
<artifactId>project</artifactId>
<packaging>war</packaging>
<version>1.0-SNAPSHOT</version>
<name>project Maven Webapp</name>
<url>http://maven.apache.org</url>
<profiles>
<profile>
<id>junit</id>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.glassfish.main.extras</groupId>
<artifactId>glassfish-embedded-all</artifactId>
<version>3.1.2</version>
<scope>provided</scope>
</dependency>
</dependencies>
</profile>
<profile>
<id>webapp</id>
<dependencies>
<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>javax.persistence</artifactId>
<version>2.0.0</version>
</dependency>
<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>eclipselink</artifactId>
<version>2.3.2</version>
</dependency>
<dependency>
<groupId>javax.faces</groupId>
<artifactId>jsf-api</artifactId>
<version>2.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.glassfish</groupId>
<artifactId>javax.ejb</artifactId>
<version>3.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.primefaces</groupId>
<artifactId>primefaces</artifactId>
<version>3.3.1</version>
</dependency>
</dependencies>
</profile>
</profiles>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.jboss.arquillian</groupId>
<artifactId>arquillian-bom</artifactId>
<version>1.0.1.Final</version>
<scope>import</scope>
<type>pom</type>
</dependency>
</dependencies>
</dependencyManagement>
<repositories>
<repository>
<id>EclipseLink Repo</id>
<url>http://www.eclipse.org/downloads/download.php?r=1&nf=1&file=/rt/eclipselink/maven.repo</url>
<!-- use this for javax.persistence <snapshots> <enabled>true</enabled></snapshots> -->
</repository>
<repository>
<id>prime-repo</id>
<name>PrimeFaces Maven Repository</name>
<url>http://repository.primefaces.org</url>
<layout>default</layout>
</repository>
</repositories>
<build>
<finalName>project</finalName>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
I have now 2 problems (at least):
- The tests seems to working with the "mvn test -P junit" but when I do "mvn package -P webapp" Maven seems to run the tests again (with no container I assume nor the junit dependency).
- The Eclipse IDE lint checker does indicate errors in source code depending on activated profile. For instance, if I active the webapp profile, all the test classes will be error marked.
Can you please guide me?
Best regards