1 App Inventor的编译
编译AppInventor需要使用ant,在项目的GitHub上https://github.com/mit-cml/appinventor-sources有如下说明:
Youwill need a full Java JDK (6 or 7, preferably from Oracle; JRE is not enough)and Python to compile and run the servers.
需要在电脑上安装JDK6或7,才能正常编译。
但ant的不同版本需要的JDK不同,像1.10.1版本就需要JDK8,否则编译的时候,会报如下错误:
Exception in thread "main"java.lang.UnsupportedClassVersionError: org/apache/tools/ant/launch/Launcher :Unsupported major.minor version 52.0
编译的时候,直接输入ant命令,会编译所有源码,花费时间较长,在本人电脑上是6分钟多。实际往往不需要编译全部代码,只编译改动的模块就可以了。
在源码的appinventor文件夹下有个build.xml文件,在其中有许多target标签:
<target name="all">
<ant inheritAll="false" useNativeBasedir="true"dir="appengine"/>
<ant inheritAll="false" useNativeBasedir="true"dir="blocklyeditor"/>
<ant inheritAll="false" useNativeBasedir="true"dir="common"/>
<ant inheritAll="false" useNativeBasedir="true"dir="buildserver"/>
<ant inheritAll="false" useNativeBasedir="true"dir="components"/>
<ant inheritAll="false" useNativeBasedir="true"dir="buildserver" target="PlayApp"/>
</target>
…
<target name="MakeAuthKey">
…
<target name="comps">
…
<target name="extensions">
…
<target name="clean">
<ant inheritAll="false" useNativeBasedir="true"dir="appengine" target="clean"/>
<ant inheritAll="false"useNativeBasedir="true" dir="blocklyeditor"target="clean"/>
<ant inheritAll="false" useNativeBasedir="true"dir="aimerger" target="clean"/>
<ant inheritAll="false" useNativeBasedir="true"dir="buildserver" target="clean"/>
<ant inheritAll="false" useNativeBasedir="true"dir="common" target="clean"/>
<ant inheritAll="false" useNativeBasedir="true"dir="components" target="clean"/>
<delete dir="build"/>
<delete dir="reports"/>
</target>
每个target标签中间说明了使用ant + target name时,编译的模块,如输入如下命令:
ant all——编译所有模块,等同于只输入ant
antextensions——编译插件
antMakeAuthKey——编译AuthKey
还有个特殊的编译命令:
antclean——删除之前编译生成的build和reports文件夹。