Author: tchemit Date: 2013-04-05 05:57:07 +0200 (Fri, 05 Apr 2013) New Revision: 574 Url: http://nuiton.org/projects/sandbox/repository/revisions/574 Log: tuto injectMavenPropertiesInJavaFile Added: injectMavenPropertiesInJavaFile/pom.xml injectMavenPropertiesInJavaFile/src/ injectMavenPropertiesInJavaFile/src/main/ injectMavenPropertiesInJavaFile/src/main/filter-java/ injectMavenPropertiesInJavaFile/src/main/filter-java/com/ injectMavenPropertiesInJavaFile/src/main/filter-java/com/codelutin/ injectMavenPropertiesInJavaFile/src/main/filter-java/com/codelutin/tech/ injectMavenPropertiesInJavaFile/src/main/filter-java/com/codelutin/tech/maven/ injectMavenPropertiesInJavaFile/src/main/filter-java/com/codelutin/tech/maven/MyClass.java Modified: injectMavenPropertiesInJavaFile/ Property changes on: injectMavenPropertiesInJavaFile ___________________________________________________________________ Added: svn:ignore + target *.iml .idea *.ipr *.iws Added: injectMavenPropertiesInJavaFile/pom.xml =================================================================== --- injectMavenPropertiesInJavaFile/pom.xml (rev 0) +++ injectMavenPropertiesInJavaFile/pom.xml 2013-04-05 03:57:07 UTC (rev 574) @@ -0,0 +1,86 @@ +<?xml version="1.0" encoding="UTF-8"?> +<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.codelutin.tech</groupId> + <artifactId>injectMavenPropertiesInJavaFile</artifactId> + <version>0.1-SNAPSHOT</version> + + <description> + Example of how to inject maven properties in a java file. + </description> + + <scm> + <url> + http://svn.nuiton.org/svn/sandbox/injectMavenPropertiesInJavaFile + </url> + </scm> + + <properties> + + <!-- where to copy filtered java sources --> + <javaGenDirectory> + ${project.basedir}/target/generated-sources/java + </javaGenDirectory> + </properties> + + <build> + + <resources> + <!-- filter java source root --> + <resource> + <directory>src/main/filter-java</directory> + <targetPath>${javaGenDirectory}</targetPath> + <filtering>true</filtering> + <includes> + <include>**/*.java</include> + </includes> + </resource> + </resources> + + <plugins> + + <!-- Add the filtered java source root to compiler --> + <plugin> + <groupId>org.codehaus.mojo</groupId> + <artifactId>build-helper-maven-plugin</artifactId> + <version>1.7</version> + <executions> + <execution> + <goals> + <goal>add-source</goal> + </goals> + <configuration> + <sources> + <source>${javaGenDirectory}</source> + </sources> + </configuration> + </execution> + </executions> + </plugin> + + <!-- Exec the main java example class --> + <plugin> + <groupId>org.codehaus.mojo</groupId> + <artifactId>exec-maven-plugin</artifactId> + <version>1.2.1</version> + <configuration> + <mainClass>com.codelutin.tech.maven.MyClass</mainClass> + </configuration> + <executions> + <execution> + <phase>package</phase> + <goals> + <goal>java</goal> + </goals> + </execution> + </executions> + </plugin> + </plugins> + + </build> + +</project> Property changes on: injectMavenPropertiesInJavaFile/pom.xml ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: injectMavenPropertiesInJavaFile/src/main/filter-java/com/codelutin/tech/maven/MyClass.java =================================================================== --- injectMavenPropertiesInJavaFile/src/main/filter-java/com/codelutin/tech/maven/MyClass.java (rev 0) +++ injectMavenPropertiesInJavaFile/src/main/filter-java/com/codelutin/tech/maven/MyClass.java 2013-04-05 03:57:07 UTC (rev 574) @@ -0,0 +1,15 @@ +package com.codelutin.tech.maven; + +/** + * Let's inject some maven project properties in the java file. + * + * @author tchemit <chemit@codelutin.com> + * @since 0.1 + */ +public class MyClass { + + public static void main(String[] args) { + System.out.println("Project GAV: ${project.groupId}:${project:artifactId}:${project:version}"); + System.out.println("Project SCM: ${scm.url}"); + } +} Property changes on: injectMavenPropertiesInJavaFile/src/main/filter-java/com/codelutin/tech/maven/MyClass.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native
participants (1)
-
tchemit@users.nuiton.org