<?xml version="1.0"?>

<project name="MMIR build resources" default="copy-resources">
    
    <target name="copy-resources">
        
        <!-- copy resources to parent directory
        	 * ANT scripts and settings
        	 * Cordova hooks for building MMIR apps
        -->
        <copy todir="../" preservelastmodified="true" overwrite="true">
            <fileset dir="resources"/>
        </copy>
        
        <!-- create settings-file from settingsDefault 
        	 (but only, if it is not exists yet)
        -->
        <copy
            file=  "resources/mmir-build.settingsDefault"
            tofile="../mmir-build.settings"
            overwrite="false"/>
    </target>
    
</project>
<?xml version="1.0"?>

<project name="MMIR build resources" default="copy-resources">
    
    <target name="copy-resources">
        
        <!-- copy resources to parent directory
        	 * ANT scripts and settings
        	 * Cordova hooks for building MMIR apps
        -->
        <copy todir="../" preservelastmodified="true" overwrite="true">
            <fileset dir="resources"/>
        </copy>
        
        <!-- create settings-file from settingsDefault 
        	 (but only, if it is not exists yet)
        -->
        <copy
            file=  "resources/mmir-build.settingsDefault"
            tofile="../mmir-build.settings"
            overwrite="false"/>
        
        
        
        <!-- FIX
        	 
        	 set file permissions for UNIX:
        	 
        	 set executable-flag for scripts (*.js, *.xml)
        	 
         -->
        
		<property location="${basedir}/../" name="targetdir"/>
		
		<!-- 
			only consider files that exist in ./resources/* AND to copy-target ./../*:
			map files names from ./resources/* to ./../*
			
			...but only for script files *.js (nodejs) and *.xml (ant) 
		 -->
		<pathconvert property="remappedlist" pathsep=",">
		    <fileset dir="resources" id="source-list" includes="**/*.js,**/*.xml"/>
			<mapper>
			  <globmapper from="${basedir}/resources/*" to="*" handledirsep="yes"/>
			</mapper>
		</pathconvert>
		
		<!-- remapped list of script files: -->
		<fileset id="target.script.files" dir="${targetdir}" includes="${remappedlist}">
		</fileset>
		
		<!-- set the executable flag for file-owner -->
		<chmod perm="u+x">
		    <fileset refid="target.script.files"/>
		</chmod>
		
    </target>
    
</project>
FIX set executable file-permission for scripts (on UNIX)
FIX set executable file-permission for scripts (on UNIX)