Maven web resources question
I have a Maven web project and I have some CSS and Jav开发者_如何学运维ascript files under the src\main\webapp\ folder. I constantly make changes to those files and would like to see my changes quickly. If I run maven install, it takes ages due to project dependencies. Sometimes all I want to change is one line of code in my CSS file and do not want to recompile everything else. I have a maven plugin that publishes my output war file to my JBoss instance. Ideally, I would like to run a maven execution script that will quickly copy my web resources to the output folder and reploy the changed war file without recompiling everything else.
I tried invoking the generate-resources goal but that doesn't seem to look in the src\main\webapp directory as it is expecting my resources to be under the src\main\resources folder. What am I missing here?
Thanks
If you want to add more resources to be copied during the generate-resources plugin, you can change the resources folders used by your build. The project.build.resources
property controls which folders are searched for resources. You could add:
<project>
...
<build>
...
<resources>
<resource>
<directory>src/main/resources</directory>
</resource>
<resource>
<directory>src/main/webApp</directory>
<includes>
<include>*.css</include>
<include>*.js</include>
You would then run mvn resources
to copy the files.
This approach is that these files will always be copied during the resources phase of any build. You can get around this by using the copy-resources
goal instead of resources. In this case you would use the following configuration:
<build>
<plugins>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>2.5</version>
<executions>
<execution>
<id>copy-web-resources</id>
<!-- here the phase you need -->
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/webApp</outputDirectory>
<resources>
<resource>
<directory>src/main/webApp</directory>
<includes>
<include>*.css</include>
<include>*.js</include>
You could then run mvn resources:copy-resources
to copy the files.
I think you could accomplish this by using the war:war
goal. This should generate a war file in the output folder for you without re-compiling the source.
精彩评论