2

I am trying to configure the exec-war-only goal for my build to include some Extra resources (some config files). The configuration that i am using is given below

 <plugin>
     <groupId>org.apache.tomcat.maven</groupId>
     <artifactId>tomcat7-maven-plugin</artifactId>
     <version>2.2</version>
     <executions>
         <execution>
             <phase>package</phase>
             <goals>
                 <goal>exec-war-only</goal>
             </goals>
         </execution>
     </executions>
     <configuration>
         <buildDirectory>${project.basedir}/../kmszip/</buildDirectory>
         <path>/kms</path>
         <finalName>${project.artifactId}.jar</finalName>
         <enableNaming>true</enableNaming>
         <extraResources>
             <directory>${project.basedir}/</directory>
             <includes>
                 <include>config.json</include>
             </includes>
         </extraResources>
     </configuration>
 </plugin>

I am getting the following error while building using the above configuration

[ERROR] Failed to execute goal org.apache.tomcat.maven:tomcat7-maven-plugin:2.2:exec-war-only (default) on project KeyManagementService: Unable to parse configuration of mojo org.apache.tomcat.maven:tomcat7-maven-plugin:2.2:exec-war-only for parameter directory: Cannot find default setter in class org.apache.tomcat.maven.plugin.tomcat7.run.ExtraResource -> [Help 1]

I also tried using the below config for <extraResources> and got a similar error as the one above.

<extraResources>
    <extraResource>${project.basedir}/config.json</extraResource>
</extraResources>
Tunaki
  • 132,869
  • 46
  • 340
  • 423

1 Answers1

0

You are missing the <extraResource> tag under <extraResources>. The correct configuration should be:

<plugin>
    <groupId>org.apache.tomcat.maven</groupId>
    <artifactId>tomcat7-maven-plugin</artifactId>
    <version>2.2</version>
    <executions>
        <execution>
            <phase>package</phase>
            <goals>
                <goal>exec-war-only</goal>
            </goals>
        </execution>
    </executions>
    <configuration>
        <buildDirectory>${project.basedir}/../kmszip/</buildDirectory>
        <path>/kms</path>
        <finalName>${project.artifactId}.jar</finalName>
        <enableNaming>true</enableNaming>
        <extraResources>
            <extraResource>
                <directory>${project.basedir}/</directory>
                <includes>
                    <include>config.json</include>
                </includes>
            </extraResource>
        </extraResources>
    </configuration>
</plugin>
Tunaki
  • 132,869
  • 46
  • 340
  • 423