Setting svn mime-types using Apache Ant

Here is the source code of an Apache Ant build file (build.xml) to set SVN mime-types recursively on a javadoc folder (useful to publish Javadoc on google source code for example)

<?xml version="1.0" encoding="UTF-8"?>
<project name="project" default="default">

	<taskdef resource="net/sf/antcontrib/antlib.xml">
        <classpath>
            <pathelement location="/path/to/ant-contrib-library"/>
        </classpath>
    </taskdef>

	<property name="srcdir" location="/path/to/source-folder-javadoc-for-example" />
	
    <!-- ================================= 
          target: default              
         ================================= -->
    <target name="default" description="description">
    	<for param="file">
    		<path>
				<fileset dir="${srcdir}">
					<include name="**/*.html" />
				</fileset>
			</path>
    		<sequential>
    			<antcall target="mime">
    				<param name="file" value="@{file}" />
    				<param name="mime-type" value="text/html" />
    			</antcall>
			</sequential>
		</for>
		<for param="file">
    		<path>
				<fileset dir="${srcdir}">
					<include name="**/*.css" />
				</fileset>
			</path>
    		<sequential>
    			<antcall target="mime">
    				<param name="file" value="@{file}" />
    				<param name="mime-type" value="text/css" />
    			</antcall>
			</sequential>
		</for>
    	<for param="file">
    		<path>
				<fileset dir="${srcdir}">
					<include name="**/*.jpeg" />
				</fileset>
			</path>
    		<sequential>
    			<antcall target="mime">
    				<param name="file" value="@{file}" />
    				<param name="mime-type" value="image/jpeg" />
    			</antcall>
			</sequential>
		</for>
    </target>
	
	<target name="mime">
		<exec executable="d:/tools/slik-svn/bin/svn.exe">
			 <arg value="propset" />
			 <arg value="svn:mime-type" />
			 <arg value="${mime-type}" />
			 <arg value="${file}"/>
		</exec>
	</target>

</project>

References

Advertisements

2 thoughts on “Setting svn mime-types using Apache Ant”

  1. Hi there, i read your blog occasionally and i own a similar one and i was just curious if
    you get a lot of spam responses? If so how do you protect against it, any plugin or anything you can advise?
    I get so much lately it’s driving me mad so any support is very much
    appreciated.

    1. Hi Alina,

      Personally I don’t receive a lot of spam responses … I’d even say I’ve never such a Spam. However I think (I am almost sure you can), on receiving such a Spam, you can reject it for ever through a Word Press menu, by IP or by any other key words in the SPAM message. I have done it once a long time ago, but I don’t really remember how I did that time. Really sorry !

      BR

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s