Ronald, I have a very similar setup in my projects where ANT was used based
on an if clause. In fact I wound up actually using ant-contrib to give me
if/else type logic to make the builds more readable.
Have you looked into Maven2 style PROFILES? A profile allows you to define
a number of configuration parameters based on some activation property
(system property I think is currently the only thing supported) as well as a
command line define, think "-Dweblogic" passed to mvn.
Here is a pointer:
http://maven.apache.org/guides/introduction/introduction-to-profiles.html
-aps
On 9/13/06, Ronald Kurr <[EMAIL PROTECTED]> wrote:
I've been looking at Maven 2 as a replacement to a current ANT-based build
system and I'm looking for ideas on how I might be able to translate one
of
the features it currently provides. The code base supports multiple J2EE
containers. Sometimes we have to build two different versions of the same
code with each version relying on vendor-specific APIs. Sometimes
modules
are built only when a certain vendor's container is targeted. We handle
triggering of optional but vendor-specific modules via the if attribute
of
the target tag. For example,
<target name="do-websphere-only-module" if="websphere">
...
</target>
We handle the triggering of mandatory but vendor-specific code by naming
conventions and property values. For example, our source directories are
layed out similar to this:
source/java/neutral
source/java/weblogic
source/java/websphere
When the ANT build is kicked off, a property is set to indicate the target
platform: -Dvendor=weblogic. When then use the value of the property to
construct the source path for that build:
<path id="compile.source.path">
<pathelement location="source/java/neutral"/>
<pathelement location="source/java/${vendor}"/>
</path>
This allows us to only include the correct vendor-specific source during
the
build. We use a similar technique when building out the classpath which
contains vendor-specific libraries.
I'm trying to figure out how I might achieve similar functionality under
Maven 2 and could use some suggestions. My first idea was to house the
mandatory but vendor-specific code in their own modules and use a naming
convention coupled with a property to control which module gets invoked by
the parent module. For example,
module names:
mandatory-webshere/
mandatory-weblogic/
mandatory-jboss/
parent POM:
<modules>
<module>mandatory-${vendor}</module>
<module>pojo-one</module>
<module>ejb-one</module>
<module>web-one</module>
<module>ear-one</module>
</modules>
That seems to work but I'm open to other ideas. What I haven't been able
to
figure out is how to configure the "only build this module if the target
is
Webshere" logic. Any ideas are appreciated. I'd like to avoid having to
drop down to ANT using the maven-antrun-plugin or writing a custom plugin
but I'll try whatever suggestions are provided.
Many Thanks,
Ron
--
"What lies behind us and what lies in front of us is of little concern to
what lies within us." -Ralph Waldo Emerson