Can I add external libraries (eg Apache Commons) to my GWT project?

752 lượt xem
Chuyển tới thư đầu tiên chưa đọc

malcolm...@gmail.com

chưa đọc,
03:53:05 21 thg 4, 200821/4/08
đến Google Web Toolkit, malcolm...@gmail.com
Can I add external libraries such as Apache Commons http://commons.apache.org
o my GWT project?

I would like to import some of the Apache Commons import
org.apache.commons.lang.time.* library

import org.apache.commons.lang.time.*;

in to my client Java code.

Is this possible, or am I barking up the wrong tree?

Mal.

jhulford

chưa đọc,
09:39:04 21 thg 4, 200821/4/08
đến Google Web Toolkit
If the code you're planning on importing only utilizes classes that
GWT has emulated, then you should be able to use a 3rd party library.
Off the top of my head though, I'm pretty sure the commons lang code
steps outside those bounds.

http://code.google.com/webtoolkit/documentation/jre.html

On Apr 21, 3:53 am, "m.gor...@bom.gov.au" <malcolm.gor...@gmail.com>
wrote:
> Can I add external libraries such as Apache Commonshttp://commons.apache.org

doopa

chưa đọc,
09:07:52 21 thg 4, 200821/4/08
đến Google Web Toolkit
Yeah - in theory most of it should work.

On Apr 21, 9:53 am, "m.gor...@bom.gov.au" <malcolm.gor...@gmail.com>
wrote:
> Can I add external libraries such as Apache Commonshttp://commons.apache.org

malcolm...@gmail.com

chưa đọc,
20:36:42 21 thg 4, 200821/4/08
đến Google Web Toolkit
I am mainly interested in org.apache.commons.lang.time.DateUtils,
which (maybe?)
uses the core Java libraries GWT uses.

I expect I will see a compile time or run time error if it tries to
access a Java
library outside the GWT core. I want to try it in case it flies
through without
needing any non-GWT library dependencies.

I've added the following entry to the my <module_name>.gwt.xml file:

<inherits name="org.apache.commons.lang.time.DateUtils"/>

And I've added the following jars to the Java
Build Path, in Eclipse:

commons-lang-2.4.jar
commons-lang-2.4-sources.jar

The error I am seeing is:

Loading inherited module 'org.apache.commons.lang.time.DateUtils'
Unable to find 'org/apache/commons/lang/time/DateUtils.gwt.xml' on
your classpath; could be a typo ...

Does that mean I need to package DateUtils as a GWT module?

Am I pursuing a difficult and time-consuming way to save myself some
date handling tasks?

Mal.

gregor

chưa đọc,
21:10:17 21 thg 4, 200821/4/08
đến Google Web Toolkit
Possibly, Mal.

What you'd have to do in principle is to introduce a gwt.xml file, say
Date.gwt.xml, to the root of commons-lang-2.4-sources.jar like so:

<module>
<inherits name='com.google.gwt.user.User'/>
<source path="org.apache.commons.lang.time"/>
</module>

and inherit that in your main module gwt.xml as well as putting the
jar in your classpath. However, there are some possible problems:

1. DateUtil uses Calendar and I'm not sure that's supported in GWT JRE
Emulation 1.5M2 (it's not in 1.4.x).
2. Note you can only specify the package in the <source> tag, not an
individual class, so if there are other classes in /time/ package that
are not compatible GWT might object even if DateUtil would work on
it's own.

regards
gregor



On Apr 22, 1:36 am, "m.gor...@bom.gov.au" <malcolm.gor...@gmail.com>
wrote:

malcolm...@gmail.com

chưa đọc,
23:56:55 21 thg 4, 200821/4/08
đến Google Web Toolkit
Thanks Gregor.

That's deepened my understanding of GWT.

I'll play it safe and use the existing GWT Java library classes.

Mal.

Chii

chưa đọc,
09:39:54 22 thg 4, 200822/4/08
đến Google Web Toolkit
you can try to just extract the relevent classes out of the source of
commons (renaming package to something inside your current gwt
project), and see if it compiles.

On Apr 22, 1:56 pm, "m.gor...@bom.gov.au" <malcolm.gor...@gmail.com>
wrote:
Trả lời tất cả
Trả lời tác giả
Chuyển tiếp
0 tin nhắn mới