3
votes

Is there a way to put dependency of a war not in WEB-INF/lib but in out custom folder?

I'm using Maven 2

Hi, what i need is that from list of dependencies of a war only one artifact should be placed not in WEB-INF/lib but in WEB-INF/bundles/ and others dependencies should be places in WEB-INF/lib

thx

THX to everybody, i can't update to Maven 2.1 so i did it through maven-antrun plugin )

3
Why do you need to place this jar file in /WEB-INF/bundles?Robert Munteanu
Our apache felix is configured to search for bundles only in this folder (that is not WEB-INF/lib)breedish

3 Answers

4
votes

I think what you need to do is make the dependency provided and copy it using mvn copy-dependencies. Here is an example that does that with apache commons / lang:

<dependencies>
    <dependency>
        <groupId>commons-lang</groupId>
        <artifactId>commons-lang</artifactId>
        <version>2.5</version>
        <scope>provided</scope>
    </dependency>
</dependencies>

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-dependency-plugin</artifactId>
            <version>2.1</version>
            <executions>
                <execution>
                    <id>copydep</id>
                    <phase>prepare-package</phase>
                    <goals>
                        <goal>copy-dependencies</goal>
                    </goals>
                    <inherited>false</inherited>
                    <configuration>
                        <includeArtifactIds>commons-lang</includeArtifactIds>
                        <outputDirectory>$project.build.directory/${project.build.finalName}/web-inf/bundles</outputDirectory>
                    </configuration>
                </execution>
            </executions>
            <configuration>
            </configuration>
        </plugin>
    </plugins>
</build>

($project.build.directory/${project.build.finalName} is the work folder that is used to assemble the war)

1
votes

Maven war plugin supports extensive customization. Not clear from your question, what exactly you want, but this page should hopefully help.

0
votes

Where do you want to put these libraries? You have to be carefull, as the war structure defines the WEB-INF/lib as the directory for third-parties libraries. All *.jar files located in this directory will be loaded in the Classpath by the container (such as Tomcat).

Changing this directory can be harmful for your application!

That's why I am not aware of a configuration parameter for the Maven WAR Plugin that allow you to change this WEB-INF/lib directory.

If you really know what you are doing, you can try to create your own WAR using an assembly.