On 20 January 2011 06:26, Jesse Farinacci <jie...@gmail.com> wrote:
> Greetings Hilco,
>
> On Wed, Jan 19, 2011 at 8:07 PM, Hilco Wijbenga
> <hilco.wijbe...@gmail.com> wrote:
>>
>> Option 1: It's easy to write a POM that creates a JAR for a GWT widget
>> including CSS and other resources. It's also easy to then write a POM
>> that depends on that JAR and creates a WAR for integration testing. So
>> far so good.
>
> This is by far the best solution. If you want to create widgets to be
> shared across multiple projects, just make a packaging=jar and make
> sure src/main/java is part of build.resources. Then include
> src/main/java/com/acme/gwt/client/MyWidget.java and
> src/main/resources/com/acme/gwt/MyWidgets.gwt.xml as part of the
> project and install it as per usual (mvn install).

I agree but only from a build/Maven's point of view.

>> Problem: Making changes in (e.g.) the CSS requires a full rebuild of
>> both the JAR and the WAR. This is a real productivity issue.
>
> I'm not unsympathetic to this, but you can't have it both ways. You
> either want re-usable components a la a library, which has a bit of
> steadiness to it, or you want rapid development -- they are competing
> goals.

I think I *can* have it both ways. It's working now. :-)

>> Option 2: Put everything in a single WAR project. Integration testing
>> uses this WAR and development can make changes that are reflected
>> after a simple refresh.
>
> Yep, you can definitely do this, but it goes against the (unstated by
> OP) goal of reusability of components.

It may not have been stated very clearly but it was certainly implied.
:-) Reusability is why I'm trying to do all this.

I don't think it "goes against" this, it just makes it a bit harder.

>> Problem: We need a JAR, not a WAR for our other GWT projects that want
>> to reuse the widget.
>
> Your war project which wants to incorporate the reusable widget jar
> need only to add <inherits name="com.acme.gwt.MyWidgets"/> and then
> utilize MyWidget somewhere. It will be properly compiled, and since
> you include src/main/java as part of the reusable widget's
> build.resources, GWT compiler will be happy.

Not quite following you here. What you say is true, and it's what I'm
doing, but I don't see how it relates to the problem. I need a JAR,
not a WAR, as a dependency. (Well, strictly speaking, a WAR would work
too but I'd have to unzip it before using [parts of] it.)

>> The only "solution" that I can see is to go with option 2 and create a
>> second (JAR) project that depends on the WAR and strips away all its
>> "web-app-ness" to create the JAR I referred to in option 1. This
>> achieves all my goals but isn't very elegant. Can anyone think of a
>> better way to do this?
>
> Best of luck to you, I have had a lot of success with the method I've
> outlined. I have about two dozen general purpose widgets, twice that
> in general reusable GWT async services, and incorporated them into
> about 20 internal projects. Everything works quite nicely...

I take it you don't have to deal with many other people (specifically
non-developer people). :-) But even if it were just me, it's really
nice to be able to see changes reflected after a refresh instead of a
full rebuild of both a JAR and a WAR.

The current setup is working quite nicely. My WAR project generates a
JAR as well and this JAR contains just the files needed for a GWT
widget. I was a little worried because the JAR and WAR share the same
POM (with <packaging>war</packaging>) but that does not seem to be a
problem.

Cheers,
Hilco

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@maven.apache.org
For additional commands, e-mail: users-h...@maven.apache.org

Reply via email to