madoke
madoke

Reputation: 873

Maven, Vaadin and the resources folder

I have an existing maven project, in which i started to use vaadin, by adding the dependency in the POM file. However, when i place the VAADIN/themes folder under src/main/resources, when building with maven it gets copied to the WEB-INF/classes folder in the .war file, instead of placing it in the war root like it is supposed to be. I already tried all obvious combinations like src/main/webapp/VAADIN or src/main/VAADIN or even src/main/webapp/WEB-INF/VAADIN but none of them seems to be the correct place to put the themes and other vaadin resources.

I also tried to generate a vaadin project like it is described in here https://vaadin.com/wiki/-/wiki/Main/Using%20Vaadin%20with%20Maven but no success. maven behaves in the same way.

Does anyone have an idea of how to correctly setup Vaadin themes on a maven project ? I am using osx 10.6 with maven 3

Any help would be much appreciated. Best Regards

Upvotes: 1

Views: 3162

Answers (2)

Samuel EUSTACHI
Samuel EUSTACHI

Reputation: 3156

You should get at the root of your war everything you put in src/main/webapp/ without any customization.

Upvotes: 2

Conan
Conan

Reputation: 2348

I'm not sure about Vaadin specifically, but you can use the Maven Resources plugin to copy resources to a specific place (anywhere you like, not just the target folder). So if you wanted to copy a folder called VAADIN from the root of your project to the root of your war, you could set it up like this:

<plugin>
  <artifactId>maven-resources-plugin</artifactId>
  <version>2.5</version>
  <executions>
    <execution>
      <id>copy-resources</id>
      <phase>validate</phase>
      <goals>
        <goal>copy-resources</goal>
      </goals>
      <configuration>
        <outputDirectory>${basedir}/target/war</outputDirectory>
        <resources>
          <resource>
            <directory>VAADIN</directory>
            <filtering>false</filtering>
          </resource>
        </resources>
      </configuration>
    </execution>
  </executions>
</plugin>

Generally the src/main/resources folder is intended for resources which are supposed to be on the classpath, and src/main/webapp is for resources which are supposed to be in the WEB-INF folder of your webapp. I'd recommend putting other resources elsewhere (maybe src/main/vaadin?). If you do really want to put it in src/main/resources and you use the approach I've just outlined, you'll also need to exclude it Maven copies the other things in there - easier just to avoid it.

Upvotes: 3

Related Questions