Commits

Micha Kops  committed d9d0534

Initial import.

  • Participants

Comments (0)

Files changed (4)

+.project
+.settings
+.classpath
+target
+# Templating Maven Plugin Example
+
+A short hack to demonstrate how to use properties from the Maven build environment in a Java class without using a bypass by filtering property files.
+
+Simply run the following commands to build and watch the results:
+
+    mvn package
+    java -cp target/templating-maven-plugin-example-0.0.1.jar com.hascode.tutorial.Main
+
+
+This should produce a similar output:
+
+    Templating Plugin for Maven Example
+    artifactId: templating-maven-plugin-example, groupId: com.hascode.tutorial, version: 0.0.1
+    project build directory: /data/project/templating-maven-plugin-example/target
+
+Please feel free to have a look at my blog at [www.hascode.com] for other samples and tutorials.
+
+----
+
+**2013 Micha Kops / hasCode.com**
+
+   [www.hascode.com]:http://www.hascode.com/
+<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/xsd/maven-4.0.0.xsd">
+	<modelVersion>4.0.0</modelVersion>
+	<groupId>com.hascode.tutorial</groupId>
+	<artifactId>templating-maven-plugin-example</artifactId>
+	<version>0.0.1</version>
+
+	<build>
+		<plugins>
+			<plugin>
+				<groupId>org.codehaus.mojo</groupId>
+				<artifactId>templating-maven-plugin</artifactId>
+				<version>1.0-alpha-3</version>
+				<executions>
+					<execution>
+						<id>filter-src</id>
+						<goals>
+							<goal>filter-sources</goal>
+						</goals>
+					</execution>
+				</executions>
+			</plugin>
+		</plugins>
+	</build>
+</project>

File src/main/java-templates/com/hascode/tutorial/Main.java

+package com.hascode.tutorial;
+
+public class Main {
+	public static void main(String[] args){
+		System.out.println("Templating Plugin for Maven Example");
+		System.out.println(String.format("artifactId: ${project.artifactId}, groupId: ${project.groupId}, version: ${project.version}"));
+		System.out.println("project build directory: ${project.build.directory}");
+	}
+}