Upgrade legacy Java Project from Ant (i.e. subant) to Maven

44 Views Asked by At

I have this java project handled by Ant modules (subant.xml)

-src
¦
+---com
¦       ¦   +---SomePackage1
¦       ¦   +---SomePackage2
¦       ¦   +---OtherPackage
¦       +---businessPackage
¦       ¦   +---business
¦       ¦   ¦   +---ejb1
¦       ¦   ¦   ¦   +---managers
¦       ¦   ¦   ¦   +---session
¦       ¦   ¦   +---exceptions
¦       ¦   ¦   +---utils
¦       ¦   +---gateway
¦       ¦       +---ejb
¦       ¦       +---managers
¦       +---MyPackage
¦       ¦   +---database
¦       ¦   ¦   +---ejb
¦       ¦   ¦   +---exceptions
¦       ¦   ¦   +---model
¦       ¦   ¦   +---utils
¦       ¦   +---ejb
¦       ¦   ¦   +---configuration
¦       ¦   +---global
¦       ¦       +---config
¦       ¦       ¦   +---exceptions
¦       ¦       +---utils
¦       ¦       +---xml
¦       ¦           +---exceptions
¦       ¦           +---utils
¦       +---utils
+---CMEjbModule
¦   +---META-INF->subant.xml, ejb-jar.xml (tag <ejbjar>)
+---OtherEjbModule
¦   +---META-INF->subant.xml, ejb-jar.xml (tag <ejbjar>)
+---FrontOfficeEjbModule
¦   +---META-INF->subant.xml, ejb-jar.xml (tag <ejbjar>)
+---BackOfficeEjbModule
¦   +---META-INF->subant.xml, ejb-jar.xml (tag <ejbjar>)
+---MyJarModule
¦   +---META-INF->subant.xml, (tag <jar>)
+---MyJar2Module
¦   +---META-INF->subant.xml, (tag <jar>)
build.xml

Each subant.xml contains <ejbjar> for EJB (it's creates a JAR module) and <jar> for JAR archives. The <ejbjar> source is like that:

<ejbjar  
    basejarname="CMEjbModule"
    destdir=<dir.to.copyJar>
    flatdestdir="true"
    genericjarsuffix=".jar"
    srcdir=<directory classes>
        descriptordir=<ejb descriptor dir>  
    dependency="full">
    <jboss/>            
    <include name="**/ejb-jar.xml"/>
    <include name="**/jboss-deployment-structure.xml"/>
    <dtd publicId="-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 3.0//EN" location="${jboss.home}/docs/dtd/ejb-jar_3_0.dtd" />
</ejbjar>

The other module are simply JAR archives created by <jar> ant tag.

The result after build.xml is six components, i.e. six JARs, one for any module directory: CMEjbModule.jar, OtherEjbModule.jar, FrontOfficeEjbModule.jar, BackOfficeEjbModule.jar, MyJarModule.jar, MyJar2Module.jar (the first four JARs contain stateless EJBs as described in their own ejb-jar.xml)

Now, I would like to update this project to a Maven (POM) project without ant-run plugin Maven. The problem is: the source java directory is unique and it's very difficult to split src into independent sub-project because there are many source classes shared by six modules.

Is it possible? For example, I prefer using the Maven <module> pattern like subant.xml without ejb-jar.xml because the EJB are 3.0, but I ignore how is possible, i.e., in each Maven module sub-project if it's possible to select some source directory to compile each module or some EJB Java source (and their dependencies) from Java project.

0

There are 0 best solutions below