Using a variable in Maven from the super pom -
i giving myself crash course of study in maven , stumbled across great plugin called buildnumber: http://mojo.codehaus.org/buildnumber-maven-plugin/create-mojo.html
i have setup rudimentary, beginners project , in pom.xml file having ${buildnumber} interpolate.
i have pom.xml below (i apologize length of it).
<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>my-app</name> <url>http://maven.apache.org</url> <scm> <connection>scm:git:ssh://git@bitbucket.org/xxxx/bb101repo.git</connection> <developerconnection>scm:git:ssh://git@bitbucket.org/xxx/bb101repo.git</developerconnection> <url>https://bitbucket.org/xxxx/bb101repo.git</url> </scm> <build> <plugins> <plugin> <groupid>org.codehaus.mojo</groupid> <artifactid>buildnumber-maven-plugin</artifactid> <version>1.2</version> <executions> <execution> <phase>validate</phase> <goals> <goal>create</goal> </goals> </execution> </executions> <configuration> <shortrevisionlength>5</shortrevisionlength> <!-- docheck : check locally modified files. if true build fail if local modifications have not been commited --> <!-- doupdate : update local re-create of repo. if true plugin update local files remote modifications before building --> <docheck>true</docheck> <doupdate>false</doupdate> </configuration> </plugin> </plugins> <finalname>${project.artifactid}-${project.version}-${buildnumber}</finalname> </build> <dependencies> <dependency> <groupid>junit</groupid> <artifactid>junit</artifactid> <version>3.8.1</version> <scope>test</scope> </dependency> </dependencies> </project>
when run mvn package, works intended.
i have file in project (under src) called info.xml , it's below.
<!doctype web-app public "-//sun microsystems, inc.//dtd web application 2.3//en" "http://java.sun.com/dtd/web-app_2_3.dtd" > <web-app> <display-name>fms help</display-name> <version>${buildnumber}</version> </web-app>
how ${buildnumber} unpack in tag under target?
i'm guessing it's simple solution, i'm stumped. again, i'm finish n00b @ maven , pointer in right direction appreciated. jw
you need tell maven apply filtering resources. check out resources plugin documentation here: http://maven.apache.org/plugins/maven-resources-plugin/examples/filter.html
to avoid applying filtering source files, you'd either need set proper include/exclude paths or move info.xml file resources directory.
maven variables pom.xml
No comments:
Post a Comment