o example for filtering resources against POM values

o example for filtering resources against filter files 


git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@294931 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Jason van Zyl 2005-10-04 22:09:57 +00:00
parent 611ec5dc49
commit 39309f6d89
1 changed files with 93 additions and 12 deletions

View File

@ -493,25 +493,106 @@ InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStr
+----+
* How do I filter resources against a properties file?
* How do I filter resources against my POM?
+----+
FYI - In beta-2, while the other technique is still supported, the
recommended way is finally settled:
<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.mycompany.app</groupId>
<artifactId>my-app</artifactId>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<name>Maven Quick Start Archetype</name>
<url>http://maven.apache.org</url>
<description>Killer App</description>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
</build>
</project>
chatting with emm in irc and src/main/filters seems like a good place for filter files.
+----+
<build>
<filters>
<filtersFile>...</filtersFile>
</filters>
</build>
+----+
~~* How do use resources with my tests?
~~ o EIDSL
# application.properties
application.name=${pom.name}
application.version=${pom.version}
+----+
* How do I filter resources against a properties file?
+----+
<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.mycompany.app</groupId>
<artifactId>my-app</artifactId>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<name>Maven Quick Start Archetype</name>
<url>http://maven.apache.org</url>
<description>Killer App</description>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<filters>
<filter>src/main/filters/filters.properties</filter>
</filters>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
</build>
</project>
+----+
+----+
# filtering.properties
environment=development
+----+
+----+
# application.properties
application.name=${pom.name}
application.version=${pom.version}
environment=${environment}
+----+
+----+
~~* How do I use external dependencies?
~~ o Explain the use of repositories, remote and local