ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Matt Raible <>
Subject Moving directories
Date Sun, 30 May 2004 20:04:49 GMT
I'm trying to create an ant target that will search through a directory 
structure of .java files.  I want to be able to pass in a package name 
and it'll rename all packages and directories.  Using the target below, 
src/dao/org/appfuse/model is getting moved to 
src/dao/com/company/org/appfuse/model.  Any idea how to fix it so that 
src/dao/com/company/model is the final directory?



=================================================================== -->
<!-- Replaces all instances of "org.appfuse" with new package name.     
<!-- Also attempts to move all org.appfuse files to new package 
=================================================================== -->
<target name="repackage">
	<fail unless="">
		You must specify an using  You must
		use a validd package name, such 'com.mycompany'.

	<replaceregexp flags="g">
		<regexp pattern="org.appfuse"/>
		<substitution expression="${}"/>
		<fileset dir="../${}">
			<!-- just in case build has files in it -->
			<include name="${build.dir}/**"/>
			<include name="src/**/*.java"/>
			<include name="src/**/*.xml"/>
			<include name="test/**/*.java"/>
			<include name="extras/**/*.java"/>
			<include name="extras/**/*.xml"/>
			<include name="metadata/web/global-exceptions.xml"/>
			<include name="metadata/templates/struts_form.xdt"/>
			<include name="web/WEB-INF/*.xml"/>
			<include name="web/WEB-INF/classes/"/>
			<exclude name="extras/jsp/build/**"/>

	<script language="javascript"><![CDATA[
		packageName = project.getProperty("");
		packageDir = packageName.replace('.', 
		project.setProperty("package.dir", packageDir);
	<echo>Moving files from 'org\appfuse' to '${package.dir}'.</echo>
	<move todir="../${}/src/dao/${package.dir}" 
		<fileset dir="../${}/src/dao">
		  <include name="org/appfuse/**/*.java"/>
		  <include name="org/appfuse/**/*.xml"/>
	<move todir="../${}/src/service/${package.dir}" 
		<fileset dir="../${}/src/service">
		  <include name="org/appfuse/**/*.java"/>
		  <include name="org/appfuse/**/*.xml"/>
	<move todir="../${}/src/web/${package.dir}" 
		<fileset dir="../${}/src/web">
		  <include name="org/appfuse/**/*.java"/>
		  <include name="org/appfuse/**/*.xml"/>


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message