Reputation: 3227
I am using tomcat7-maven-plugin
, and my web application is stored in src/main/webapp
. It is a React app, so I run npm run build
to generate a "compiled" version in src/main/webapp/build
. My problem is that whenever I package the webapp, the whole webapp
folder is packaged (including node_modules
...), instead of just the build
folder.
Here is my configuration for the plugin:
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<configuration>
<port>9090</port>
<!-- I am looking for something of the following form -->
<webappPath>build</webappPath>
</configuration>
</plugin>
</plugins>
</pluginManagement>
How could I make the plugin only package the webapp/build
directory? Or maybe is there a way to at least exclude node_modules
from the package, since all these modules are only used to create that packaged version of my webapp?
Upvotes: 4
Views: 1765
Reputation: 845
You can able to include or exclude in build
<project>
...
<name>My Resources Plugin Practice Project</name>
...
<build>
...
<resources>
<resource>
<directory>src/my-resources</directory>
<includes>
<include>**/*.txt</include>
</includes>
<excludes>
<exclude>**/*test*.*</exclude>
</excludes>
</resource>
...
</resources>
...
</build>
...
</project>
Apache Maven Include or Exclude
Upvotes: 1
Reputation: 9492
The tomcat7-maven-plugin is not responsible for packaging your war file. It is only responsible for deploy undeploy start restart and other related operations upon tomcat.
It is the maven WAR plugin that is related to the packaging of the WAR file https://maven.apache.org/plugins/maven-war-plugin/usage.html
If you want to change the default path that the war plugin is using then you need to
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<warSourceDirectory>your source directory</warSourceDirectory>
</configuration>
</plugin>
Upvotes: 2