Reputation: 2864
My situation is:
Now what I want is to include (copy) the javascript file to the war file during the build phase of maven. To be precise, I want the script.js to land in /js/ directory of the war archive, just as it was placed in /app/src/main/webapp/js before starting the build.
I need this to share one version of resource files among many web-apps.
Kind regards, Q.
Upvotes: 6
Views: 11079
Reputation: 52635
You could do something like this, as documented here.
<project>
...
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.1.1</version>
<configuration>
<webResources>
<resource>
<!-- this is relative to the pom.xml directory -->
<directory>../common</directory>
<targetPath>/js</targetPath>
</resource>
</webResources>
</configuration>
</plugin>
</plugins>
</build>
...
</project>
Upvotes: 5
Reputation: 3163
You can use maven-resources plugin to copy a file to the desired location. Before or after a war has been built
Upvotes: 1
Reputation: 4547
You can use the mojo copy-resources to copy resources which are not in the default maven layout or not declared in the build/resources element.
Check
Upvotes: 2