Sample: Creating a plug-in project from the command-line interface

You can create a plug-in project by using the command-line interface; however, the preferred method to create plug-in projects is by using Eclipse.

Before you begin

For more information about creating a plug-in project using Eclipse, see Sample: Developing a plug-in and pattern type with Eclipse.

Procedure

  1. Open the command-line interface.
  2. Change directory to the plugin.depends project directory in your workspace.
  3. Set the ANT_HOME environment variable. You can use Ant in your Eclipse installation at eclipse/plugins/org.apache.ant_1.7*. You can also invoke this Ant script from Eclipse. To do this, right-click create.plugin.project.xml in the plugin.depends project. Select Run As > Ant Build. Click the Main tab. In the argument section, type the various -Dproject.name=jp1 values that are provided in this sample.
  4. Create a template plug-in project by using the following command:
    ant -Dproject.name=tp1 -Dplugin.name=a.b.c.template -f create.plugin.project.xml
    

    The project.name property is optional and if it is not specified, it defaults to the value of the plugin.name.

  5. Create a Java™ plug-in project:
    1. Create a Java plug-in project that contains no package name:
      (.java assumed on java classname)
      
      ant -Dproject.name=jp1 -Dplugin.name=a.b.c.java -Djava.classname=MyPlugin -f create.plugin.project.xml 
      
      
    2. Create a Java plug-in project that contains a package name:
      ant -Dproject.name=jp2 -Dplugin.name=a.b.c.java -Djava.classname=a.b.c.MyPlugin -f create.plugin.project.xml 
  6. Verify that the command is successful. Import the newly created projects into your workspace.
    To build the plug-in projects, for example, jp1, you can find build.plugin.xml in project jp1. Right-click build.plugin.xml and issue Run As > Ant Build with the goal clean, publish selected. The equivalent Ant command is to issue the following command in the project jp1 directory:
    ant –f build.plugin.xml clean publish 
    The plug-in a.b.c.java-<version>.tgz is created in the export directory.