Maven web property question

I have a Maven web project and I have some CSS and Javascript files in the src \ main \ webapp \ folder. I constantly make changes to these files and want to quickly see my changes. If I run maven install, it will take a long time due to project dependencies. Sometimes all I want to change is a single line of code in my CSS file and I don’t want to recompile everything else. I have a maven plugin that publishes my war output file in 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 republish the modified war file without recompiling everything else.

I tried to call the resource generation target, but it does not seem to look in the src \ main \ webapp directory, as it is expected that my resources will be in the src \ main \ resources folder. What am I missing here?

thanks

+6
source share
2 answers

If you want to add more resources to copy during the resource generation plugin, you can change the resource folders used by your assembly. The project.build.resources property controls which folders are searched for resources. You can add:

 <project> ... <build> ... <resources> <resource> <directory>src/main/resources</directory> </resource> <resource> <directory>src/main/webApp</directory> <includes> <include>*.css</include> <include>*.js</include> 

Then you started mvn resources to copy the files.

This approach is that these files will always be copied during the resource phase of any assembly. You can get around this by using the copy-resources target instead of resources. In this case, you will 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> 

Then you can run mvn resources:copy-resources to copy the files.

+5
source

I think you could do this using the war:war target. This should create a war file in the output folder for you without recompiling the source.

+2
source

Source: https://habr.com/ru/post/896924/


All Articles