3

I have an SVN externals folder which contains many folders called *Plugin then within each of these folders there is a modules folder and a binaries folder.

The problem for me is, within my build task I want to copy **/* from modules to a location within my project, as well as any *.plugin.dll from the binaries location to somewhere else in my project.

So here is a dummy example:

- DummyPlugin1
  |- binaries
     |- some.assembly.dll
     |- some.plugin.dll
  |- modules
     |- some-named-folder
        |- some-sub-folder
           |- some.content.xml
        |- some-other-sub-folder
           |- yet-another-folder
              |- some.more.content.jpg
- DummyPlugin2
  |- binaries
     |- some.other.plugin.dll
  |- modules
     |- another-named-folder
        |- content.xml
        |- image.jpg
     |- yet-another-named-folder
        |- some-web-page.html

So in this example I would want to basically copy:

  • some.plugin.dll
  • some.other.plugin.dll

To a given output directory, then from the modules directory I would want to take:

  • some-named-folder (and all content)
  • another-named-folder (and all content)
  • yet-another-named-folder (and all content)

and put all of that in another given output directory.

I was trying to do this:

<copy todir="${dir.projects.dynamic.binaries}">
    <fileset basedir="${dir.plugins}/**/binaries">
        <include name="*.plugin.dll" />
    </fileset>
</copy>
<copy todir="${dir.projects.dynamic.modules}">
    <fileset basedir="${dir.plugins}/**/modules">
        <include name="**/*" />
    </fileset>
</copy>

However I keep getting an error telling me that basedir on fileset cannot contain ** or any other invalid symbols. The documentation seems a bit vague as to if you can or cannot use patterns in your fileset basedir or not, however I am assuming after this error that I cannot.

The problem is that if I was to do this way instead:

<copy todir="${dir.projects.dynamic.binaries}">
    <fileset basedir="${dir.plugins}">
        <include name="**/binaries/*.plugin.dll" />
    </fileset>
</copy>
<copy todir="${dir.projects.dynamic.modules}">
    <fileset basedir="${dir.plugins}">
        <include name="**/modules/**/*" />
    </fileset>
</copy>

However it copies the parent folders, i.e DummyPlugin1/binaries/some.assembly.dll, DummyPlugin2/binaries/some.other.plugin.dll rather than just the dll which I want. Same with the modules...

I know I could change the basedir to include DummyPlugin1/binaries, DummyPlugin2/binaries but I do not know how many folders will be in there or what their names will be without constantly altering the build script, so I would rather keep it dynamic so it will just pull out whatever plugins and modules are in there for me, rather than me having to make a copy for EACH plugin folder that may or may not be in there.

So is there any way for me to have my cake and eat it here?

Grofit
  • 17,693
  • 24
  • 96
  • 176

2 Answers2

3

basedir has to be a single directory, but you should be able to accomplish what you want using the flatten option, which puts all input files into a single output directory (ignoring the paths, basically).

After reading your question again: can you try this?

<copy todir="${dir.projects.dynamic.binaries}" flatten="true">
    <fileset>
        <include name="${dir.plugins}/**/binaries/*.plugin.dll" />
    </fileset>
</copy>
<copy todir="${dir.projects.dynamic.modules}">
    <fileset basedir="${dir.plugins}">
        <include name="/**/modules/**/*" />
    </fileset>
</copy>
skolima
  • 31,963
  • 27
  • 115
  • 151
  • Problem is I do need to keep the folder structure from within the modules directories intact. As there I am copying a root folder and all contents not just a set of files. – Grofit Jan 29 '12 at 13:56
  • Perhaps generating separate filesets with NAnt 'foreach' will be a better fit? First get a fileset for the directories, then iterate over it. – skolima Jan 29 '12 at 21:27
  • Do you have an example or link to show how that would work, the Nant documentation is a little sparse these days. I was going to use Rake but didnt want to have a dependency on ruby and rake being installed. – Grofit Jan 30 '12 at 09:29
1

The answer was already included in your question: use a <foreach> loop:

<foreach item="Folder" property="binaries.path">
  <in>
    <items basedir="${dir.plugins}">
      <include name="**/binaries" />
    </items>
  </in>
  <do>
    <copy todir="${dir.projects.dynamic.binaries}">
      <fileset basedir="${binaries.path}">
        <include name="*.plugin.dll" />
      </fileset>
    </copy>
  </do>
</foreach>
<foreach item="Folder" property="modules.path">
  <in>
    <items basedir="${dir.plugins}">
      <include name="**/modules" />
    </items>
  </in>
  <do>
    <copy todir="${dir.projects.dynamic.modules}">
      <fileset basedir="${modules.path}">
        <include name="**/*" />
      </fileset>
    </copy>
  </do>
</foreach>
The Chairman
  • 7,087
  • 2
  • 36
  • 44