JRE/JDE related ANT build Errors

Categories: Java; Tagged with: ; @ July 30th, 2012 18:35

I’m trying to build some java project in my new pc, got some error:

build.xml:46: Unable to find a javac compiler;
com.sun.tools.javac.Main is not on the classpath.
Perhaps JAVA_HOME does not point to the JDK.
It is currently set to “C:\Program Files (x86)\Java\jre7”

or :

cannot access java.util.ArrayList
    [javac] bad class file: C:\Program Files (x86)\Java\jre7\lib\rt.jar(java/util/ArrayList.class)
    [javac] class file has wrong version 51.0, should be 49.0
    [javac] Please remove or make sure it appears in the correct subdirectory of the classpath.
    [javac] import java.util.ArrayList;
    [javac]                  ^
    [javac] 1 error
    [javac] 100 warnings

I have config the Path environment variable, and the JRE installed in Eclipse preferences, I got those Errors also, and I forget there also need to config the ant run configuration:  run as… and switch to ‘JRE’ tab, select the right JDK.

Using Date and Time in Ant 在Ant中使用日期及时间

Categories: Development Notes; Tagged with: ; @ March 22nd, 2012 23:08

Example:

<tstamp>
            <format property="today" pattern="yyyy_MM_dd_HH_mm"/>
        </tstamp>
<echo message="${today}"></echo>

 

[echo] 2012_03_22_23_00

 

Tstamp in Ant manual:

http://ant.apache.org/manual/Tasks/tstamp.html

Using Ant Zip File 使用Ant打包zip文件

Categories: Flex; Tagged with: ; @ October 14th, 2010 20:05

    <!– =================================
          target:  buildATDZipFile – 指定参与打包的目录或具体文件 – 适用于打包指定的具体目录/文件.
         ================================= –>
    <target name="buildATDZipFile" description="Build Drive zip file.">
          <zip destfile="${DIR_ROOT}/Drive.zip">
            <zipfileset dir="${DIR_ROOT}/src" prefix="${ROOT_NAME}/src" excludes="**/.svn"/>
            <zipfileset dir="${DIR_ROOT}/libs" prefix="${ROOT_NAME}/libs" excludes="**/.svn"/>
            <zipfileset dir="${DIR_ROOT}" includes="OpenInBrowser.bat" fullpath="${ROOT_NAME}/OpenInBrowser.bat"/>
        </zip>
    </target>

Or:

    <!– =================================
          target: buildZipTest 指定排除列表, 直接打包 – 适用于排出部分打包全部.
         ================================= –>
    <target name="buildZipTest" description="description">
        <zip destfile="TestAnt.zip" basedir="${basedir}" excludes="
            *.zip,
            **/.svn/**,
            tomcat/logs/**,
              build/**"></zip>
    </target>

使用ANT Build SWC

Categories: Flex; Tagged with: ; @ October 11th, 2010 20:59

两年前刚开始学Flex的时候常去看Cookbook, 还翻译过一篇关于生成SWC文件的帖子—当时甚至连ANT都没有用过, 真TM是为赋新词强说愁, 闲的肱二头肌疼, 再上层楼, 用了ANT, 写过几个Build才知道, 除了使用了装B武器之外, 我仍旧一无是处.

使用Adobe提供的compc – component compiler来打包as文件, 使用ANT编写极为简单, 如下:

<!– =================================
target: Build SWC文件举例 – 极不实用.
================================= –>
<target name=”buildSWCTest” depends=”” description=”Build Athena Framework SWC file.”>
<compc output=”$E:/test.swc”
include-classes=”com.liguoliang.Class1 com.liguoliang.Class2″>
<source-path path-element= “E:/Projects/FLEX/TestApp/src” />
</compc>
</target>

compc要求使用include-classes指定参与打包的Class, 一个半个类倒也无所谓, 一个个写上就可以了, 但问题是成百上千个, 写的完也写乱套了. 于是出现如下ANT命令, 帮助生成指定目录下的所有AS Class的PackageName:

注意: 部分变量定义没贴出来. 领会意思就ok.

<fileset dir=”${src-dir}” id=”src.files“>
<include name=”**\**”/>
</fileset>

<echo message=”${src-dir}” />
<pathconvert
property=”build-classes
pathsep=” ”
dirsep=”.”
refid=”src.files
>
<map from=”\” to=”/”/>
<map from=”${src-dir}/” to=””/>
<mapper>
<chainedmapper>
<globmapper from=”*.as” to=”*”/>
<!–globmapper from=”*.mxml” to=”*”/–>
</chainedmapper>
</mapper>
</pathconvert>

<echo message=”Class is set to: ${build-classes}”/>

使用$build-classes作为compc的include-classes的Value再进行Build就可.

另: 可在compc中, 可使用external-library-path增加外部SWC:
<external-library-path file=”somdir/common.swc” append=”true”/>

See:
1. Using the compc task
2. Using compc, the component compiler
3. Working with compiler options – 同时适用于mxmlc与compc
4. Flex compc & ant 编译

使用ANT生成SWC Building SWC with ANT

Categories: Flex; Tagged with: ; @ November 3rd, 2008 14:44

by Tomasz Stocki on October 19, 2008 Avg  原载: Flex cookbook beta  翻译及整理:LiGL

问题摘要 Problem Summary

你试图使用ANT编译SWC文件.  You want to compile your swc using ant.

解决方法  Solution Summary

使用Adobe在Flex SDK中提供的Flex ANT任务来编译你的应用 Use flex ant tasks provided by adobe in flex SDK to compile your application.

解释 Explanation

在部署应用程序时, 我们可以使用ANT这个强大的工具—它可以帮助我们运行程序, 运行命令行, 复制文件,等等…
When deploying flex application we can use very powerful tool – ant. With his help we can launch applications, run command line tools, copy files and much, much more (see: http://ant.apache.org/manual/index.html)
在开始之前, 如果你使用的时FlexBuilder单独版本[非Eclipse插件版], 你需要先安装ANT
Before we start you should install ANT on your flex builder if you have stand alone version.
参考: See article “Installing Ant in Flex Builder 3” at :
http://blog.jodybrewster.net/2008/04/09/installing-ant-in-flex-builder-3/

安装完毕之后, 只需要建立以下两个文件: After that, just create two files in project:

build.properties: —–该文件用于存储Bulid.xml中用到的属性, 便于管理与查看
###### Flex Properties ##############################
# change this path to your flex sdk directory
# Use "/" in your directory path e.g. C:/FlexSDK/3.0.0
FLEX_HOME=C:/flex_sdk_4.0
###### Project Properties ###########################
src-dir=${basedir}/src

build.xml:

<project name="Ant build SWC sample" basedir="." default="build SWC">
<!-- load user configuration properties -->
<property file="build.properties" />
<taskdef resource="flexTasks.tasks" classpath="${FLEX_HOME}/ant/lib/flexTasks.jar" />
<!-- =================================
target: build SWC
================================= -->
<target name="build SWC">
<compc output="${basedir}/swc/sample.swc"
include-classes="tom.hallo.CHalloWorld">
<source-path path-element="${src-dir}" />
</compc>
</target>
</project>

第一个文件中存储了关于本机FlexSDK及工程的目录. First file build.properties, holds info about location FlexSDK and files structure in your project.
在Build.xml中的代码读取第一个文件并运行ANT的compc任务生成swc文件. Code in build.xml loads build.properties and run ant task compc to generate swc.
在FlexBuilder中, 只需要将Build.xml从导航栏中拖到Ant视图中, 然后双击’build SWC’任务. In Flex Builder, just drag and drop build.xml from Flex Navigator to Ant view and double “click build SWC” task.

Older Posts



// Proudly powered by Apache, PHP, MySQL, WordPress, Bootstrap, etc,.