[心缘地方]同学录
首页 | 功能说明 | 站长通知 | 最近更新 | 编码查看转换 | 代码下载 | 常见问题及讨论 | 《深入解析ASP核心技术》 | 王小鸭自动发工资条VBA版
登录系统:用户名: 密码: 如果要讨论问题,请先注册。

[备忘]RCP开发纯插件,如何用ANT自动打包的方法。

上一篇:[转载]使RCP程序自动加载所有新的插件
下一篇:[备忘]终于搞定Eclipse的SVN插件的安装。

添加日期:2011/3/15 10:59:35 快速返回   返回列表 阅读4346次
RCP开发应用程序,ANT打包办法参考这里:
http://www.mytju.com/classcode/news_readNews.asp?newsID=303

而纯插件的工程,导出时,其实就是一个Jar包。
对比了一下没有什么不同,所以,直接用Jar命令就行了。

我写的一段,供参考:


<project name="HelloWorld" default="build">
    <property file="build.properties" />

    <target name="init">
        <mkdir dir="${buildDirectory}" />
        <mkdir dir="${buildDirectory}/bin" />
        <copy todir="${buildDirectory}">
            <fileset dir=".">
                <include name="./**" />
            </fileset>
        </copy>
    </target>

    <target name="plugin-build">
        <javac srcdir="src/" destdir="${buildDirectory}/bin" encoding="UTF-8">
            <classpath>
                <fileset dir="lib">
                    <include name="**/*.jar"/>
                </fileset>
                <fileset dir="${base}\target\eclipse\plugins">
                    <include name="**/*.jar"/>
                </fileset>
            </classpath>
        </javac>

        <jar destfile="${buildDirectory}/xxxxxx.jar" manifest="META-INF/MANIFEST.MF">
            <fileset dir="${buildDirectory}/bin">
                <include name="**/*.class"/>
            </fileset>
            <fileset dir=".">
                <include name="icons/"/>
                <include name="lib/"/>
                <include name="template/"/>
                <include name="log4j.properties"/>
                <include name="plugin.xml"/>
            </fileset>
        </jar>
        <zip destfile="${mainFrameZipPath}" filesonly="false" whenempty="skip" update="true">
            <zipfileset file="${buildDirectory}/xxxxxx.jar" fullpath="mainframe/plugins/xxxxxx.jar"/>
        </zip>
    </target>

    <target name="clean">
        <delete dir="${buildDirectory}" />
    </target>

    <target name="build" depends="clean,init, plugin-build" />
    
</project>


其中,${buildDirectory}之类的变量是用bat传进来的,大概可以参考rcp应用程序那个。

(1)首先,是把java代码编译一下,用javac命令,然后添加了一堆jar包作为classpath。

(2)然后,打Jar包,用jar命令。把需要的目录、文件都include进来。

注意,META-INF/MANIFEST.MF这个文件要使用manifest="META-INF/MANIFEST.MF"来指定,

在下面include的话,会被忽略,然后生成一个空空的文件。

(3)把生成的Jar包直接扔进rcp application打成的zip包里。fullpath就是jar包在zip包里的路径。

三步搞定。

 

评论 COMMENTS
没有评论 No Comments.

添加评论 Add new comment.
昵称 Name:
评论内容 Comment:
验证码(不区分大小写)
Validation Code:
(not case sensitive)
看不清?点这里换一张!(Change it here!)
 
评论由管理员查看后才能显示。the comment will be showed after it is checked by admin.
CopyRight © 心缘地方 2005-2999. All Rights Reserved