How to configure your maven project (pom.xml) to use lib.web

Use project template

Currently, there is no way to generate project with mvn archetype:generate command. Instead, you may use project templates provided with distribution (in project-templates subdirectory).

Currently, there is only one project template: simplest. This is just "Hello world!" application. You may test it working next way:

$ cd project-templates/simplest
$ mvn jetty:run

After you see the message:

[INFO] Starting scanner at interval of 5 seconds.

point your your browser to http://localhost:8080/. To stop Jetty server, press Ctrl+C in console.

NOTE. You may also use lib.web.example.war subproject as your starting point. It's a bit more complex.

Edit you pom.xml manually

This is not a complete example of pom.xml. You may find such example in project templates (see above). Here I just point out a couple of moments.

First, specify scala-tools.org maven repositories:

<project ...>
	...
	<repositories>
	...
	
		<!-- Needed if you want to use lib.web release version (e.g. 0.3.3): -->
		<repository>
			<id>scala-tools.org</id>
			<url>http://scala-tools.org/repo-releases</url>
			<!-- Just traffic optimization (don't search for snapshots among releases): -->
			<snapshots>
				<enabled>false</enabled>
			</snapshots>
		</repository>
		
		<!-- Needed if you want to use lib.web snapshot version (e.g. 0.3-SNAPSHOT): -->
		<repository>
			<id>scala-tools.org snapshots</id>
			<url>http://scala-tools.org/repo-snapshots</url>
			<!-- Just traffic optimization (don't search for releases among snapshots): -->
			<releases>
				<enabled>false</enabled>
			</releases>
		</repository>
	</repositories>

Second, specify as project dependency. You will also have to specify servlet API dependency with "provided" scope meaning that in runtime it's provided by servlet container:

<project ...>
	...
	<dependencies>
		<dependency>
			<groupId>javax.servlet</groupId>
			<artifactId>servlet-api</artifactId>
			<version>2.5</version>
			<scope>provided</scope>
		</dependency>
		<dependency>
			<groupId>ru.dimgel</groupId>
			<artifactId>lib.web</artifactId>
			<version>0.3-SNAPSHOT</version>
		</dependency>
	</dependencies>

Omitting scope for means that lib.web.jar will be packaged into you war archive, along with its dependencies (commons-io.jar, commons-codec.jar, commons-fileupload.jar).

Third, if you need maven Jetty plugin, you have to specify scala-library.jar in its dependencies. That's because scala-library.jar is used in project itself as "provided" dependency, which means it won't be packaged into war but must be provided at runtime. This way you ensure scala-library.jar will be on classpath when Jetty plugin starts:

<project ...>
	...
	<build>
		...
		<plugins>
			...
			<plugin>
				<groupId>org.mortbay.jetty</groupId>
				<artifactId>maven-jetty-plugin</artifactId>
				...
				<dependencies>
					<dependency>
						<groupId>org.scala-lang</groupId>
						<artifactId>scala-library</artifactId>
						<version>${scala.version}</version>
					</dependency>
				</dependencies>
			</plugin>