I'd like to use the maven-replacer-plugin to rename my javascript import statements in my index.html file.
However I would only like to do this where the path starts with app
index.html snippet
...
<!-- rename this one to app/something12345.js -->
<script src="app/something.js"></script>
<!-- leave this one as it is -->
<script src="vendor/angular.js"></script>
...
In my pom.xml so far I have this configuration for the maven-replacer-plugin
<plugin>
<groupId>com.google.code.maven-replacer-plugin</groupId>
<artifactId>replacer</artifactId>
<version>1.5.2</version>
<executions>
<execution>
<phase>prepare-package</phase>
<goals>
<goal>replace</goal>
</goals>
</execution>
</executions>
<configuration>
<file>target/${project.build.finalName}/index.html</file>
<replacements>
<replacement>
<token>(\.js")</token>
<value>12345.js"</value>
</replacement>
</replacements>
</configuration>
</plugin>
At the moment this will obviously replace all the .js
matches.
Is there some magic incantation I can put in the <token>
section to achieve this?
I managed to do this using the following
<replacement>
<token>((app/)(.)*)(\.js")</token>
<value>$112345.js</value>
</replacement>
although in my real application I replaced 12345
with the ${buildNumber}
variable, so the syntax was
<replacement>
<token>((app/)(.)*)(\.js")</token>
<value>$1${buildNumber}.js</value>
</replacement>
which I hope might make the solution a bit more understandable
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With