Search code examples
javamavenmaven-3warvaadin7

Vaadin: How to add META-INF/services to the war?


I have a Vaadin 7 maven web project that has some annotations that create service definition on META-INF/services.

I added this to the pom so the annotations are processed:

<!-- Run annotation processors on src/main/java sources -->
<plugin>
    <groupId>org.bsc.maven</groupId>
    <artifactId>maven-processor-plugin</artifactId>
    <version>3.3.1</version>
    <executions>
        <execution>
            <id>process</id>
            <goals>
                <goal>process</goal>
            </goals>
            <phase>generate-sources</phase>
        </execution>
    </executions>
</plugin>

The files show within target/classes/META-INF/services but don't make it to the final war.

I tried adding the folder to the maven-war-plugin like this:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-war-plugin</artifactId>
    <version>3.0.0</version>
    <configuration>
        <failOnMissingWebXml>false</failOnMissingWebXml>
        <packagingIncludes>target/classes/*</packagingIncludes>
    </configuration>
</plugin>

But then most of the Vaadin files don't make it into the war and it doesn't work. Any idea?


Solution

  • I ended up using the approach from this unrelated answer: Maven: include folder in resource folder in the war build.

    Here's what I ended up doing:

                 <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-war-plugin</artifactId>
                    <version>3.0.0</version>
                    <configuration>
                        <failOnMissingWebXml>false</failOnMissingWebXml>
                        <webResources>
                            <resource>
                                <directory>target/classes/META-INF/services</directory>
                                <includes>
                                    <include>*.*</include>
                                </includes>
                                <targetPath>META-INF/services</targetPath>
                            </resource>
                        </webResources>
                    </configuration>
                </plugin>
    

    Basically added the services folder as a resource and placed it on the right place of the final war.