Here's an Ant copy task example where I begin with a hierarchical structure of jar files in my development environment (in my lib folder), then flatten out all my lib
subdirectories into one directory in my production environment when I copy all the jar files to my production library directory (using the flatten attribute of the Ant copy task):
<!-- build a temporary lib dir, and flatten out the jars into one folder --> <copy todir="${temp.dir.lib}" flatten="true"> <fileset dir="${lib.dir}"> <exclude name="${cob.lib.dir}" /> <exclude name="junit*" /> <include name="**/*.jar"/> <include name="**/*.zip"/> </fileset> </copy>
(As you can see from those commands, I also use some Ant copy exclude
and copy include
statements during the copy
process.)
To be more clear, before my Ant build script runs I start with a directory structure that looks like this in my development environment:
lib/axis2 lib/axis2/axiom-api-1.2.5.jar lib/axis2/axis2-adb-1.3.jar lib/axis2/axis2-codegen-1.3.jar lib/axis2/axis2-jws-api-1.3.jar lib/axis2/axis2-kernel-1.3.jar lib/axis2/axis2-spring-1.3.jar lib/axis2/axis2-xmlbeans-1.3.jar lib/cobertura lib/cobertura/asm-2.2.1.jar lib/cobertura/asm-tree-2.2.1.jar lib/cobertura/cobertura.jar lib/commons-dbcp-1.2.2.jar lib/commons-logging-1.1.jar lib/commons-pool-1.3.jar lib/jakarta-oro-2.0.8.jar lib/junit-4.4.jar lib/log4j-1.2.14.jar lib/mysql-connector-java-5.1.6.jar lib/sam-common-1.1.jar lib/spring.jar lib/sqlserver lib/sqlserver/msbase.jar lib/sqlserver/mssqlserver.jar lib/sqlserver/msutil.jar lib/webservice lib/webservice/activation-1.1.jar lib/webservice/commons-beanutils-1.7.0.jar lib/webservice/commons-codec-1.3.jar lib/webservice/commons-collections-3.2.jar lib/webservice/commons-dbcp.jar lib/webservice/commons-httpclient-3.0.jar lib/webservice/commons-pool.jar lib/webservice/jaxen-1.1-beta-9.jar lib/webservice/jaxws-api-2.0.jar lib/webservice/jdom-1.0.jar lib/webservice/jsr173_api-1.0.jar lib/webservice/mail-1.4.jar lib/webservice/saaj-api-1.3.jar lib/webservice/saaj-impl-1.3.jar lib/webservice/spring.jar lib/webservice/stax-api-1.0.1.jar lib/webservice/wsdl4j-1.6.1.jar lib/webservice/wstx-asl-3.2.0.jar lib/webservice/xbean-2.2.0.jar lib/webservice/xbean-spring-2.8.jar lib/webservice/xfire-aegis-1.2.6.jar lib/webservice/xfire-annotations-1.2.6.jar lib/webservice/xfire-core-1.2.6.jar lib/webservice/xfire-java5-1.2.6.jar lib/webservice/xfire-jaxws-1.2.6.jar lib/webservice/xfire-jsr181-api-1.0-M1.jar lib/webservice/xfire-spring-1.2.6.jar lib/webservice/XmlSchema-1.1.jar
After my build script runs I end up with a flat directory structure in my production environment, like this:
lib/axiom-api-1.2.5.jar lib/axis2-adb-1.3.jar lib/axis2-codegen-1.3.jar lib/axis2-jws-api-1.3.jar lib/axis2-kernel-1.3.jar lib/axis2-spring-1.3.jar lib/axis2-xmlbeans-1.3.jar lib/asm-2.2.1.jar lib/asm-tree-2.2.1.jar lib/cobertura.jar lib/commons-dbcp-1.2.2.jar lib/commons-logging-1.1.jar lib/commons-pool-1.3.jar lib/jakarta-oro-2.0.8.jar lib/junit-4.4.jar lib/log4j-1.2.14.jar lib/mysql-connector-java-5.1.6.jar lib/sam-common-1.1.jar lib/spring.jar lib/msbase.jar lib/mssqlserver.jar lib/msutil.jar lib/activation-1.1.jar lib/commons-beanutils-1.7.0.jar lib/commons-codec-1.3.jar lib/commons-collections-3.2.jar lib/commons-dbcp.jar lib/commons-httpclient-3.0.jar lib/commons-pool.jar lib/jaxen-1.1-beta-9.jar lib/jaxws-api-2.0.jar lib/jdom-1.0.jar lib/jsr173_api-1.0.jar lib/mail-1.4.jar lib/saaj-api-1.3.jar lib/saaj-impl-1.3.jar lib/spring.jar lib/stax-api-1.0.1.jar lib/wsdl4j-1.6.1.jar lib/wstx-asl-3.2.0.jar lib/xbean-2.2.0.jar lib/xbean-spring-2.8.jar lib/xfire-aegis-1.2.6.jar lib/xfire-annotations-1.2.6.jar lib/xfire-core-1.2.6.jar lib/xfire-java5-1.2.6.jar lib/xfire-jaxws-1.2.6.jar lib/xfire-jsr181-api-1.0-M1.jar lib/xfire-spring-1.2.6.jar lib/XmlSchema-1.1.jar
As you can see in this listing, after my Ant copy / flatten command, all my jar files are in one directory -- the subdirectory structure was removed during the Ant copy / flatten process.
I like this, because I can keep my lib
directories clean and organized in development, then put everything in one lib
directory for the application server in the production environment.