Maven: Where to put generated resources for tomcat-maven-plugin?

前端 未结 3 1345
遥遥无期
遥遥无期 2021-02-13 10:30

I have CSS and JavaScript files in src/main/webapp directory of my project. I want to join add joined and minified version of these resources to my WAR file and to

相关标签:
3条回答
  • 2021-02-13 10:49

    Note the plugin is now maintained at Apache (so upgrade a bit :-) ) see http://tomcat.apache.org/maven-plugin-2.0/.

    Even it works using install I'm not sure it's the optimum solution (regarding io and build time).

    The tomcat run must be able to use resources from more than one directory (I'm not sure it's possible with the current tomcat embeded api).

    Can you add a feature request here https://issues.apache.org/jira/browse/MTOMCAT

    Thanks

    0 讨论(0)
  • 2021-02-13 11:14

    Use warSourceDirectory:

    <warSourceDirectory>${project.build.directory}/${project.build.finalName}</warSourceDirectory>
    

    Instead of this configuration property (warDirectory) for the tomcat-maven-plugin:

    <warDirectory>${project.build.directory}/${project.build.finalName}</warDirectory>
    

    According to the tomcat-maven-plugin documentation, warSourceDirectory is where the web resources get picked up, and its default value is ${basedir}/src/main/webapp. This means that if you don’t set that property, you need to generate your unified/minified JavaScript file under ${basedir}/src/main/webapp.

    If you set warSourceDirectory to the output folder, this means you need to generate this file before starting Tomcat.

    0 讨论(0)
  • 2021-02-13 11:14

    Alternatively, you can also use the run-war goal instead of run, e.g. mvn tomcat6:run-war. This wil use the exploded war in your build directory (and thus filtered resources). See this site. There is also run-war-only which skips the packaging phase.

    0 讨论(0)
提交回复
热议问题