2

I'm rewriting legacy Spring project build script from Ant to Maven. The project has several GWT modules, each compiled to JAR. The current project structure consists of several Maven modules, which is more or less like this: mainProject |- AnalyzerGWT <-- this module uses GWT |- analyzer <-- this doesn't |- someOtherModule |- p4you-spring <-- this module has resources and builds WAR

Each module, which uses GWT, has following code in its pom.xml (module is called AnalyzerGWT):

        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>gwt-maven-plugin</artifactId>
            <version>2.5.1</version>
            <configuration>
                <gwtSdkFirstInClasspath>true</gwtSdkFirstInClasspath>
                <compileSourcesArtifacts>
                    <artifact>com.pamm:portal-common</artifact>
                    <artifact>com.pamm:analyzer</artifact>
                </compileSourcesArtifacts>
            </configuration>
            <executions>
                <execution>
                    <goals>
                        <goal>compile</goal>
                        <goal>test</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>

It compiles successfully and result GWT resources are saved into AnalyzerGWT/target/AnalyzerGWT-1.0/com.pamm.analyzer.gwt.Analyzer/, however the content of this directory is not included to result JAR file.

Is there an elegant way to copy the content of this directory into JAR's root path?

yuiu
  • 93
  • 10

2 Answers2

2

I managed to solve the problem by adding:

   <plugin>       
         <artifactId>maven-resources-plugin</artifactId>
            <version>2.5</version>
            <executions>
                <execution>
                    <id>copy-resources</id>
                    <phase>prepare-package</phase>
                    <goals>
                        <goal>copy-resources</goal>
                    </goals>
                    <configuration>
                        <outputDirectory>${project.build.outputDirectory}</outputDirectory>
                        <resources>
                            <resource>
                                <directory>
                                    ${project.build.directory}/AnalyzerGWT-1.0/com.pamm.analyzer.gwt.Analyzer/
                                </directory>
                                <filtering>false</filtering>
                            </resource>
                        </resources>
                    </configuration>
                </execution>
            </executions>
    </plugin>

to the <plugins> section in pom.xml.

yuiu
  • 93
  • 10
0

The files in that folder is most likely the javascript produced by the GWT compiler, and as such you're probably better off packaging the module as a WAR file instead

<packaging>war</packaging>

and Maven will do the rest for you.

Cheers,

Anders R. Bystrup
  • 15,729
  • 10
  • 59
  • 55
  • Thank you for your answer. However it doesn't do the trick. Project has several modules and each of them is supposed to be compiled into JAR. All these JARs are packaged to WAR by *maven-war-plugin* defined in separate module. The structure is more-or-less like this: – yuiu Nov 09 '15 at 14:49
  • I didn't manage to write it 5 minutes: The parent project: *mediaMonitor*, modules: *AnalyzerGWT*, *analyzer*, some other modules, *p4you-spring* - module with resources, which compiles WAR. – yuiu Nov 09 '15 at 14:57
  • 1
    How about war overlays? – Thomas Broyer Nov 09 '15 at 16:59
  • I still can't help to think that you're approaching this wrongly. As `AnalyzerGWT` generates JavaScript, then this should be a WAR. There's nothing to prevent you from creating two WARs and package them in an EAR or so for deployment. WAR overlays are primarily for sharing resources between several WARs... – Anders R. Bystrup Nov 10 '15 at 09:43
  • @AndersR.Bystrup I am aware of that, but I'm constrained by the current project layout. I'm not allowed to change it. – yuiu Nov 10 '15 at 12:23