Question

(maven 2.2.1)

Hello, I have this dir tree:

.
├── pom.xml
├── src
│   ├── main
│   │   └── webapp
│   │       ├── META-INF
│   │       ├── **resources**
│   │       │   ├── **bootstrap**
│   │       │   │   ├── **bootstrap**
│   │       │   │   │   ├── css
│   │       │   │   │   ├── img
│   │       │   │   │   └── js
│   │       │   │   ├── docs
│   │       │   │   ├── img
│   │       │   │   ├── js
│   │       │   │   ├── less
│   │       │   │   ├── LICENSE
│   │       │   │   ├── Makefile
│   │       │   │   ├── package.json
│   │       │   │   └── README.md
│   │       │   ├── cms
│   │       │   └── **static**
│   │       │       ├── css
│   │       │       ├── feeds
│   │       │       ├── img
│   │       │       ├── js
│   │       │       └── less
│   │       ├── WEB-INF

Where I highlighted with double * the interesting directories...

At package time, I'm trying both to exclude resources/bootstrap from the final WAR and copy resources/bootstrap/boostrap inside resources/static.

In other words, I need to obtain the following:

.
│   │       ├── META-INF
│   │       ├── **resources**
│   │       │   ├── cms
│   │       │   └── **static**
│   │       │       ├── **bootstrap**
│   │       │       │   ├── css
│   │       │       │   ├── img
│   │       │       │   └── js
│   │       │       ├── css
│   │       │       ├── feeds
│   │       │       ├── img
│   │       │       ├── js
│   │       │       └── less
│   │       ├── WEB-INF

I'm unluckily messing around with the maven-war-plugin but still I'm unable to obtain the desired result.

Here's the latest version of the relevant part of my pom:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-war-plugin</artifactId>
    <version>2.2</version>
    <configuration>
        <packagingExcludes>WEB-INF/**.tld</packagingExcludes>
        <warSourceExcludes>resources/bootstrap</warSourceExcludes>
        <webResources>
            <resource>
                <!-- this is relative to the pom.xml directory -->
                <directory>src/main/webapp/resources/bootstrap</directory>
                <!-- override the destination directory for this resource -->
                <targetPath>resources/static</targetPath>
                <includes>
                    <include>bootstrap/**</include>
                </includes>
            </resource>
        </webResources>                 
    </configuration>
</plugin>

Thank you in advance for any hints of follow-ups!

Was it helpful?

Solution

You were close; you need to specify resources/bootstrap/** for the warSourcesExcludes parameter in order to omit the entire tree (the directory and all its children). Only excluding the resources/bootstrap directory doesn't do anything, because it still includes all children of that directory, automatically creating the directory when it copies a child and the parent directory doesn't exist.

So your config should have:

    <configuration>
        ...
        <warSourceExcludes>resources/bootstrap/**</warSourceExcludes>
        ...
    </configuration>

And don't forget to run a Maven clean before packaging the war again.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top