I want to add to a jar file some resources. I “profiled” it and added them in the build section.
But the resources aren’t in the final jar file.
Here it goes the profile section of my pom.xml:
<profile>
<id>myProfile</id>
<build>
<finalName>name</finalName>
<resources>
<resource>
<targetPath>.</targetPath>
<filtering>false</filtering>
<directory>${basedir}/profiles/myFolder</directory>
<includes>
<include>file.txt</include>
<include>file.xml</include>
</includes>
</resource>
</resources>
</build>
</profile>
And here the command I issue:
mvn clean install -PmyProfile
What’s wrong?
Your POM snippet looks globally fine and I cannot reproduce your problem. Here is the pom.xml I used:
With the following project structure:
$ tree . . ├── pom.xml ├── profiles │ └── myFolder │ ├── file.txt │ └── file.xml └── src ├── main │ └── java │ └── com │ └── stackoverflow │ └── App.java └── test └── java └── com └── stackoverflow └── AppTest.java 11 directories, 5 filesAnd here is what I get:
$ mvn clean install -PmyProfile ... $ cd target $ tree . . ├── classes │ ├── com │ │ └── stackoverflow │ │ └── App.class │ ├── file.txt │ └── file.xml ├── maven-archiver │ └── pom.properties ├── name.jar ├── surefire-reports │ ├── com.stackoverflow.AppTest.txt │ └── TEST-com.stackoverflow.AppTest.xml └── test-classes └── com └── stackoverflow └── AppTest.class $ jar xvf name.jar created: META-INF/ inflated: META-INF/MANIFEST.MF created: com/ created: com/stackoverflow/ inflated: file.xml inflated: com/stackoverflow/App.class inflated: file.txt created: META-INF/maven/ created: META-INF/maven/com.stackoverflow/ created: META-INF/maven/com.stackoverflow/Q3459013/ inflated: META-INF/maven/com.stackoverflow/Q3459013/pom.xml inflated: META-INF/maven/com.stackoverflow/Q3459013/pom.propertiesWorks as expected.