maven gwt module depends on a external jar

464 views
Skip to first unread message

Kei Kei

unread,
May 22, 2012, 2:50:19 AM5/22/12
to codehaus-mojo-gwt-...@googlegroups.com
I have a mavenize gwt module depends on a jar(this jar is simple jar, no gwt related).
the project name of the jar is als-admin-viewer-core with maven coordinate
<groupId>hk.gov.ehr.service.tch.als</groupId>
<artifactId>als-admin-viewer-core</artifactId>
<version>1.0.0</version>
<package>jar</package>

and in the als-admin-viewer-core pom.xml, I already add the following plugin goal
<build>
    <plugins>
      <plugin>
          <groupId>org.apache.maven.plugins</groupId>  
        <artifactId>maven-source-plugin</artifactId>  
           <version>2.1.2</version>  
        <executions>
            <execution>
                <phase>package</phase>
                <goals>
                    <goal>jar-no-fork</goal>
                </goals>
            </execution>        
        </executions>          
      </plugin>   
    </plugins>
  </build>
and als-admin-viewer-core-1.0.0.jar and  als-admin-viewer-core-1.0.0-sources.jar is succesfully created in als-admin-viewer-core\target.

and the mavenize gwt module name is
als-admin-viewer-webapp
and in its .pom.xml, I already add the dependency as follow:
<dependency>
    <groupId>hk.gov.ehr.service.tch.als</groupId>
    <artifactId>als-admin-viewer-core</artifactId>
    <version>1.0.0</version>
</dependency>

<dependency>
    <groupId>hk.gov.ehr.service.tch.als</groupId>
    <artifactId>als-admin-viewer-core</artifactId>
    <version>1.0.0</version>
    <classifier>sources</classifier>
</dependency>
 
then I run maven clean install on als-admin-viewer-core first and then run mvn clean install on als-admin-viewer-webapp, but then the following error message prompted:
[INFO] --- gwt-maven-plugin:2.4.0:compile (default) @ als-admin-viewer-webapp ---
[INFO] auto discovered modules [hk.gov.ehr.service.tch.als.admin.viewer.AlsAdminViewerWebApp]
[INFO] Compiling module hk.gov.ehr.service.tch.als.admin.viewer.AlsAdminViewerWebApp
[INFO]    Validating newly compiled units
[INFO]       Ignored 5 units with compilation errors in first pass.
[INFO] Compile with -strict or with -logLevel set to TRACE or DEBUG to see all errors.
[INFO]    Scanning for additional dependencies: file:/D:/workspace/als-admin-viewer-webapp/src/main/java/hk/gov/ehr/service/tch/als/admin/viewer/client/SearchLogsPanel.java
[INFO]       Computing all possible rebind results for 'hk.gov.ehr.service.tch.als.admin.viewer.client.SearchService'
[INFO]          Rebinding hk.gov.ehr.service.tch.als.admin.viewer.client.SearchService
[INFO]             Checking rule <generate-with class='com.google.gwt.user.rebind.rpc.ServiceInterfaceProxyGenerator'/>
[INFO]                [ERROR] Errors in 'file:/D:/workspace/als-admin-viewer-webapp/src/main/java/hk/gov/ehr/service/tch/als/admin/viewer/client/SearchService.java'
[INFO]                   [ERROR] Line 16: No source code is available for type hk.gov.ehr.service.tch.als.admin.viewer.core.LogSearchCriteria; did you forget to inherit a required module?
[INFO]                   [ERROR] Line 17: No source code is available for type hk.gov.ehr.service.tch.als.admin.viewer.core.Log; did you forget to inherit a required module?

what is the reason? seem the AlsAdminViewerWebApp still cannot see the source java file of core!!
attached is the core pom.xml, webapp pom.xml and the error message.
errormessage.txt
pom.xml.core
pom.xml.viewer

Thomas Broyer

unread,
May 22, 2012, 3:50:15 AM5/22/12
to codehaus-mojo-gwt-...@googlegroups.com

On Tuesday, May 22, 2012 8:50:19 AM UTC+2, Kei Kei wrote:
[INFO]                [ERROR] Errors in 'file:/D:/workspace/als-admin-viewer-webapp/src/main/java/hk/gov/ehr/service/tch/als/admin/viewer/client/SearchService.java'
[INFO]                   [ERROR] Line 16: No source code is available for type hk.gov.ehr.service.tch.als.admin.viewer.core.LogSearchCriteria; did you forget to inherit a required module?
[INFO]                   [ERROR] Line 17: No source code is available for type hk.gov.ehr.service.tch.als.admin.viewer.core.Log; did you forget to inherit a required module?

what is the reason? seem the AlsAdminViewerWebApp still cannot see the source java file of core!!

Is there a GWT module adding hk.gov.ehr.service.tch.als.admin.viewer.core to the "source path"?
(e.g. I suppose there's a GWT module in hk.gov.ehr.service.tch.als.admin.viewer, which adds the "client" subpackage to the source path; does it also contain a <source path="core"/> to add the "core" subpackage to the source path too?)

Kei Kei

unread,
May 22, 2012, 4:47:21 AM5/22/12
to codehaus-mojo-gwt-...@googlegroups.com
Oh, after adding <source path='core'/>, it work now (the webapp can compile, can see the source in core jar).
I have checked and see the als-admin-viewer-core-1.0.0-sources.jar is located in the als-admin-viewer-webapp-1.0.0.war\WEB-INF\lib\
just 'core' is enough because the full package name of core is
hk.gov.ehr.service.tch.als.admin.viewer.core
and the AlsAdminViewerWebApp.gwt.xml is located in package
hk.gov.ehr.service.tch.als.admin.viewer
even in a different application (core in jar and gwt.xml in war)?
if the full package name of the core is
com.abc.core, then
in gwt.xml, should write
source path='com.abc.core'?

And I found there is no need to use the compileSourcesArtifacts paramer in gwt:compile.
in fact, I do not understand the section

Using general purpose JARs as GWT library

in http://mojo.codehaus.org/gwt-maven-plugin/user-guide/library.html
hope there will be a clear example for that section.
Anyway, your suggested method is easy to follow, thanks.

Thomas Broyer

unread,
May 22, 2012, 5:12:21 AM5/22/12
to codehaus-mojo-gwt-...@googlegroups.com


On Tuesday, May 22, 2012 10:47:21 AM UTC+2, Kei Kei wrote:
Oh, after adding <source path='core'/>, it work now (the webapp can compile, can see the source in core jar).
I have checked and see the als-admin-viewer-core-1.0.0-sources.jar is located in the als-admin-viewer-webapp-1.0.0.war\WEB-INF\lib\

Add <scope>provided</scope> on the dependency.
 
just 'core' is enough because the full package name of core is
hk.gov.ehr.service.tch.als.admin.viewer.core
and the AlsAdminViewerWebApp.gwt.xml is located in package
hk.gov.ehr.service.tch.als.admin.viewer
even in a different application (core in jar and gwt.xml in war)?

GWT loads from the classpath, so it doesn't matter where the files are "physically" located.
 
if the full package name of the core is
com.abc.core, then
in gwt.xml, should write
source path='com.abc.core'?

No. path="" should be a path (using "/" as a separator, not ".") relative to the *.gwt.xml file.

And I found there is no need to use the compileSourcesArtifacts paramer in gwt:compile.
in fact, I do not understand the section

Using general purpose JARs as GWT library

in http://mojo.codehaus.org/gwt-maven-plugin/user-guide/library.html
hope there will be a clear example for that section.

compileSourcesArtifacts is there only so you don't have to declare the dependency on the <classifier>sources</classifier> artifact. I prefer declaring the dependency than using the compileSourcesArtifacts "hack".
Message has been deleted

Kei Kei

unread,
May 23, 2012, 3:44:42 AM5/23/12
to codehaus-mojo-gwt-...@googlegroups.com
Oh, sorry, I think I make a great mistake?


adding <source path='core'/>
means the core package will be translated to javascript also.

but at first, what our company wants is to extract the server part logic to a general jar not depends on gwt client..., so after all the above change, my server part (the core jar) is still depends on gwt?

Or is it impossible to extract the server logic to a general jar because GWT client really need to pass the search criteria from gwt client to server and receive result<Log> from server?

the target is the final core jar can receive client search request from other application like GXT or any other client.

Thomas Broyer

unread,
May 23, 2012, 3:57:46 AM5/23/12
to codehaus-mojo-gwt-...@googlegroups.com
If you use GWT-RPC, the classes used with your GWT-RPC services will be used on the client-side so they have to be translatable to JS.
That doesn't necessarily mean your whole 'core' package has to be translatable though (you can use Ant-like filters with <source/> [1]), and it doesn't necessarily mean that your 'core' package is GWT-aware.
There's also the solution of providing GWT "emulated" versions of the classes, that would be used only on the client-side [2], you'd probably have to provide CustomFieldSerializer for those classes though [3].
There are also alternatives:
  • ditch GWT-RPC for RequestFactory (or any other protocol or API that wouldn't use your server-side classes on the GWT client-side code)
  • use specific "DTOs" for your GWT-RPC and copy them from/to your classes from the 'core' package

[2] See “Overriding one package implementation with another” on https://developers.google.com/web-toolkit/doc/latest/DevGuideOrganizingProjects#DevGuideModuleXml

Kei Kei

unread,
May 23, 2012, 4:09:43 AM5/23/12
to codehaus-mojo-gwt-...@googlegroups.com
I think the method

use specific "DTOs" for your GWT-RPC and copy them from/to your classes from the 'core' package
is the most easier for me in current situation.

What I think the meaning is
in core:
Class LogCore  // fucntion as DTO
Class LogCriteriaCore
// fucntion as DTO

method getSearchResult(LogSearchCriteriaCore criteria){
....
}

in webapp (client)
Class Log;
Class LogCriteria;

in Class
LogCriteria, import the LogCriteriaCore Class from core, then create logCriteriaCore object and use a method to copy all properties value in logCriteria to logCriteriaCore Object.
Then we can pass the
logCriteriaCore object from webApp to Core module getSearchResult(LogSearchCriteriaCore criteria).

is it correct?
Reply all
Reply to author
Forward
0 new messages