dion        2003/07/16 18:48:56

  Added:       src/plugins-build/ant/src/plugin-resources/templates
                        build.jelly
  Log:
  Add template.
  
  Revision  Changes    Path
  1.1                  
maven/src/plugins-build/ant/src/plugin-resources/templates/build.jelly
  
  Index: build.jelly
  ===================================================================
  <j:jelly
    xmlns:ant="jelly:ant"
    xmlns:j="jelly:core" 
    xmlns:u="jelly:util"
    xmlns:x="jelly:xml"
    xmlns="dummy">
  
    <ant:tstamp />
    <!-- get first repo in the list -->
    <u:tokenize var="repos" delim=",">${maven.repo.remote}</u:tokenize>
    <j:set var="repo">${repos[0]}</j:set>
  
    <x:comment>
    build.xml generated by maven from project.xml version ${pom.currentVersion}
    on date ${TODAY}, time ${TSTAMP}
    </x:comment>
  
  <project name="${pom.artifactId}" default="jar" basedir=".">
    
    <property name="defaulttargetdir" value="target"/> 
    <property name="libdir" value="target/lib" />
    <property name="classesdir" value="target/classes"/>
    <property name="testclassesdir" value="target/test-classes"/>
    <property name="testreportdir" value="target/test-reports"/>
  
    <property name="distdir" value="dist"/>
    <property name="javadocdir" value="dist/docs/api"/>
    <property name="final.name" value="${maven.final.name}"/>
    
    <target 
      name="init"
      description="o Initializes some properties">
      <mkdir dir="$${libdir}"/>
      <condition property="noget">
        <equals arg1="$${build.sysclasspath}" arg2="only"/>
      </condition>
    </target>
  
    <target
      name="compile"
      depends="get-deps"
      description="o Compile the code">
      
      <mkdir dir="$${classesdir}"/>
  
      <javac
        destdir="$${classesdir}"
        excludes="**/package.html"
        debug="true"
        deprecation="true"
        optimize="false">
        <src>
          <pathelement location="${pom.build.sourceDirectory}"/>
        </src>
        <classpath>
          <fileset dir="$${libdir}">
            <include name="*.jar"/>
          </fileset>
        </classpath>
      </javac>
      
      <!-- 
       | Copy any resources that must be present in the deployed
       | JAR file.
      -->
      <j:forEach var="resource" items="${pom.build.resources}">
   
      <copy todir="$${classesdir}">
        
        <j:set var="dir" value="${resource.directory}"/>
        <j:if test="${empty dir}">
          <j:set var="dir" value="."/>
        </j:if>
        
        <fileset dir="${dir}">
        
        <j:forEach var="res" items="${resource.includes}">
          <include name="${res}"/>
        </j:forEach>
        <j:forEach var="res" items="${resource.excludes}">
          <exclude name="${res}"/>
        </j:forEach>
        </fileset>
      </copy>
      
      </j:forEach>
  
      <!-- Copy any resources required for unit testing -->
      <j:forEach var="resource" items="${pom.build.unitTest.resources}">
   
      <copy todir="$${testclassesdir}">
        
        <j:set var="dir" value="${resource.directory}"/>
        <j:if test="${empty dir}">
          <j:set var="dir" value="."/>
        </j:if>
        
        <fileset dir="${dir}">
        
        <j:forEach var="pattern" items="${resource.includes}">
          <include name="${pattern}"/>
        </j:forEach>
        <j:forEach var="pattern" items="${resource.excludes}">
          <exclude name="${pattern}"/>
        </j:forEach>
        </fileset>
      </copy>
   
      </j:forEach>
  
    </target>
      
    <target
      name="jar"
      depends="compile,test"
      description="o Create the jar">
  
      <jar
        jarfile="target/$${final.name}.jar"
        basedir="$${classesdir}"
        excludes="**/package.html"
      />
  
    </target>
    
    <target
      name="clean"
      description="o Clean up the generated directories">
      <delete dir="$${defaulttargetdir}"/>
      <delete dir="$${distdir}"/>
    </target>
  
    <target
      name="dist"
      depends="jar, javadoc"
      description="o Create a distribution">
      <mkdir dir="dist"/>
      <copy todir="dist">
        <fileset dir="$${defaulttargetdir}" includes="*.jar"/>        
        <fileset dir="$${basedir}" includes="LICENSE*, README*"/>        
      </copy>
    </target>
   
    <target
      name="test"
      depends="internal-test"
      if="test.failure"
      description="o Run the test cases">
      <fail message="There were test failures."/>
    </target>
    <target
      name="internal-test"
      depends="compile-tests">
      <j:if test="${unitTestSourcesPresent}">
        <mkdir dir="$${testreportdir}"/>
        <junit printSummary="yes"
               haltonerror="true"
               failureproperty="test.failure"
               fork="true"
               dir="./">
  <!--
    I think the following is wrong
          <sysproperty key="basedir" value="${pom.build.unitTestSourceDirectory}"/>
          <sysproperty key="basedir" value="${basedir}"/> // this gives a full path
          including the C:\ on windows
  -->        
          <sysproperty key="basedir" value="."/>
          <formatter type="xml"/>
          <formatter type="plain" usefile="false"/>
          <classpath>
            <fileset dir="$${libdir}">
              <include name="*.jar"/>
            </fileset>
            <pathelement path="$${testclassesdir}"/>
            <pathelement path="$${classesdir}"/>
          </classpath>
          <batchtest todir="$${testreportdir}">
            <fileset dir="${pom.build.unitTestSourceDirectory}">
              <j:forEach var="pat" items="${pom.build.unitTest.includes}">
                <include name="${pat}"/>
              </j:forEach>
              <j:forEach var="pat" items="${pom.build.unitTest.excludes}">
                <exclude name="${pat}"/>
              </j:forEach>
              
              <!-- add extra excludes if the property is set -->
              <j:if test="${context.getVariable('maven.ant.excludeTests') != null}">
                <u:tokenize var="patterns" 
delim=",">${maven.ant.excludeTests}</u:tokenize>
                <j:forEach var="pattern" items="${patterns}">
                  <exclude name="${pattern}" />
                </j:forEach>
              </j:if>
            </fileset>
          </batchtest>
        </junit>
      </j:if>
    </target>
  
    <target 
      name="compile-tests"
      depends="compile">
      <j:if test="${unitTestSourcesPresent}">
        <mkdir dir="$${testclassesdir}"/>
        <javac
          destdir="$${testclassesdir}"
          excludes="**/package.html"
          debug="true"
          deprecation="true"
          optimize="false">
          <src>
            <pathelement location="${pom.build.unitTestSourceDirectory}"/>
          </src>
          <classpath>
            <fileset dir="$${libdir}">
              <include name="*.jar"/>
            </fileset>
            <pathelement path="$${classesdir}"/>
          </classpath>
        </javac>
  
        <j:choose trim="true">
          <j:when test="${!pom.build.unitTest.resources.includes.isEmpty()}">
             <j:set var="maven.has.test.resource.patterns" value="true"/>
           </j:when>
           <j:when test="${!pom.build.unitTest.resources.excludes.isEmpty()}">
             <j:set var="maven.has.test.resource.patterns" value="true"/>
           </j:when>
        </j:choose>
     
        <j:if test="${maven.has.test.resource.patterns}">
   
        <copy todir="$${testclassesdir}">
          <fileset dir="${pom.build.unitTestSourceDirectory}">
            <j:forEach var="res" items="${pom.build.unitTest.resources.includes}">
              <include name="${res}"/>
            </j:forEach>
            <j:forEach var="res" items="${pom.build.unitTest.resources.excludes}">
              <exclude name="${res}"/>
            </j:forEach>
          </fileset>
        </copy>
        </j:if>
      </j:if>
    </target>
  
    <target
      name="javadoc"
      depends="jar"
      description="o Generate javadoc">
   
   
      <mkdir dir="$${javadocdir}"/>
   
      <!-- Get the year to display in the Javadocs -->
      <tstamp>
        <format property="year" pattern="${pom.inceptionYear}-yyyy"/>
      </tstamp>
   
      <property
        name="copyright"      
        value="Copyright &amp;copy; ${year} ${pom.organization.name}. All Rights 
Reserved."
      />
   
      <property
        name="title"
        value="${pom.name} ${pom.currentVersion} API"
      />
   
      <javadoc
        sourcepath="${pom.build.sourceDirectory}"
        packagenames="${pom.package}.*"
        destdir="$${javadocdir}"
        author="true"
        private="true"
        version="true"
        use="true"
        windowtitle="${title}"
        doctitle="${title}"
        bottom="${copyright}">
        <classpath>
          <fileset dir="$${libdir}">
            <include name="*.jar"/>
          </fileset>
          <pathelement location="target/$${final.name}.jar"/>
        </classpath>
      </javadoc>
   
    </target>
  
    <target
      name="get-deps"
      depends="init"
      unless="noget">
    
      <j:forEach var="dep" items="${pom.dependencies}">
      <!-- note: this is a valid use of artifactDirectory -->
      <get 
        src="${repo}/${dep.artifactDirectory}/${dep.type}s/${dep.artifact}"
        dest="$${libdir}/${dep.artifact}"
        usetimestamp="true"
        ignoreerrors="true"
      /></j:forEach>
      <!-- force junit for tests -->
      <get 
        src="${repo}/junit/jars/junit-3.8.1.jar"
        dest="$${libdir}/junit-3.8.1.jar"
        usetimestamp="true"
        ignoreerrors="true"/>
      <get 
        src="${repo}/ant/jars/ant-1.5.jar"
        dest="$${libdir}/ant-1.5.jar"
        usetimestamp="true"
        ignoreerrors="true"/>
      <get 
        src="${repo}/ant/jars/ant-optional-1.5.jar"
        dest="$${libdir}/ant-optional-1.5.jar"
        usetimestamp="true"
        ignoreerrors="true"/>
    </target>
  
    <!-- ================================================================== -->
    <!-- A N T  A U T O  I N S T A L L E R                                  -->
    <!-- ================================================================== -->
    <!-- For users that have Ant installed Maven can be automatically       -->
    <!-- installed by answering a few simple questions. We only need to     -->
    <!-- know what the user wants for ${maven.home} and ${maven.repo.local} -->
    <!-- and we're set.                                                     -->
    <!-- ================================================================== -->
  
    <target
      name="install-maven">
  
      <!--
      
      Ask the user what they would like to use for
      
      ${maven.home}
      ${maven.repo.local}
      
      -->
  
      <get 
        src="$${repo}/maven/maven-install-latest.jar"
        dest="$${user.home}/maven-install-latest.jar"
        usetimestamp="true"
      />
      
      <unjar
        src="$${user.home}/maven-install-latest.jar"
        dest="$${maven.home}"
      />
      
    </target>
  
  </project>
  </j:jelly>
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to