To include web resources from locations other than the typical src/main/webapp directory, configure a property and the maven-war-plugin with the <webResources>
parameter with something like this:
pom.xml
...
<properties>
<webResDir>/path/to/js-css</webResDir>
<properties>
...
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>3.3.2</version>
<configuration>
<webResources>
<resource>
<directory>${webResDir}</directory>
</resource>
</webResources>
<!-- I recommend this config which does a better job of removing any deleted/outdated resources, as of v3.3.2 -->
<outdatedCheckPath>/</outdatedCheckPath>
</configuration>
</plugin>
NOTES
While the basic idea still applies at earlier versions, you'll get a better experience with recommended minimum versions:
PREREQ MINIMUM VERSIONS
- version 3.3.2 of maven-war-plugin (adds support for outdatedCheckPath syntax shown)
- version 3.5.2 of liberty-maven-plugin (adds support for filtered web resources)
PLUGIN-LEVEL CONFIGURATION
Note too the maven-war-plugin configuration should be added at the plugin level for liberty dev mode to access it, rather than at the level of an execution defined under the maven-war-plugin.
PROPERTY OVERRIDE
As with Maven project properties in general, this can now be overridden:
- on the command-line:
mvn -DwebResDir=/some/path ... <goals, phases>
- In settings.xml (especially useful if you have a host-specific location shared across multiple projects accessed from that system), e.g. see the Maven Settings documentation
REFERENCES
More examples here: https://maven.apache.org/plugins/maven-war-plugin/examples/adding-filtering-webresources.html