<project basedir="." default="nbm" name="PMD netbeans module">

    <import file="nbproject/build-impl.xml"/>

    <property name="pmd.jar" value="pmd-4.2.5.jar"/>
    <property name="nb.version" value="netbeans65"/>
    <property name="VERSION" value="2.2.7"/>

    <property file="build.ant.properties"/>

    <property name="keystore" value="${user.home}/.pmdkeystore"/>
        
    <target name="nblib" depends="init">
        <mkdir dir="build/libclasses"/>
        <javac srcdir="libsrc" destdir="build/libclasses" source="${javac.source}" debug="${build.compiler.debug}" deprecation="${build.compiler.deprecation}">
            <classpath>
                <pathelement location="lib/${pmd.jar}"/>
            </classpath>
        </javac>
        <copy todir="build/libclasses">
            <fileset dir="libsrc" includes="**/*.xml"/>
        </copy>
        <mkdir dir="${cluster}/modules/ext"/>
        <jar jarfile="${cluster}/modules/ext/nbpmdrules.jar" compress="false">
            <fileset dir="build/libclasses"/>
        </jar>
    </target>

    <target name="netbeans-extra" depends="init,nblib">
        <mkdir dir="${cluster}/modules/ext"/>
        <copy todir="${cluster}/modules/ext">
          <fileset dir="lib">
            <include name="${pmd.jar}"/>
            <include name="asm-3.1.jar"/>
            <include name="jaxen-1.1.1.jar"/>
          </fileset>
        </copy>
    </target>

	<target depends="clean, nbm" description="Builds the distribution" name="distribution">
		<fail unless="VERSION" message="Must define VERSION property with the version number for this distribution!"/>
		<zip compress="true" destfile="build/pmd-${nb.version}-${VERSION}-src.zip">
			<zipfileset dir="." prefix="pmd-${nb.version}-${VERSION}">
				<include name="*.txt"/>
				<include name="manifest.mf"/>
				<include name="build.xml"/>
				<include name="nbproject/*.*"/>
				<include name="javahelp/**/*"/>
				<include name="src/**/*"/>
				<include name="libsrc/**/*"/>
				<include name="lib/${pmd.jar}"/>
				<include name="lib/jaxen-1.1.1.jar"/>
                                <include name="lib/asm-3.1.jar"/>
			</zipfileset>
			<zipfileset dir="." fullpath="pmd-${nb.version}-${VERSION}/pmd.nbm" includes="build/pmd.nbm"/>
		</zip>
		<zip compress="true" destfile="build/pmd-${nb.version}-${VERSION}-bin.zip">
			<zipfileset dir="." prefix="pmd-${nb.version}-${VERSION}">
				<include name="*.txt"/>
			</zipfileset>
			<zipfileset dir="." fullpath="pmd-${nb.version}-${VERSION}/pmd.nbm" includes="build/pmd.nbm"/>
		</zip>
	</target>
	
</project>