<project default="plugin">

  <goal name="plugin">
    <!-- set up the directory the jar will be assembled to -->
    <property name="assemblyDir" value="target/assemblyDir"/>
    
    <mkdir dir="${assemblyDir}"/>
    
    <!-- copy the plugin files to the assembly directory -->
    <copy todir="${assemblyDir}">
      <fileset dir=".">
        <exclude name="**/target/**"/>
        <exclude name="src/**"/>
        <exclude name="maven.xml"/>
        <exclude name="maven.log"/>
        <exclude name="**/velocity.log"/>
        <exclude name="**/.cvsignore"/>
      </fileset>
    </copy>
    
    <!-- jar the files up -->
    <jar jarfile="${maven.build.dir}/${maven.final.name}.jar">
      <fileset dir="${assemblyDir}"/>
    </jar>
    
    <!-- copy the jar to the local repository as a maven jar -->
    <copy
      file="${maven.build.dir}/${maven.final.name}.jar"
      todir="${maven.repo.local}/maven/jars"/>
  </goal>

  <!-- install the plugin in the maven home directory -->    
  <goal name="plugin:install" prereqs="plugin"
    description="Install the plugin in Maven's plugins dir">

    <copy file="${maven.build.dir}/${maven.final.name}.jar"
      todir="${maven.home}/plugins"/>

  </goal>

  <!-- unzip the jar file into a plugin directory -->
  <goal name="plugin:deploy" prereqs="plugin"
        description="Install an unpacked version of the plugin">

    <mkdir dir="${maven.home}/plugins/${maven.final.name}"/>
    <unzip src="${maven.build.dir}/${maven.final.name}.jar" 
      dest="${maven.home}/plugins/${maven.final.name}"/>

  </goal>

</project>
    