- Change the name of the Apache Karaf startup script
What you will learn:
- Configure maven-antrun-plugin to do post-processing
Please see the post "Create a custom Apache Karaf server" for the initial setup.
By default, the startup script is named "karaf". For branding purposes, we want to rename the karaf script to "dekantar".
Configure maven-antrun-plugin to rename the script name and do a "search-and-replace" in the script text.
<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-antrun-plugin</artifactId> <executions> <execution> <id>rename_script</id> <phase>process-resources</phase> <goals> <goal>run</goal> </goals> <configuration> <target> <move file="target/assembly/bin/karaf" tofile="target/assembly/bin/dekantar"/> <move file="target/assembly/bin/karaf.bat" tofile="target/assembly/bin/dekantar.bat"/> <replace dir="target/assembly/bin" token="bin/karaf " value="bin/dekantar "/> <replace dir="target/assembly/bin" token="karaf.out" value="dekantar.out"/> <replace dir="target/assembly/bin" token="karaf.bat" value="dekantar.bat"/> <replace dir="target/assembly/bin" token='KARAF_SCRIPT="karaf' value='KARAF_SCRIPT="dekantar'/> </target> </configuration> </execution> </executions> </plugin>
The target/assembly directory is where the karaf-maven-plugin assembles all the files and dependencies for the Karaf server distribution.
See https://github.com/juttayaya/karaf/blob/master/karaf3/custom-karaf/custom-karaf-server/pom.xml for full example.
Moral of the story:
Use maven-antrun-plugin to execute custom commands in Maven builds
No comments:
Post a Comment