5

i have a problem. I'm use antrun plugin for maven and do next: i have folder and subfolders(I do not know what are called sub-folders and their number) and i'm do archive for this subfolders with their name(subfolder name - "1", archive name - "1.acp").

               <tasks>
                  <taskdef resource="net/sf/antcontrib/antlib.xml" classpath="${settings.localRepository}/ant-contrib/ant-contrib/1.0b3/ant-contrib-1.0b3.jar" />
                  <taskdef resource="net/sf/antcontrib/antcontrib.properties" classpath="${settings.localRepository}/ant-contrib/ant-contrib/1.0b3/ant-contrib-1.0b3.jar" />
                  <for param="file">
                      <path>
                          <dirset dir="src/main/bootstrap" includes="/*" />
                      </path>
                      <sequential>
                          <basename property="dir" file="@{file}" />
                          <zip destfile="${project.build.outputDirectory}/alfresco/extension/agilent/${dir}.acp" basedir="@{file}" />
                      </sequential>
                  </for>
              </tasks>

But property dir is immutable!!! And all archive has name "1.acp". How to make this property mutable or do this another way?

2 Answers 2

6

You may use a 1.8 Ant's Local task

In your case:

<sequential>
  <local name="dir"/>
  <basename property="dir" file="@{file}"/>
  <zip
    destfile="${project.build.outputDirectory}/alfresco/extension/agilent/${dir}.acp" 
    basedir="${dir}"
  />
</sequential>
4

You can use the var task from ant contrib.

The property unset, lets you reset values(example from above link):

    <property name="x" value="6"/>
    <echo>${x}</echo>   <!-- will print 6 -->
    <var name="x" unset="true"/>
    <property name="x" value="12"/>
    <echo>${x}</echo>   <!-- will print 12 -->

So you will have to fix it to:

 <sequential>
   <var name="dir" unset="true"/>
   <basename property="dir" file="@{file}" />
   <zip destfile="${project.build.outputDirectory}/alfresco/extension/agilent/${dir}.acp" basedir="@{file}" />
 </sequential>
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.