Search code examples
maven-2weblogicclasspathwardirectory-structure

Maven 2 Weblogic.xml replacement


I am having a problem about placing weblogic.xml under WEB-INF folder after mvn install. My weblogic.xml file is under src/main/resources/weblogic.xml and I want it to be placed under WEB-INF after install.(packaging is "war" by the way)

I tried this:

<resources>
            <resource>
                <directory>src/main/resources</directory>
                <targetPath>../resources</targetPath>
                <excludes><exclude>web.xml</exclude><exclude>weblogic.xml</exclude></excludes>
            </resource>
            <resource>
                <directory>src/main/resources/config</directory>
                <targetPath>..</targetPath>
                <includes><include>weblogic.xml</include></includes>
            </resource>
        </resources>

It is working with install but when I want a classpath using eclipse:eclipse, It gives the error :

Description Resource Path Location Type Cannot nest output folder 'ResponseManager/target/WEB-INF/resources' inside output folder 'ResponseManager/target/WEB-INF' ResponseManager Build path Build Path Problem

because of this conf in classpath:

  <classpathentry kind="src" path="src/main/resources" output="target/WEB-INF/resources" excluding="web.xml|weblogic.xml|**/*.java"/>
  <classpathentry kind="src" path="src/main/resources/config" output="target/WEB-INF" including="weblogic.xml" excluding="**/*.java"/>

Any ideas?


Solution

  • Normally files under src/main/resources get packaged along the compiled class files, in a webapp they would be placed in WEB-INF/classes. Is there any reason why you can't put these under the standard path src/main/webapp?

    If you need to package additional files which are not in the src/main/webapp folder then it would be better to configure these resources in the war plugin like this:

    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-war-plugin</artifactId>
        <version>2.1</version>
        <configuration>
            <webResources>
                <resource>
                    <directory>src/main/config</directory>
                    <targetPath>WEB-INF</targetPath>
                    <includes>
                        <include>weblogic.xml</include>
                    </includes>
                </resource>
            </webResources>                    
        </configuration>
    </plugin>
    

    It should be possible to specify the targetPath as above but I think it would be cleaner to reproduce the wanted directory structure inside your source folder.