ant build

James
2013-01-28
2013-05-23
  • James

    James - 2013-01-28

    Hello:

    I am stuck on the building of the hello.jar. I managed to expand the SDK.
    I believe the build.xml did it ok.

     Volume in drive C has no label.
     Volume Serial Number is 9869-0873
     Directory of C:\Users\Steves\BundlingTools\one-jar-sdk-0.97
    01/27/2013  07:22 AM    <DIR>          .
    01/27/2013  07:22 AM    <DIR>          ..
    01/26/2013  05:09 AM               316 .classpath
    01/26/2013  05:09 AM               387 .project
    01/26/2013  05:09 AM                23 .version
    01/26/2013  05:09 AM             4,649 build.xml
    01/26/2013  05:09 AM    <DIR>          com
    01/26/2013  05:09 AM    <DIR>          doc
    01/27/2013  07:22 AM                94 hello.mf
    01/26/2013  05:09 AM    <DIR>          main
    01/26/2013  05:09 AM    <DIR>          META-INF
    01/26/2013  05:09 AM            89,769 one-jar-ant-task-0.97.jar
    01/26/2013  05:09 AM               483 one-jar-ant-task.xml
    01/26/2013  05:09 AM             1,046 OneJar.class
    01/26/2013  05:09 AM             1,479 README.txt
    01/26/2013  05:09 AM    <DIR>          src
                   9 File(s)         98,246 bytes
                   7 Dir(s)  739,801,075,712 bytes free
    C:\Users\Steves\BundlingTools\one-jar-sdk-0.97>README.txt
    C:\Users\Steves\BundlingTools\one-jar-sdk-0.97>build.xml
    C:\Users\Steves\BundlingTools\one-jar-sdk-0.97>
    

    The README.txt :

    After reading build.xml, verify that everything worked as follows:
      $ ant hello
      $ java -jar hello.jar
      
    Then rebuild the SDK and re-expand it:
      $ ant sdk
      $ java -jar sdk.jar
      
    A new copy of the SDK should be present under one-jar-sdk-<version>.
    

    Is there any one that could elaborate one how to do this. True there is no
    code to write. These instructions seem to imply that I understand how to build
    the jar already.

    $ ant hello   
    this does not make sense to me. I see the build file.xml and a manifest hello.mf

    So what does  $ ant hello    imply?

    of course ant hello does not work but I tried to use ant and send it something
    to build.

    C:\Users\Steves\BundlingTools\one-jar-sdk-0.97>cd %ANT_HOME%
    C:\Users\Steves\BundlingTools\ant\bin>ant %BUNDLING_TOOLS%\%SDK97%\hello
    Buildfile: build.xml does not exist!
    Build failed
    C:\Users\Steves\BundlingTools\ant\bin>ant %BUNDLING_TOOLS%\%SDK97%\hello.mf
    Buildfile: build.xml does not exist!
    Build failed
    C:\Users\Steves\BundlingTools\ant\bin>
    C:\Users\Steves\BundlingTools\ant\bin>ant %BUNDLING_TOOLS%\%SDK97%\build
    Buildfile: build.xml does not exist!
    Build failed
    C:\Users\Steves\BundlingTools\ant\bin>ant %BUNDLING_TOOLS%\%SDK97%\build.xm
    l
    Buildfile: build.xml does not exist!
    Build failed
    C:\Users\Steves\BundlingTools\ant\bin>
    

    thanks

    C:\Program Files\Java\jdk1.7.0_01\bin
    :\Users\Steves\BundlingTools\one-jar-sdk-0.97
    C:\Users\Steves\BundlingTools\ant\bin
    
     
  • P. Simon Tuffs

    P. Simon Tuffs - 2013-02-06

    I think you need to put ant on the %PATH% of your machine using the set PATH=c:\wherever-ant-is\bin;%PATH% command, and then make sure you invoke ant in the directory containing build.xml.   This is the usual way to use ant, and hopefully will make your example work.  So ant hello tells ant to build the "hello" target in the build.xml file in the working directory you are in.

    Regards,

    Simon.

     
  • James

    James - 2013-02-19

    I think you need to put ant on the %PATH% of your machine using the set PATH=c:\wherever-ant-is\bin;%PATH% command, and then make sure you invoke ant in the directory containing build.xml.   This is the usual way to use ant, and hopefully will make your example work.  So ant hello tells ant to build the "hello" target in the build.xml file in the working directory you are in.

    I could not get the ant build to find the build in the dir.
    do you think ant user var and sys var are right?
    Thanks.

    ANT_HOME=C:\Users\Steves\BundlingTools\ant\bin

    %SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0;C:\Program Files\ATI Technologies\ATI.ACE\Core-Static;C:\Program Files\MySQL\MySQL Server 5.1\bin;%JAVA_HOME%\bin;%ANT_HOME%;%MAIL_HOME%\mail.jar;%MAIL_HOME%\lib\mailapi.jar;%MAIL_HOME%\lib\pop3.jar;%MAIL_HOME%\lib\smtp.jar;%MAIL_HOME%\lib\imap.jar;%MAIL_HOME%\lib\dsn.jar

    Directory of C:\Users\Steves\BundlingTools\one-jar-sdk-0.97

    01/27/2013  07:22 AM    <DIR>          .
    01/27/2013  07:22 AM    <DIR>          ..
    01/26/2013  05:09 AM               316 .classpath
    01/26/2013  05:09 AM               387 .project
    01/26/2013  05:09 AM                23 .version
    01/26/2013  05:09 AM             4,649 build.xml
    01/26/2013  05:09 AM    <DIR>          com
    01/26/2013  05:09 AM    <DIR>          doc
    01/27/2013  07:22 AM                94 hello.mf
    01/26/2013  05:09 AM    <DIR>          main
    01/26/2013  05:09 AM    <DIR>          META-INF
    01/26/2013  05:09 AM            89,769 one-jar-ant-task-0.97.jar
    01/26/2013  05:09 AM               483 one-jar-ant-task.xml
    01/26/2013  05:09 AM             1,046 OneJar.class
    01/26/2013  05:09 AM             1,479 README.txt
    01/26/2013  05:09 AM    <DIR>          src
                   9 File(s)         98,246 bytes
                   7 Dir(s)  732,632,281,088 bytes free

    C:\Users\Steves\BundlingTools\one-jar-sdk-0.97>ant build
    'ant' is not recognized as an internal or external command,
    operable program or batch file.

     
  • James

    James - 2013-02-25

    I am reading the README.txt provided in the one-jar-sdk-0.97. the sdk was ran and expanded.
    I am tring to run the first command.

    ant hello
    

    my paths are all wrong or something but all my trial and errors end up the same. the build file does not exist.
    is this true. I thought the build file was provided in the SDK.

    C:\Users\Steves>cd %ANT_HOME%
    C:\Users\Steves\BundlingTools\ant\bin>dir
     Volume in drive C has no label.
     Volume Serial Number is 9869-0873
     Directory of C:\Users\Steves\BundlingTools\ant\bin
    01/27/2013  07:26 AM    <DIR>          .
    01/27/2013  07:26 AM    <DIR>          ..
    04/30/2010  06:02 PM             9,997 ant
    04/30/2010  06:02 PM             7,706 ant.bat
    04/30/2010  06:02 PM             2,857 ant.cmd
    04/30/2010  06:02 PM             3,410 antenv.cmd
    04/30/2010  06:02 PM               861 antRun
    04/30/2010  06:02 PM             1,536 antRun.bat
    04/30/2010  06:02 PM             2,199 antRun.pl
    04/30/2010  06:02 PM             3,219 complete-ant-cmd.pl
    04/30/2010  06:02 PM             4,315 envset.cmd
    04/30/2010  06:02 PM             1,116 lcp.bat
    04/30/2010  06:02 PM             4,422 runant.pl
    04/30/2010  06:02 PM             3,396 runant.py
    04/30/2010  06:02 PM             1,817 runrc.cmd
                  13 File(s)         46,851 bytes
                   2 Dir(s)  731,459,153,920 bytes free
    C:\Users\Steves\BundlingTools\ant\bin>ant %BUNDLING_TOOLS%\%SDK97%\hello
    Buildfile: build.xml does not exist!
    Build failed
    C:\Users\Steves\BundlingTools\ant\bin>
    
    C:\Users\Steves\BundlingTools>dir
     Volume in drive C has no label.
     Volume Serial Number is 9869-0873
     Directory of C:\Users\Steves\BundlingTools
    02/25/2013  03:38 AM    <DIR>          .
    02/25/2013  03:38 AM    <DIR>          ..
    01/27/2013  07:26 AM    <DIR>          ant
    02/25/2013  04:01 AM    <DIR>          one-jar-sdk-0.97
    01/26/2013  06:15 AM    <DIR>          onejar
                   0 File(s)              0 bytes
                   5 Dir(s)  731,459,289,088 bytes free
    C:\Users\Steves\BundlingTools>cd %SDK97%
    C:\Users\Steves\BundlingTools\one-jar-sdk-0.97>dir
     Volume in drive C has no label.
     Volume Serial Number is 9869-0873
     Directory of C:\Users\Steves\BundlingTools\one-jar-sdk-0.97
    02/25/2013  04:01 AM    <DIR>          .
    02/25/2013  04:01 AM    <DIR>          ..
    02/25/2013  04:01 AM               316 .classpath
    02/25/2013  04:01 AM               387 .project
    02/25/2013  04:01 AM                23 .version
    02/25/2013  04:01 AM             4,649 build.xml
    02/25/2013  04:01 AM    <DIR>          com
    02/25/2013  04:01 AM    <DIR>          doc
    02/25/2013  04:01 AM                92 hello.mf
    02/25/2013  04:01 AM    <DIR>          main
    02/25/2013  04:01 AM    <DIR>          META-INF
    02/25/2013  04:01 AM            89,769 one-jar-ant-task-0.97.jar
    02/25/2013  04:01 AM               483 one-jar-ant-task.xml
    01/05/2011  07:33 PM           133,290 one-jar-sdk-0.97.jar
    02/25/2013  04:01 AM             1,046 OneJar.class
    02/25/2013  04:01 AM             1,479 README.txt
    02/25/2013  04:01 AM    <DIR>          src
                  10 File(s)        231,534 bytes
                   7 Dir(s)  731,459,289,088 bytes free
    C:\Users\Steves\BundlingTools\one-jar-sdk-0.97>ant hello
    'ant' is not recognized as an internal or external command,
    operable program or batch file.
    C:\Users\Steves\BundlingTools\one-jar-sdk-0.97>
    
    C:\Users\Steves>SET
    ALLUSERSPROFILE=C:\ProgramData
    ANT_HOME=C:\Users\Steves\BundlingTools\ant\bin
    APPDATA=C:\Users\Steves\AppData\Roaming
    BUNDLING_MANIFEST=C:\Users\Steves\BundlingTools\one-jar-sdk-0.97\META-INF
    BUNDLING_TOOLS=C:\Users\Steves\BundlingTools
    CommonProgramFiles=C:\Program Files\Common Files
    COMPUTERNAME=STEVES-PC
    ComSpec=C:\Windows\system32\cmd.exe
    FP_NO_HOST_CHECK=NO
    HOMEDRIVE=C:
    HOMEPATH=\Users\Steves
    JAVA_HOME=C:\Program Files\Java\jdk1.7.0_01
    LOCALAPPDATA=C:\Users\Steves\AppData\Local
    LOGONSERVER=\\STEVES-PC
    MAIL_HOME=C:\javamail-1.4.3
    NUMBER_OF_PROCESSORS=2
    OS=Windows_NT
    Path=C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\Sys
    tem32\WindowsPowerShell\v1.0;C:\Program Files\ATI Technologies\ATI.ACE\Core
    -Static;C:\Program Files\MySQL\MySQL Server 5.1\bin;%JAVA_HOME%\bin;%ANT_HO
    ME%;%MAIL_HOME%\mail.jar;%MAIL_HOME%\lib\mailapi.jar;%MAIL_HOME%\lib\pop3.j
    ar;%MAIL_HOME%\lib\smtp.jar;%MAIL_HOME%\lib\imap.jar;%MAIL_HOME%\lib\dsn.ja
    r
    PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC
    PROCESSOR_ARCHITECTURE=x86
    PROCESSOR_IDENTIFIER=x86 Family 6 Model 15 Stepping 13, GenuineIntel
    PROCESSOR_LEVEL=6
    PROCESSOR_REVISION=0f0d
    ProgramData=C:\ProgramData
    ProgramFiles=C:\Program Files
    PROMPT=$P$G
    PSModulePath=C:\Windows\system32\WindowsPowerShell\v1.0\Modules\
    PUBLIC=C:\Users\Public
    SDK97=one-jar-sdk-0.97
    SESSIONNAME=Console
    SystemDrive=C:
    SystemRoot=C:\Windows
    TEMP=C:\Users\Steves\AppData\Local\Temp
    TMP=C:\Users\Steves\AppData\Local\Temp
    USERDOMAIN=Steves-PC
    USERNAME=Steves
    USERPROFILE=C:\Users\Steves
    windir=C:\Windows
    C:\Users\Steves>
    
     
  • James

    James - 2013-02-26

    new attempt at ant hello command:
    I was tring to run >ant hello as prescibed in the README.txt.
    I read that the ant command should run on a target from any where.
    I adjusted my PATH and %ANT_HOME%.

    WHEN I run ant hello ; where is it I do not see it in the SDK ? ;
    and if is run c:\&gt;ant <???>  should it not automatically see the build.xml in the dir I tell it
    to look in?

    thanks I have a bunch of command stuff below:

    ////////
    C:\Users\Steves>CD %ANT_HOME%

    C:\Users\Steves\BundlingTools\ant\bin>ANT -version
    Unable to locate tools.jar. Expected to find it in C:\Program Files\Java\jr
    e7\lib\tools.jar
    Apache Ant version 1.8.1 compiled on April 30 2010
    C:\Users\Steves\BundlingTools\ant\bin>ant %BUNDLING_TOOLS%\%SDK97%\hello
    Unable to locate tools.jar. Expected to find it in C:\Program Files\Java\jr
    e7\lib\tools.jar
    Buildfile: build.xml does not exist!
    Build failed
    C:\Users\Steves\BundlingTools\ant\bin>

    /////////

    C:\Users\Steves\BundlingTools>CD %SDK97%

    C:\Users\Steves\BundlingTools\one-jar-sdk-0.97>DIR
    Volume in drive C has no label.
    Volume Serial Number is 9869-0873

    Directory of C:\Users\Steves\BundlingTools\one-jar-sdk-0.97

    02/25/2013  04:01 AM    <DIR>          .
    02/25/2013  04:01 AM    <DIR>          ..
    02/25/2013  04:01 AM               316 .classpath
    02/25/2013  04:01 AM               387 .project
    02/25/2013  04:01 AM                23 .version
    02/25/2013  04:01 AM             4,649 build.xml
    02/25/2013  04:01 AM    <DIR>          com
    02/25/2013  04:01 AM    <DIR>          doc
    02/25/2013  04:01 AM                92 hello.mf
    02/25/2013  04:01 AM    <DIR>          main
    02/25/2013  04:01 AM    <DIR>          META-INF
    02/25/2013  04:01 AM            89,769 one-jar-ant-task-0.97.jar
    02/25/2013  04:01 AM               483 one-jar-ant-task.xml
    01/05/2011  07:33 PM           133,290 one-jar-sdk-0.97.jar
    02/25/2013  04:01 AM             1,046 OneJar.class
    02/25/2013  04:01 AM             1,479 README.txt
    02/25/2013  04:01 AM    <DIR>          src
                  10 File(s)        231,534 bytes
                   7 Dir(s)  734,942,175,232 bytes free

    C:\Users\Steves\BundlingTools\one-jar-sdk-0.97>ant hello
    'ant' is not recognized as an internal or external command,
    operable program or batch file.

    C:\Users\Steves\BundlingTools\one-jar-sdk-0.97>

    /////////////////////

    C:\Users\Steves>SET
    ALLUSERSPROFILE=C:\ProgramData
    ANT_HOME=C:\Users\Steves\BundlingTools\ant\bin
    APPDATA=C:\Users\Steves\AppData\Roaming
    BUNDLING_MANIFEST=C:\Users\Steves\BundlingTools\one-jar-sdk-0.97\META-INF
    BUNDLING_TOOLS=C:\Users\Steves\BundlingTools
    CommonProgramFiles=C:\Program Files\Common Files
    COMPUTERNAME=STEVES-PC
    ComSpec=C:\Windows\system32\cmd.exe
    FP_NO_HOST_CHECK=NO
    HOMEDRIVE=C:
    HOMEPATH=\Users\Steves
    JAVA_HOME=C:\Program Files\Java\jdk1.7.0_01\bin
    LOCALAPPDATA=C:\Users\Steves\AppData\Local
    LOGONSERVER=\\STEVES-PC
    MAIL_HOME=C:\javamail-1.4.3
    NUMBER_OF_PROCESSORS=2
    OS=Windows_NT
    PATH=C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\Sys
    tem32\WindowsPowerShell\v1.0;C:\Program Files\ATI Technologies\ATI.ACE\Core
    -Static;C:\Program Files\MySQL\MySQL Server 5.1\bin;%JAVA_HOME%;%ANT_HOME%\
    bin;%MAIL_HOME%\mail.jar;%MAIL_HOME%\lib\mailapi.jar;%MAIL_HOME%\lib\pop3.j
    ar;%MAIL_HOME%\lib\smtp.jar;%MAIL_HOME%\lib\imap.jar;%MAIL_HOME%\lib\dsn.ja
    r
    PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC
    PROCESSOR_ARCHITECTURE=x86
    PROCESSOR_IDENTIFIER=x86 Family 6 Model 15 Stepping 13, GenuineIntel
    PROCESSOR_LEVEL=6
    PROCESSOR_REVISION=0f0d
    ProgramData=C:\ProgramData
    ProgramFiles=C:\Program Files
    PROMPT=$P$G
    PSModulePath=C:\Windows\system32\WindowsPowerShell\v1.0\Modules\
    PUBLIC=C:\Users\Public
    SDK97=one-jar-sdk-0.97
    SESSIONNAME=Console
    SystemDrive=C:
    SystemRoot=C:\Windows
    TEMP=C:\Users\Steves\AppData\Local\Temp
    TMP=C:\Users\Steves\AppData\Local\Temp
    USERDOMAIN=Steves-PC
    USERNAME=Steves
    USERPROFILE=C:\Users\Steves
    windir=C:\Windows

    C:\Users\Steves>

    //////

    <project name="one-jar-sdk" default="sdk">

        <property name="one-jar.dist.dir" value="${basedir}"/>  
       
        <property name="src.main.dir" location="${basedir}/src/main"/>
        <property name="src.lib.dir" location="${basedir}/src/lib"/>
        <property name="src.install.dir" location="${basedir}/src/install"/>
    <property name="lib.dir" location="${basedir}/lib"/>
        <property name="build.dir" location="${basedir}/build"/>  
       
        <property name="classes.dir" location="${basedir}/classes"/>  

        <target name="init">
            <mkdir dir="${src.main.dir}"/>  
            <mkdir dir="${src.lib.dir}"/>
        <mkdir dir="${lib.dir}"/>
            <mkdir dir="${classes.dir}/main"/>  
            <mkdir dir="${classes.dir}/lib"/>  
            <mkdir dir="${classes.dir}/src"/>  
            <mkdir dir="${build.dir}"/>  
        </target>  
       
        <import file="one-jar-ant-task.xml"/>  

        <target name="hello" depends="init">
            <!- Build lib.jar ->  
            <javac destdir="${classes.dir}/lib">
                <src path="${src.lib.dir}" />
            </javac>
            <jar destfile="${build.dir}/lib.jar" >
                <fileset dir="${classes.dir}/lib"/>
            </jar>  
            <!- Build classes for main.jar ->  
            <javac destdir="${classes.dir}/main">
                <src path="${src.main.dir}" />
                <classpath path="${build.dir}/lib.jar"/>  
                <classpath>
            <fileset dir="${src.lib.dir}"/>
                </classpath>
            </javac>
            <!- Construct the One-JAR file ->  
            <one-jar destfile="hello.jar">
                <!- hello.mf:
               
                Main-Class: com.simontuffs.onejar.Boot
                One-Jar-Main-Class: com.simontuffs.onejar.hello.Main
                ->
                <manifest>
                    <attribute name="One-Jar-Main-Class" value="com.simontuffs.onejar.hello.Main"/>
                </manifest>
                <main>
                    <!- Construct main.jar from classes and source code ->
                    <fileset dir="${classes.dir}/main"/>
                </main>
                <lib>
                    <fileset file="${build.dir}/lib.jar" />

                <!- This will copy the files in the SDK/lib dir to the lib folder in the jar file->
        <fileset dir="${lib.dir}"/>

                </lib>
            </one-jar>
            <echo>
              Now you can run the Hello One-JAR example using
              $ java -jar hello.jar
            </echo>  
              
        </target>

        <target name="sdk">
            <!- Rebuild this SDK using the One-JAR task. ->  
        <echo>Building sdk ${one-jar.version}</echo>
            <mkdir dir="${classes.dir}/install"/>  
            <javac destdir="${classes.dir}/install">
                <src path="${src.install.dir}" />
            </javac>
            <delete file="one-jar-sdk-${one-jar.version}.jar"/>
            <one-jar destfile="one-jar-sdk-${one-jar.version}.jar">
                <!- one-jar-sdk.mf:
               
                Main-Class: com.simontuffs.onejar.Boot
                One-Jar-Main-Class: com.simontuffs.onejar.sdk.Install
                One-Jar-Expand:
                One-Jar-Expand-Dir: ./one-jar-sdk-${one-jar.version}
                One-Jar-Show-Expand: true          
                ->
                <manifest>
                    <attribute name="One-Jar-Main-Class" value="com.simontuffs.onejar.sdk.Install"/>
                    <!- Note: One-Jar-Expand is a list of paths to expand: empty is all ->
                <attribute name="One-Jar-Expand" value=""/>
                    <attribute name="One-Jar-Expand-Dir" value="./one-jar-sdk-${one-jar.version}"/>
                <attribute name="One-Jar-Confirm-Expand" value="true"/>
                    <attribute name="One-Jar-Show-Expand" value="true"/>
                </manifest>
                <fileset dir=".">
                    <include name="one-jar-ant-${one-jar.version}.jar"/>  
                    <include name="src/main/**"/>  
                    <include name="src/lib/**"/>  
                    <include name="src/install/**"/>  
                    <include name="build.xml"/>  
                    <include name="README.txt"/>  
                    <include name="one-jar-ant-task*"/>  
                    <include name="*.mf"/>  
                    <include name=".*"/>  
                <exclude name=".version"/>
                </fileset>
                <main>
                    <fileset dir="${classes.dir}/install"/>
                </main>
            </one-jar>
        </target>  

        <target name="clean">
            <delete dir="${classes.dir}"/>
            <delete dir="${build.dir}"/>
        </target>  
       
    </project>

     

Log in to post a comment.