Skip to content

Instantly share code, notes, and snippets.

@dlundy
Created October 19, 2012 05:40
Show Gist options
  • Save dlundy/3916409 to your computer and use it in GitHub Desktop.
Save dlundy/3916409 to your computer and use it in GitHub Desktop.
Sample Maven pom.xml using per-environment configuration and local repo
<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>com.mycorp.project</groupId>
<artifactId>project</artifactId>
<packaging>war</packaging>
<version>1.0-SNAPSHOT</version>
<name>Sample Maven Webapp</name>
<url>http://www.example.com</url>
<build>
<filters>
<filter>src/main/resources/env/${env}.properties</filter>
</filters>
<!-- Filter other resources to the java directory -->
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
<includes>
<include>*.properties</include>
<include>*.xml</include>
</includes>
</resource>
</resources>
<finalName>project</finalName>
</build>
<properties>
<!-- default environment -->
<env>dev</env>
<!-- Set default encoding to UTF-8 -->
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<!-- environment definitions -->
<profiles>
<profile>
<id>dev</id>
<properties>
<env>dev</env>
</properties>
</profile>
<profile>
<id>qa</id>
<properties>
<env>qa</env>
</properties>
</profile>
<profile>
<id>prod</id>
<properties>
<env>prod</env>
</properties>
</profile>
</profiles>
<!-- Create a local repo so we can distribute jars without using the system scope -->
<!-- http://blog.dub.podval.org/2010/01/maven-in-project-repository.html -->
<repositories>
<repository>
<id>lib</id>
<name>lib</name>
<releases>
<enabled>true</enabled>
<checksumPolicy>ignore</checksumPolicy>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
<url>file://${project.basedir}/lib</url>
</repository>
</repositories>
<dependencies>
<!-- dependencies here -->
</dependencies>
</project>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment