आपका पीओएम स्निपेट विश्व स्तर पर ठीक दिखता है और मैं आपकी समस्या को पुन: उत्पन्न नहीं कर सकता।
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.stackoverflow</groupId>
<artifactId>Q3459013</artifactId>
<version>1.0-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
<profiles>
<profile>
<id>myProfile</id>
<build>
<finalName>name</finalName>
<resources>
<resource>
<directory>${basedir}/profiles/myFolder</directory>
<filtering>false</filtering>
<includes>
<include>file.txt</include>
<include>file.xml</include>
</includes>
</resource>
</resources>
</build>
</profile>
</profiles>
</project>
निम्नलिखित परियोजना संरचना के साथ
:
$ 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 files
और यहाँ मैं क्या मिलता है:
$ 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.properties
वर्क्स अपेक्षा के अनुरूप यहां pom.xml मैं प्रयोग किया जाता है।
स्रोत
2010-08-11 17:03:10
@ पास्कल: बहुत अच्छा जवाब। मेरे पास एक ही pom.xml है क्योंकि यह जार फ़ाइल में उचित फ़ाइलों को शामिल नहीं करता है। मैं बाद में maven2 के एक नए संस्करण के साथ कोशिश करूंगा (मेरा 2.0.9 है)। आपके समय के लिए धन्यवाद! – ssedano
@Udo मैं वास्तव में मेवेन 2.2.1 –
@ पास्कल और अमरा का उपयोग कर रहा हूं: अब मुझे यह काम करने के लिए धन्यवाद! लेकिन अगर मैं फ़ाइलों को रूट फ़ोल्डर (जार) में रखना चाहता हूं? targetPath> target/myProject काम नहीं करता – ssedano