Guide - How to auto-export your plugin using ant

Oct 22, 2019
Guide - How to auto-export your plugin using ant
  • Configuring Ant to auto export your plugin

    Short guide to configure your ant to auto export your plugin

    Hello, this should hopefully be the one stop shop, for getting yourself a very useful auto-export system for Eclipse Ant projects.

    Creating the project(top)

    If you have yet to create a project go and check out this guide

    Creating the ant file(top)

    Now you have your project, you are going to want to right click your project, go to "New", and then "File". Once you click on that, you will get a dialog box, make sure the parent folder is the correct project. Then enter "build.ant" for the file name. Finally, click finish!

    Entering the needed information(top)

    After clicking finish, the build.ant file should have opened automatically; however if it didn't, go ahead and open it. Next you are going to want to paste this in[/SIZE]
    Code (XML):
    <?xml version="1.0" encoding="UTF-8"?>
    <project name="SimpleProject" default="CreateJar" basedir = ".">
        <basename file="${basedir}" property="project.projectname"/>
        <property name="project.pluginsLocation" location="PLUGINS DIRECTORY"/>

        <target name="clean" description="Cleans project">
            <delete file="${project.pluginsLocation}\${project.projectname}.jar"/>
        <target name="CreateJar" description="Create a jar for the project" depends="clean">
            <jar destfile="${project.pluginsLocation}\${project.projectname}.jar">
               <fileset dir="${basedir}">
                  <include name="**.yml"/>
               <fileset dir="${basedir}\bin">
                   <include name="**"/>

    Now the next thing you are going to need to do is put in the plugin directory. (or where ever you would like the plugins to be exported to). You replace the text on line 5 reading "PLUGINS DIRECTORY" with the directory you would like it to go to. Finally, go ahead and save it!

    Adding the Builder(top)

    Now that you have your build.ant file created you are going to want to once again right click your project, then click "properties" and a dialog box should open called "Properties for Project Name"

    Click "Builders" on the right hand side of the dialog box. then click "New...", and again another dialog box. next click "Ant Builder", and now another dialog box should open called "Edit Configuration".

    Firstly give the new builder a recognizable name perhaps "Plugin ant builder".

    Go to the tab labeled "Main". Here you will want to click on "Browse Workspace..." under "Build file:". In the new dialog box, click your project on the right, then on the left click "build.ant" and then "OK"

    Go to the tab labeled "Refresh" check the box labeled "Refresh resources upon completion", this should then choose the selector "The project containing the selected resource"

    Go to the tab labeled "Targets"
    If you would like the plugin to automatically be exported every time, then click "Set Targets..." next to "Auto build" then just click "OK" in the new dialog box.
    Then do the same thing with "During a "Clean":"

    Finally click "OK" in the "Edit Configuration" dialog box, and then "Apply and Close" in the properties dialog box. You are now good to go!

    Useful Tips(top)

    - So now that you have your project set up, you can basically now use this ant file for any other project you don't need to change anything (unless of course you want the plugin destination to be different).

    - When exporting, the jar file will be named the exact same as your project name. If you would like to change this to a static name, then you can change line 4 of the ant file to
    Code (XML):
    <property name="project.projectname" value="JARNAME"/>

    - If you would like to manually export it there are a few options
    1. You can click the "Run as..." button (looks like a simple green play arrow) in the top icon bar, and it should say "%project name% build.ant" then just select the correct one, if there are two+ of the same, you should be safe to click any.
    2. you can right click the "build.ant" file, then click "Run as..." then click the first option.
    3. If you have it automatically saving then it will automatically export the jar EVERY time you save ANY file in the project!
    4. if you had noticed in option 2, there is a key short cut which is "ALT+SHIFT+X, Q" which will export it quickly, to do this just do the first combo of alt+shift+x then let those go then click q.

    - if you would like to add more types of files to be exported you can add a new line after line 15 with similar syntax to that of line 14 and 15, some useful examples might include
    Code (XML):
    // Export source code as well
    <include name="src\**"/>

    // Export txt files
    <include name = "**.txt"/>

    ~ small update changed the ant code slightly
  • Loading...
  • Loading...