Description
I'll outline a description of the precise problem here, but if you're looking for a deep-dive on exactly how I arrived here, including sample code, take a look at this Stack Overflow post.
In Java Maven projects, the "default" layout (and what most projects use) is src/main/java
, src/main/resources
, src/test/java
, and src/test/resources
. However, those are only defaults, and nothing prevents a team from using a different layout. The following configuration supports the layout source/production/java
, source/production/resources
, source/test/java
, and source/test/resources
:
<build>
...
<sourceDirectory>source/production/java</sourceDirectory>
<resources>
<resource>
<directory>source/production/resources</directory>
</resource>
</resources>
<testSourceDirectory>source/test/java</testSourceDirectory>
<testResources>
<testResource>
<directory>source/test/resources</directory>
</testResource>
</testResources>
...
</build>
The maven-war-plugin
has a similar default: It looks for web application resources in src/main/webapp
. However, once again, this is just a default, and it can be configured using <warSourceDirectory>
:
<build>
...
<plugins>
...
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>3.3.1</version>
<configuration>
<warSourceDirectory>source/production/web</warSourceDirectory>
...
</configuration>
</plugin>
...
</plugins>
...
</build>
A problem arises in the fact that Spring Boot hard-codes src/main/webapp
in several places throughout the code, which makes it impossible to use a layout which uses a different directory structure for web resources.
I've contributed to Spring before (it's been many years), so I'm willing to work on a pull request to address this problem, but I need some guidance first. I need to know things like: Where would this get configured (spring-boot-maven-plugin
? somewhere else?)? How do I get that configuration in those places in code? Perhaps other things that I don't yet know that I need to know.