Unrecognised tag: 'compileSourcesArtifacts'

465 views
Skip to first unread message

Thad

unread,
May 8, 2013, 12:13:00 PM5/8/13
to codehaus-mojo-gwt-...@googlegroups.com
I'd like to use Maven with my next GWT project. I've worked through  Sonatype's "Maven by Example" and have converted some of my current libraries from Ant to Maven builds.

I've a database library which is used by GWT and non-GWT projects. With Ant, I'd simply copy the *.java, *.class, and *.gwt.xml files into the same jar file. I'm trying to do this with Maven. Initially I used the maven-resources-plugin with a copy-resources goal. This is not ideal as it requires the path to the database *.java and *.class files in my datebase-gwt's POM (as it did with Ant).

I'm trying to follow the directions for "Using general purpose JARs as GWT library" (at http://mojo.codehaus.org/gwt-maven-plugin/user-guide/library.html), but it's not working, or at least not the way I though it would.

First off, if I put 

  <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>gwt-maven-plugin</artifactId>
        <version>2.5.1</version>
        <compileSourcesArtifacts>
          <compileSourcesArtifact>com.mycorp.database:db</compileSourcesArtifact>
        </compileSourcesArtifacts>
  </plugin>

in my pom.xml I get the error: 

$ mvn clean install
[INFO] Scanning for projects...
[ERROR] The build could not read 1 project -> [Help 1]
[ERROR]   
[ERROR]   The project com.mycorp.database:db-gwt:8.1 (/home/thad/dev/gen2/db-gwt/pom.xml) has 1 error
[ERROR]     Malformed POM /home/thad/dev/gen2/db-gwt/pom.xml: Unrecognised tag: 'compileSourcesArtifacts' (position: START_TAG seen ...</version>\r\n        <compileSourcesArtifacts>... @115:34)  @ /home/thad/dev/gen2/db-gwt/pom.xml, line 115, column 34 -> [Help 2]

Why this error?

mvn install will run if I put <compileSourcesArtifacts> inside a configuration element, but there are no java or class files from db the resulting db-gwt-8.1.jar (though both db-8.1.jar and db-8.1-sources.jar are in my local repository).

I expect to see what I get with Ant, a db-gwt jar with

com/mycorp/Database.gwt.xml
com/mycorp/DbGwt.gwt.xml
com/mycorp/database/Foo.class
com/mycorp/database/Foo.java
com/mycorp/database/Bar.class
com/mycorp/database/Bar.java
...

Where Database.gwt.xml is

  <module rename-to='db'>
        <inherits name="com.google.gwt.core.Core"/>
        <source path="database"/>
  </module>

and DbGwt.gwt.xml is

  <module rename-to='db-gwt'>
        <inherits name='com.google.gwt.user.User'/>
        <inherits name='com.optix.Database' />
  </module>

Is this what I should see? Or should I see a virtually empty jar file? If so, how to I declare dependencies in my GWT project? By stacking db-8.1.jar, db-8.1-sources.jar, and db-gwt-8.1.jar some how?

Thanks.

Thomas Broyer

unread,
May 8, 2013, 5:21:21 PM5/8/13
to codehaus-mojo-gwt-...@googlegroups.com
Plugin configuration has to go inside a <configuration> element.

Thad

unread,
May 9, 2013, 8:46:28 PM5/9/13
to codehaus-mojo-gwt-...@googlegroups.com
Okay. But, again, how do I mash this together in a dependency? I've tried to add dependencies for db-8.1.jar, db-8.1-sources.jar, and db-gwt-8.1.jar, but when I try to create an object from db-8.1.jar, DevMode tells me the source is not found (although all three files are in WEB-INF/lib.

Thad

unread,
May 9, 2013, 9:49:00 PM5/9/13
to codehaus-mojo-gwt-...@googlegroups.com
I found an approach using maven-shade-plugin

You will require both the*.jar and *-sources.jar in your repository.

In the dependencies of your combined project, put both the *.jar and *-sources.jar:

  <dependencies>
    <dependency>
      <groupId>com.mycorp.database</groupId>
      <artifactId>db</artifactId>
      <version>${project.version}</version>
    </dependency>
    <dependency>
      <groupId>com.mycorp.database</groupId>
      <artifactId>db</artifactId>
      <version>${project.version}</version>
      <classifier>sources</classifier>
    </dependency>
  </dependencies>

Add one plugin to to build/plugins:

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-shade-plugin</artifactId>
        <version>2.0</version>
        <executions>
          <execution>
            <phase>package</phase>
            <goals>
              <goal>shade</goal>
            </goals>
            <configuration>
              <shadeSourcesContent>true</shadeSourcesContent>
              <filters>
                <filter>
                  <artifact>com.mycorp.database:db</artifact>
                  <includes>
                    <include>**/*.java</include>
                    <include>**/*.class</include>
                  </includes>
                  <excludes>
                    <exclude>META-INF/*</exclude>
                  </excludes>
                </filter>
              </filters>
            </configuration>
          </execution>
        </executions>
      </plugin>

Run `mvn clean install`. This creates a single jar with both *.java and *.class files and the Database.gwt.xml file.

This did not require a dummy class in the current project, nor the DbGwt.gwt.xml to instantiate a class on the GWT client side.

For the using project, declare 

    <dependency>
      <groupId>com.mycorp.database</groupId>
      <artifactId>db-gwt</artifactId>
      <version>${project.version}</version>
    </dependency>

And put <inherits name='com.mycorp.Database'/> in your project file (*.gwt.xml).

Thomas Broyer

unread,
May 10, 2013, 4:19:37 AM5/10/13
to codehaus-mojo-gwt-...@googlegroups.com


On Friday, May 10, 2013 2:46:28 AM UTC+2, Thad wrote:
Okay. But, again, how do I mash this together in a dependency? I've tried to add dependencies for db-8.1.jar, db-8.1-sources.jar, and db-gwt-8.1.jar, but when I try to create an object from db-8.1.jar, DevMode tells me the source is not found (although all three files are in WEB-INF/lib.

compileSourcesArtifacts is about resolving the sources artifact so you don't have to have a dependency on it.
Compiler and DevModel should have in their classpath all your scope=compile and scope=provided dependencies, and the sources artifacts from compileSourcesArtifacts.

I do not use compileSourcesArtifacts, I prefer adding the dependency on the sources artifacts (like you did with your maven-shade-plugin hack), and it just works.
Reply all
Reply to author
Forward
0 new messages