ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sascha Ernst <sascha.er...@living-e.com>
Subject delete directory structures older than X days
Date Tue, 16 Jun 2009 15:58:30 GMT
Hello,

I googled the mailing list archive and found a matching solution based on javascript for ant
1.5.

I'm using ant 1.7.1 and tried this to delete NBS-folders (NightlyBuildSystem) older than a
specific amount of time.

  <target name="delete.old.stuff"
          depends="init"
          description="delete all NBS stuff which is older than a specific amount of time">

    <!-- start the timer -->
    <stopwatch name="timer.delete.old.stuff"/>

    <!-- first calculate the borderline timestamp -->
    <tstamp>
      <format property="borderline.timestamp" pattern="MM/dd/yyyy HH:mm aa"
              offset="${deletion.threadshold}" unit="day"/>
    </tstamp>

	<echo message="borderline.timestamp=${borderline.timestamp}" />
	
	<!-- now delete all NBS checkouts and stuff older than that boderline timestamp -->
	<echo message="delete ${NBS.dir.prefix}** in ${nbsdir} before ${borderline.timestamp}"
/>
	<delete includeemptydirs="true" verbose="true">
	  <dirset dir="${nbsdir}" includes="${NBS.dir.prefix}**">	  
	    <date datetime="${borderline.timestamp}" when="before" checkdirs="true"/>
	  </dirset>
	</delete>

	<!-- now determine the  artifact folder -->
	<property name="artifact.dir" value="${builddir}/CruiseControl/artifacts/${projectname}"
/>

	<echo message="artifact.dir=${artifact.dir}" />

	<!-- now delete all artifacts and stuff older than that boderline timestamp -->
	<echo message="delete **/**/* in ${artifact.dir} before ${borderline.timestamp}" />
	<delete includeemptydirs="true"  verbose="true">
	  <dirset dir="${artifact.dir}" includes="**/**/*">	  
	    <date datetime="${borderline.timestamp}" when="before"  checkdirs="true"/>
	  </dirset>
	</delete>
	
	<!-- print out timer and reset it -->
    <stopwatch name="timer.delete.old.stuff" action="total"/>

    <echo message="DONE : delete.old.stuff" />
  </target>

Unfortunately this construction does not delete anything :-(

The console says this:
delete.old.stuff:
     [echo] borderline.timestamp=06/06/2009 17:32 PM
     [echo] delete NBS-run** in F:/NightlyBuildSystem before 06/06/2009 17:32 PM
     [echo] artifact.dir=F:\NightlyBuildSystem/CruiseControl/artifacts/Mailminder NBS
     [echo] delete **/**/* in F:\NightlyBuildSystem/CruiseControl/artifacts/Mailminder NBS
before 06/06/2009 17:32 PM
[stopwatch] [timer.delete.old.stuff: 0.844 sec]
     [echo] DONE : delete.old.stuff

Is there something I'm doing completely wrong?
Is there any possibility to delete such old stuff without using javascript anyway?

Thanks for your time and your help

Regards

///Sascha Ernst///





---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Mime
View raw message