Reputation: 1818
I have created a java project with maven. In my project (under src/main/resources) there are some resource files I want to be copied into target/classes.
I added these lines into my pom xml:
<build>
<resources>
<resource>
<directory>src/main/resources</directory>
<includes>
<include>**/*.*</include>
</includes>
</resource>
</resources>
</build>
when I run mvn resources:resources by the command line I get the resources files are being copied into target/classes (so the resources phase in the lifecycle is working). However, when I enter mvn install:install in the cmd, the resources files aren't being copied into target/classes.
I get:
[INFO]
[INFO] --- maven-install-plugin:2.4:install (default-install) @ mqm-data-population ---
[INFO] Installing C:\xxx\xlation\pom.xml to C:\Users\xxx\xon-12.50.14-SNAPSHOT.pom
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.278 s
it seems that the install phase in the lifecycle does not call the resources phase or something like that..
I thought that it might be rellevent to the resources plugin so I added:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>2.7</version>
</plugin>
</plugins>
<resources>
<resource>
<directory>src/main/resources</directory>
<includes>
<include>**/*.*</include>
</includes>
</resource>
</resources>
</build>
That did not help as well....
Can someone help? Thanks.
SOLVED
After a quick search online I found out why the resource files were not being copied into my target/classes. I needed to use the maven resources plugin, and point out the phase in which I want the resources to be copied into target/classes (in my case, the “install” phase…).
After looking here: https://maven.apache.org/plugins/maven-resources-plugin/examples/copy-resources.html
I added this to my pom.xml, and is working…
Upvotes: 1
Views: 957
Reputation: 342
Possibly your default profile is not active modify it by adding true
<profiles>
<profile>
<id>development</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<build>
<resources>
<resource>
<directory>src/main/resources</directory>
<includes>
<include>**/*.*</include>
</includes>
Upvotes: 0