Remove unnecessary files from java web application war file

I usually use Visual Code for coding in javascript and other client-side development. That means that I usually have .vscode/launch.json, .vscode/launch.json and jsconfig.json which are good for development but not needed in the final war file (created when doing mvn -B package)
src/main/webapp/
├── .vscode/
│   ├── launch.json
│   └── settings.json
├── WEB-INF/
├── css/
│   └── ...
├── images/
│   └── ...
├── index.html
├── js/
│   └── ...
└── jsconfig.json
Below piece should be added in the pom.xml to tell maven to exclude certain files. When the start (*) is not enough we can use %regex[ ]. More details: Maven war plugin - including/excluding files from war.
<project>
  ...
  <build>
    <plugins>

      <plugin>
        <artifactId>maven-war-plugin</artifactId>
        <version>2.6</version>
        <configuration>
          <!-- Exclude configuration files for Visual Code editor -->
          <packagingExcludes>jsconfig.json</packagingExcludes>
          <packagingExcludes>.vscode/*</packagingExcludes>
          <!-- Exclude documentation and other unnecessary files from d3.js -->
          <packagingExcludes>js/vendor/d3/*.md</packagingExcludes>
        </configuration>
      </plugin>

    </plugins>
  </build>
  ...
</project>

0 comments :

This work is licensed under BSD Zero Clause License | nacho4d ®