Maven Copy Folder Before War File Generation

java, maven, maven-resources-plugin

Solution

You are using the wrong phase in your execution as the `package` phase is actually the phase where your war is created, so you need to execute at an earlier phase e.g. `prepare-package`.

You should definitely read Introduction to the Build Lifecycle for clarification.

In addition you should not become accustomed to pulling in resources via maven-resources-plugin from the file system. This is generally frowned upon as bad practice since other developers will not be able to reproduce your build.

Using a repository manager to store your dependencies is the way to go here. Read Why do I need a Repository Manager? to get started.

Problem

I have two Git repositories. One repositary is java services (maven web project) and another repository consists of UI {HTML, JS, CSS}(non maven), At the time of java services repository build I want to include the latest UI (master) into the war file. I tried with `maven-resources-plugin` ``` <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>3.2</version> <configuration> <source>1.7</source> <target>1.8</target> </configuration> </plugin> <plugin> <artifactId>maven-resources-plugin</artifactId> <version>2.7</version> <executions> <execution> <id>copy-resources</id> <!-- here the phase you need --> <phase>install</phase> <goals> <goal>copy-resources</goal> </goals> <configuration> <outputDirectory>${basedir}/target/</outputDirectory> <resources> <resource> <directory>/home/srinivas/AAA/bb/</directory> </resource> </resources> </configuration> </execution> </executions> </plugin> </plugins> </build> ``` mvn install It copies the resources to target folder but it is not placing them in the war file

Original source

Related problems