Reputation: 5816
I got a directory structure like this:
plugins (directory)
- file1.php
- file1.xml
- file2.php
- file2.xml
- file3.php
- file3.xml
...
What i need is a directory structure like this:
plugins (directory)
- file1 (directory)
-- file1.php
-- file1.xml
- file2 (directory)
-- file2.php
-- file2.xml
- file3 (directory)
-- file3.php
-- file3.xml
...
I'm trying to achive that with Phing (has to be phing) like this:
<foreach param="file" absparam="absfilename" target="constructplugins">
<fileset dir="${dir.root}/plugins/">
<include name="*.php"/>
</fileset>
</foreach>
<target name="constructplugins" description="constructplugins">
<mkdir dir="${dir.tmp}/build/plugins/${file}" />
<copy file="${absfilename}" todir="${dir.tmp}/build/plugins/${file}" />
</target>
Like you already see i get a direcory name like "file1.php". I have no idea how to cut the ".php" to create the proper dir, as phing mappers wont work here. And i have also no idea how to copy the xml file. This has to be generic and the build runs under windows xp.
Any help is appreciated.
Upvotes: 0
Views: 1461
Reputation: 1464
I haven't tested this, but it should be possible with 'PhpEvalTask'.
<foreach param="file" absparam="absfilename" target="constructplugins">
<fileset dir="${dir.root}/plugins/">
<include name="*.php"/>
</fileset>
</foreach>
<target name="constructplugins" description="constructplugins">
<php expression="preg_replace('/\\.[^.\\s]{3,4}$/', '', ${file})" returnProperty="filename"/>
<mkdir dir="${dir.tmp}/build/plugins/${filename}" />
<copy file="${absfilename}" todir="${dir.tmp}/build/plugins/${filename}/${file}" />
</target>
I might get around to testing it later.
Upvotes: 2