5

I have a project which consists of GWT client end and a Tomcat server end. Everything is setup using maven. However, I want the client's HTML and CSS files (which reside in the resources folder) to be copied to the server projects webapp directory. I have been looking at the maven-dependency-plugin but cannot get it to work. I cannot seem to find a way to specify the source and destination path. I'd appreciate if someone can point me in the right direction.

Thanks.

GlGuru
  • 756
  • 2
  • 10
  • 21

4 Answers4

3
  <!-- Use the following to extract all files from the dependent jar or war (see type) : -->

  <plugin>
     <artifactId>maven-dependency-plugin</artifactId>
     <executions>
       <execution>
         <id>unpack</id>
         <phase>generate-sources</phase>
         <goals>
           <goal>unpack</goal>
         </goals>
         <configuration>
           <artifactItems>
             <artifactItem>
               <groupId>com.group.id</groupId>
               <artifactId>artifact-id</artifactId>
               <version>1.0-SNAPSHOT</version>
               <type>jar</type>
               <overWrite>true</overWrite>
               <outputDirectory>target/exploded-artifact-id-jar</outputDirectory>
             </artifactItem>
           </artifactItems>
         </configuration>
       </execution>
     </executions>
   </plugin>

 <!-- then copy the neccessary files to the webapp directory -->

  <plugin> 
    <artifactId>maven-antrun-plugin</artifactId>  
    <executions> 
      <execution> 
        <id>copy-webapp-resources</id>  
        <phase>generate-resources</phase>  
        <configuration> 
          <tasks> 
            <copy todir="target/webapp" filtering="false"> 
              <fileset dir="target/exploded-artifact-id-jar/path-to-files"/>  
            </copy> 
          </tasks> 
        </configuration>  
        <goals> 
          <goal>run</goal> 
        </goals> 
      </execution>  
    </executions>  
  </plugin>
Dirk Jäckel
  • 2,979
  • 3
  • 29
  • 47
  • But the resources reside in another maven project which has been added as a dependency. – GlGuru Nov 14 '10 at 19:03
  • I have found this solution worked fine for resources residing in an external maven dependency. Although I am not sure why such an obtuse way of including resources is needed. When standard gwt compile ought to include the resources. – Nigel_V_Thomas Sep 13 '13 at 14:28
0

You should create a public folder at the same level that the <module_name>.gwt.xml module config file. That is:

+src/main/resources
|-<module_name>.gwt.xml
|-+public
  |-<static resources>

In that way, after gwt compilation, all the resources will go to src/main/webapp/<module_name>/. That folder is the one that maven (through the plugin) or you (manually) will use to create the final webapp.

Hope this helps.
Regards

Diego Sergnese
  • 340
  • 4
  • 12
0

Take a look at maven-war-plugin page at Apache Maven:

http://maven.apache.org/plugins/maven-war-plugin/examples/adding-filtering-webresources.html

Paul Verest
  • 60,022
  • 51
  • 208
  • 332
0

In your pom.xml, you can specify the resources you need to be used. Eg:

<build>
<!-- Resources to be bundeled with the final WAR -->
  <resources>
    <resource>
      <directory>config</directory>
    </resource>
  <resource>
      <directory>src/main/java</directory>
      <excludes>
        <exclude>**/*.java</exclude>
      </excludes>
  </resource>
  <resource>
    <directory>src/main/resources</directory>
  </resource>
</resources>
Arpit
  • 6,212
  • 8
  • 38
  • 69