Use exec executable to call system shell command : Shell Command « Ant « Java

Home
Java
1.2D Graphics GUI
2.3D
3.Advanced Graphics
4.Ant
5.Apache Common
6.Chart
7.Class
8.Collections Data Structure
9.Data Type
10.Database SQL JDBC
11.Design Pattern
12.Development Class
13.EJB3
14.Email
15.Event
16.File Input Output
17.Game
18.Generics
19.GWT
20.Hibernate
21.I18N
22.J2EE
23.J2ME
24.JavaFX
25.JDK 6
26.JDK 7
27.JNDI LDAP
28.JPA
29.JSP
30.JSTL
31.Language Basics
32.Network Protocol
33.PDF RTF
34.Reflection
35.Regular Expressions
36.Scripting
37.Security
38.Servlets
39.Spring
40.Swing Components
41.Swing JFC
42.SWT JFace Eclipse
43.Threads
44.Tiny Application
45.Velocity
46.Web Services SOA
47.XML
Java » Ant » Shell Command 




Use exec executable to call system shell command
 
//https://amateur.dev.java.net/
//GNU General Public License (GPL v. 2.0)

<?xml version="1.0" encoding="UTF-8"?>
<project name="Amateur" default="compile" basedir=".">
    
    <!-- ???? need a help target -->
    
    <property name="JUNIT_HOME" value="/Applications/eclipse/plugins/org.junit_3.8.1"/>
    <property name="QTJava" value="/System/Library/Java/Extensions/QTJava.zip"/>

    <taskdef name="jarbundler"
             classpath="lib/jarbundler-1.8.1.jar"
             classname="net.sourceforge.jarbundler.JarBundler" /> 
    
    <path id="project.classpath">
        <pathelement location="bin"/>
        <pathelement location="${QTJava}"/>
    </path>
    
    <path id="test.classpath">
        <path refid="project.classpath"/>
        <pathelement location="${JUNIT_HOME}/junit.jar"/>
    </path>
    
    <target name="init">
        <tstamp/>
        <property name="Name"    value="Amateur"/>
        <property name="name"    value="amateur"/>
        <property name="version" value="1.0d6"/>
        <property name="year"    value="2006"/>
        <mkdir dir="bin"/>
        <mkdir dir="dist"/>
    </target>
    
    <target name="clean">
        <delete dir="bin"/>
        <delete dir="dist"/>
    </target>
    
    <target name="compile" depends="init">
        <echo message="${ant.project.name}: ${ant.file}"/>
        <javac destdir="bin">
            <src path="src"/>
            <classpath refid="project.classpath"/>
        </javac>
    </target>
    
    <target name="test">
        <junit fork="yes" printsummary="withOutAndErr">
            <formatter type="plain"/>
            <test name="com.elharo.quicktime.tests.AmateurTests"/>
            <classpath refid="test.classpath"/>
        </junit>
    </target>
    
    <target name="run">
        <java fork="yes" classname="com.elharo.quicktime.Main" failonerror="true">
            <classpath refid="project.classpath"/>
        </java>
    </target>
    
    <target name="jar" depends="compile">
       <jar jarfile="dist/${name}-${version}.jar"
             basedir="bin"
             index="no"
             compress="yes"
             includes="com/elharo/quicktime/*"
             excludes="com/elharo/quicktime/tests/* com/elharo/quicktime/pantry/*">

          <manifest>
            <attribute name="Built-By" value="${user.name}"/>
            <attribute name="Specification-Title"    value="Amateur"/>
            <attribute name="Specification-Version"  value="${version}"/>
            <attribute name="Specification-Vendor"   value="Elliotte Rusty Harold"/>
            <attribute name="Implementation-Title"   value="Amateur"/>
            <attribute name="Implementation-Version" value="${version}"/>
            <attribute name="Implementation-Vendor"  value="Elliotte Rusty Harold"/>          
            <attribute name="Main-Class" value="com.elharo.quicktime.Main"/>
            <section name="com/elharo/quicktime/">
              <attribute name="Sealed" value="true"/>
              <attribute name="Specification-Title"   value="Amateur core classes"/>
              <attribute name="Implementation-Title"  value="com.elharo.quicktime"/>
            <attribute name="Implementation-Version" value="${version}"/>
            <attribute name="Implementation-Vendor"  value="Elliotte Rusty Harold"/>          
           </section>
          </manifest>
        </jar>        
    </target>
    
    <target name="app" depends="jar">
      <delete dir="dist/Amateur.app"/>
        <jarbundler dir="dist" jars="dist/${name}-${version}.jar" 
                    name="Amateur" 
                    mainclass="com.elharo.quicktime.Main" 
                    infostring=" ${version}"
                    version=" ${version}"
                    screenmenu="true"
                    signature="QTAM"
                    bundleid="com.elharo.quicktime"
                    icon="Amateur.icns"
        >
          <documenttype name="Amateur Media"
                    mimetypes="image/jpeg image/png image/gif video/mpeg video/quicktime audio/mpeg" 
                    role="Viewer"/>

          <documenttype name="Amateur Media"
                    extensions="jpg mov mpg mp3 gif png pdf" 
                    role="Viewer"/>

        </jarbundler>
    </target>
    
    <target name="image" depends="app">
      <exec executable="hdiutil" os="Mac OS X">
          <arg value="create"/>
          <arg value="-srcfolder"/>
          <arg value="dist/${Name}.app"/>
          <arg value="-ov"/>
          <arg value="dist/${Name}-${version}.dmg"/>
      </exec>
    </target>


    <taskdef classpath="lib/cobertura.jar" resource="tasks.properties" />
    
    <target name="instrument">
      <cobertura-instrument todir="bin/instrumented-classes">
        <fileset dir="bin/classes">
          <include name="**/*.class"/>
        </fileset>
      </cobertura-instrument>
    </target>
    
    <target name="cover-test" depends="instrument">
      <mkdir dir="${testreportdir}" />
      <junit dir="./" failureproperty="test.failure" printSummary="yes" 
             fork="true" haltonerror="true">
        <!-- Normally you can create this task by copying your existing JUnit
             target, changing its name, and adding these next two lines.
             You may need to change the locations to point to wherever 
             you've put the cobertura.jar file and the instrumented classes. -->
        <classpath location="lib/cobertura.jar"/>
        <classpath location="bin/instrumented-classes"/>
        <classpath>
          <fileset dir="${libdir}">
            <include name="*.jar" />
          </fileset>
          <pathelement path="${testclassesdir}" />
          <pathelement path="${classesdir}" />
        </classpath>
        <batchtest todir="${testreportdir}">
          <fileset dir="src">
            <include name="**/*Test.java" />
          </fileset>
        </batchtest>
      </junit>
    </target>

    
</project>

   
  














Related examples in the same category
1.Execute shell command
2.Apply executable
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.