开发者

Add .mf & .xml files in META-INF directory inside a Maven built EAR

I have arbitrary .xml & .mf files that i have to add in the META-INF folder inside the ear itself. Build is done using maven2.2.1. Simply adding those files under ${basedir}/src/main/application/META-INF/ works fine, but it doesn't fit my needs. Is there another way to do such thing? I tried:

<build>
<resources>
        <resource>
            <directory>G:/WS/vermeg/ear2/XML's</directory>
            <targetPath>META-INF</targetPath>
        </resource>
    </resources>
</build>

but this doesn't add my xml files under the EAR itself.

I also tried:

<configuration>
            <earSourceDirectory&g开发者_如何转开发t;G:\WS\vermeg\ear2\XML's\</earSourceDirectory>
...
</configuration>

this commands add my files inside the ear, but NOT in the META-INF inside the EAR (myEar.ear/META-INF).

Any help is welcome, and would be great. Thnx.

nacef,


Try using the resources plugin as described here: http://maven.apache.org/plugins/maven-resources-plugin/examples/copy-resources.html


I got it. Thanx Jgiff. I used indeed the maven-resources-plugin, specified where my xml's are located and that i wanted them to be copied in the META-INF folder of the project during the "validate" phase, that's important. My pom looks somehow like this now:

 <plugin>
           <groupId>org.apache.maven.plugins</groupId>
           <artifactId>maven-resources-plugin</artifactId>
           <version>2.4.3</version>
            <executions>
            <execution>
                <id>copy-resources</id>
                    <phase>validate</phase>
                    <goals>
                    <goal>copy-resources</goal>
                    </goals>
    <configuration>
       <outputDirectory>G:\WS\vermeg\ear2\src\main\application\META-INF\</outputDirectory>
            <resources>
            <resource>
                <directory>G:\WS\vermeg\ear2\XML's</directory>
                <filtering>true</filtering>
            </resource>
            </resources>
            </configuration>
            </execution>
            </executions>
        </plugin>

When executing an mvn clean install, maven executes the "validate" phase first so the copy is done before packaging the ear. That was successful.


I'll add this additional detail for anyone who encounters this problem using IBM Rational Application Developer (RAD) to generate policy and binding files for deployment to WebSphere Application Server (WAS).

In our case we generated policy binding files (policyAttachments.xml and wsPolicyServiceControl.xml) using the RAD tools for Policy set attachments. By default these get dumped into a META-INF folder in the EAR project root. If there is a handy way to modify this default behavior to always put it into application/META-INF, I did not come across it. But above methods work just fine in RAD with m2e for running locally and building EARs.

Here is the section of my pom used to copy those files:

     <plugin>
         <groupId>org.apache.maven.plugins</groupId>
         <artifactId>maven-resources-plugin</artifactId>
         <version>2.4.3</version>
         <executions>
             <execution>
                 <id>copy-resources</id>
                 <phase>validate</phase>
                 <goals>
                     <goal>copy-resources</goal>
                 </goals>
                 <configuration>
                     <outputDirectory>${basedir}\src\main\application\META-INF\</outputDirectory>
                     <resources>
                         <resource>
                             <directory>${basedir}\META-INF</directory>
                             <filtering>true</filtering>
                         </resource>
                     </resources>
                 </configuration>
             </execution>
         </executions>
     </plugin>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜