Wendy,

I can't say I've had this exact problem, but I can think of two approaches
I'd consider:

1) Create a separate project, let's call it jsf. Have all the RI/MyFaces
jars listed in its dependency list. No code is involved, but the build
produces two artifacts, both "uberjars" (not that you'd use the deprecated
plug-in) that incorporate all the classes needed for each option. Then your
existing approach with single-jar substitution based on a property will
continue to work.

2) Create two different "parent" project files, and have the "extends"
parameter depend on a property:

<project>
        <extends>${jsf.project.file}</extends>
...
</project>

Those base project files list the dependencies for the appropriate option.
You can use the same property to determine how to filter the web.xml file. I
did a quick test of this, and both ${pom.extends} and ${pom.dependencies}
appear to have gotten modified as I expected. I haven't verified that code
compilation, war bundling, etc. work, but since the object model appears
correct I would expect everything else to work.

I'm sure you could also script up a plug-in, but these two approaches seem
relatively simple to me with minimal modifications to your existing scripts.

Hope this helps,

Jay

-----Original Message-----
From: Wendy Smoak [mailto:[EMAIL PROTECTED] 
Sent: Monday, August 29, 2005 9:15 PM
To: Maven Users List
Subject: [m1] Conditional dependencies

I'm working on a project that needs to compile and build with *either* the
JSF Reference Implementation *or* Apache MyFaces.  This has to be
user-specified, at build time.  In addition to compilation and including the
correct .jar files in a webapp, there's also a modification that must be
done to web.xml, commenting out a section if we're using the RI, leaving it
in place for MyFaces.

And I had it working by having the user specify which JSF api and
implementation .jar files to use, as properties:

maven.shale.jsf.api.jar=${maven.repo.local}/myfaces/jars/myfaces-jsf-api-1.0
.9.jar
maven.shale.jsf.impl.jar=${maven.repo.local}/myfaces/jars/myfaces-impl-1.0.9
.jar
   or
maven.shale.jsf.api.jar=${maven.repo.local}/javax.faces/jars/jsf-api-1.1.jar
maven.shale.jsf.impl.jar=${maven.repo.local}/javax.faces/jars/jsf-impl-1.1.j
ar

But then I found out that for MyFaces, there is a *third* .jar file that
must be included in the .war file.  So now (realizing that there's probably
no way I can avoid a bunch of scripting) I'm thinking of having the user
specify either:

maven.shale.jsf = [myfaces|jsfri]
  or
maven.shale.jsf.ri = [true|false]
maven.shale.jsf.myfaces = [true|false]

Before I go any further with that, is there a precedent I should follow?

Alternately, because I can't specify "a" dependency in the project.xml file,
I already wrote 'myfaces-project.xml' which does nothing but declare the
dependencies so Maven will download them.  Is it possible that the "right
answer" is to have a 'myfaces-project.xml' file in each directory and do
either

$ maven build-all
   or
$ maven -p myfaces-project.xml build-all

depending on which JSF implementation you want to use?  I'm not sure I want
to start down that path, given that there may eventually be multiple JSF
implementations from which to choose.

What would you do in this situation?

If you want to take a look at the files:
   http://svn.apache.org/viewcvs.cgi/struts/shale/trunk/
or
   $ svn co http://svn.apache.org/repos/asf/struts/shale/trunk/ shale

(If you want to try to build it, read this first: 
http://wiki.wsmoak.net/cgi-bin/wiki.pl?ShaleMavenBuild )

Thanks for any advice!  I note that there is only one thread on this topic
in the archives... one post, with no replies.

--
Wendy Smoak




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to