kenorb
kenorb

Reputation: 166429

How to create an Ant's symlink with wildcard?

I've tried to create a symlink like:

<symlink link="${basedir}/docroot" resource="${basedir}/drupal-7.*" overwrite="true"/>

however, the line doesn't expand the wildcard but creates a link which points literally to drupal-7.*, not to drupal-7.56.

I've tried to use examples with fileset on this page, but it doesn't really cover my scenario.

How can I create an Ant's symlink which points to a dynamic folder (the one expanded by drupal-7.*)?

Upvotes: 0

Views: 281

Answers (2)

CAustin
CAustin

Reputation: 4614

You should use dirset instead of fileset to include directories, not files. Also, it would probably be a good idea to check for an unexpected number of directories as well.

Here is the example:

<dirset dir="${basedir}" includes="drupal-7.*" id="link.target" />

<fail message="Multiple or zero drupal-7.* directories found.">
    <condition>
        <not>
            <resourcecount refid="link.target" when="equal" count="1" />
        </not>
    </condition>
</fail>

<symlink link="${basedir}/docroot" resource="${toString:link.target}" />

Upvotes: 1

kenorb
kenorb

Reputation: 166429

Here is the solution by invoking shell command:

<exec executable="sh" failonerror="true" dir="${basedir}" outputproperty="drupaldir">
  <arg value="-c"/>
  <arg value="echo drupal-7*"/>
</exec>
<symlink link="${basedir}/docroot" resource="${basedir}/${drupaldir}" overwrite="true"/>

Upvotes: 0

Related Questions