[Eclipse plug-in Development Guide] 2.4 build a product

Source: Internet
Author: User

A commercial product is built to provide users with a form that can be installed in the user environment. You can build products in a variety of ways, including manually or using Windows batch script, Unix shell script, and Apache ant script. The final delivery is a separate compressed file or an independent executable file. For this purpose, favorites plug-in (a sample project in this book) uses the source code as a separately compressed zip file to interact with users.

2.4.1 manual Construction

Manual building involves running an eclipse Export (export) Wizard Page, entering some fields and clicking the finish button. Select File> export to run the desired export Wizard Page. On the First Wizard Page (Figure 2-14), select deployable plug-ins and fragments and click Next.

Figure 2-14 Export (export) Wizard Page 1 select an export type

 

On the second Wizard Page (Figure 2-15), select the plug-in to be exported, enter the ZIP file name, and select the displayed option. In addition, the ant script for the specified export operation isCom. qualityeclipse. favorites ProjectBuild-favorites.xml file, and then click Finish ).

Figure 2-15 Export (export) Wizard Page 2: specified ZIP file content

The created ZIP file contains a separate jar plug-in package (in eclipse3.1, a plug-in can be deployed as a separate JAR file)

Plugins/COM. qualityeclipse. favorites_1.0.0.jar

The plug-in jar files include the plug-in and source code, which are the same as those specified on the export Wizard Page:

Favorites. Jar <br/> favoritessrc.zip <br/> plugin. xml <br/> icons/sample.gif <br/> META-INF/manifest. MF

Unfortunately, this manual process is prone to errors. Manual building is required once or twice, but what if there are different people in the company who need to build products? What will happen when the product scale is expanding? A commercial product requires a reusable and stable way to build it.

2.4.2 build with Apache ant

An Apache ant script provides a reliable, flexible, and reusable process for building a commercial plug-in project. To create an ant script, we have to do more work before, however, compared with a product built manually, it will produce fewer errors over time, which will be described in Chapter 19th.

Eclipse can produce a simple ant script. TheBuild-favorites.xml:

<? XML version = "1.0" encoding = "UTF-8"?> <Br/> <project default = "plugin_export" name = "build"> <br/> <target name = "plugin_export"> <br/> <PVDF. exportplugins Destination = "/build/qualityeclipse" <br/> exportsource = "true" exporttype = "Zip" <br/> filename = "favoritesplugin.zip" <br/> plugins = "com. qualityeclipse. favorites "Source =" 1.3 "<br/> Target =" 1.2 "usejarformat =" true "/> <br/> </Target> <br/> </Project>

Previously, simple scripts work well, but unfortunately, we tried to use an asynchronous and non-peripheral front-end environment (in bugs.eclipse.org/bugs/show_bug.cgi? Id = 58413 check the entry 58413 registered by Bugzilla) it is very difficult to create a simple script.

 

If you want your own build script to do more, you need to follow the complicated ant script. For more ant and build scripts, see Chapter 19 Building a product.

<? XML version = "1.0" encoding = "UTF-8"?> <Br/> <project default = "plugin_export" name = "build"> <br/> <target name = "plugin_export"> </P> <p> <! -- Define build directories --> <br/> <property name = "build. root "<br/> location ="/build/qualityeclipse "/> <br/> <property name =" build. temp "<br/> location =" $ {build. root}/Temp "/> <br/> <property name =" build. out "<br/> location =" $ {build. root}/product "/> </P> <p> <! -- Create build directories --> <br/> <Delete dir = "$ {build. temp} "/> <br/> <mkdir dir =" $ {build. temp} "/> <br/> <mkdir dir =" $ {build. out} "/> </P> <p> <! -- Read the manifest. mf --> <br/> <copy file = "META-INF/manifest. MF "todir =" $ {build. temp} "/> <br/> <replace file =" $ {build. temp}/manifest. MF "> <br/> <replacefilter token =": = "value =" = "/> <br/> <replacefilter token = ": "value =" = "/> <br/> <replacetoken>; </replacetoken> <br/> <replacevalue> <br/> </replace> <br/> <property file = "$ {build. temp}/manifest. MF "/> </P> <p> <! -- Plugin locations --> <br/> <property name = "plugin. dir "value = <br/>" com. qualityeclipse. favorites _ $ {bundle-version} "/> <br/> <property name =" plugin. files "location = <br/>" $ {build. temp}/files/$ {plugin. dir} "/> <br/> <property name =" plugin. <a name = "iddle1543"> </a> jar "location = <br/>" $ {build. temp}/jars/plugins/$ {plugin. dir }. jar "/> <br/> <property name =" product.zip "value = <br/>" $ {build. out}/F Avorites_v1_bundle-version=.zip "/> </P> <p> <! -- Assemble the files --> <br/> <mkdir dir = "$ {plugin. files} "/> <br/> <jar destfile =" $ {plugin. files}/favorites. jar "> <br/> <fileset dir =" bin "/> <br/> </jar> <br/> <jar destfile =" $ {plugin. files}/favoritessrc.zip "> <br/> <fileset dir =" src "/> <br/> </jar> <br/> <copy todir =" $ {plugin. files} "> <br/> <fileset dir = ". "includes =" META-INF/manifest. MF "/> <br/> <fileset dir = ". "supported des =" plugin. XML "/> <br /> <Fileset dir = ". "includes =" icons /*. GIF "/> <br/> </copy> <a name =" d0e12516 "> </a> <br/> <! -- Assemble plug-in jar --> <br/> <mkdir dir = "$ {build. temp}/jars/plugins "/> <br/> <zip destfile =" $ {plugin. jar} "> <br/> <zipfileset dir =" $ {plugin. files} "> <br/> <include name = "**/*. * "/> <br/> </zipfileset> <br/> </zip> </P> <p> <! -- Assemble the product zip --> <br/> <zip destfile = "Export your product.zip}"> <br/> <fileset dir = "$ {build. temp}/jars "/> <br/> </zip> </P> <p> </Target> <br/> </Project>

InBuild-favorites.xmlRight-click and choose run ant... (Figure 2-16) run the ant script. When the ant Wizard Page is displayed, click the JRE label and select run in the same JRE as the workspace option (Figure 2-17). Click Run to build the product.

Figure 2-16 build. xml pop-up menu

Figure 2-17 and Wizard Page

NOTE: If your ant script uses the ant task specified by ECLIPSE, for examplePVDF. exportpluginsTo make your ant script executable, You must select the run in the same JRE as the workspace option.

This article is the original article of eclipselight.org (eclipse light). For more information, see the source.

Fixed Link: http://www.eclipselight.org/general/658/

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.