0

In most programming IDE I can run a process (a jar or exe) before compile or build. For example, I can run an exe file to generate a few classes. This is more enhanced with text templates in Visual Studio.

Is it possible to run a process before compile or build in Netbeans? Do we have a similar concept like text templates in NetBeans? I am using NetBeans version 8.0.2

AaA
  • 3,600
  • 8
  • 61
  • 86
  • Not sure if it is what you are looking for https://platform.netbeans.org/tutorials/nbm-filetemplates.html – T D Nguyen Nov 17 '15 at 10:28
  • 1
    Default Netbeans projects use [Ant](http://ant.apache.org/) to build. Probably, you can edit ant scripts to run code generation before build. Check out this question: http://stackoverflow.com/questions/3730880/use-ant-for-running-program-with-command-line-arguments – default locale Nov 17 '15 at 10:31
  • Check the manual: http://docs.oracle.com/cd/E50453_01/doc.80/e50452/create_japps.htm#CHDDAHEB –  Nov 17 '15 at 11:38
  • @NguyenDoanTung, Although your link is to an interesting document, it does not do what I need. In vsual studio, text template is used to generate code that will compile with rest of the program. because you have access to project space, you can generate code based on other code in your project. For example, you create an xml template in your project and TT will use that xml file to create Data access, Permission Class or even UI. – AaA Nov 18 '15 at 02:44

1 Answers1

2

To execute a command before compiling, put it in the build.xml file as this:

<target name="-pre-compile">
    <exec executable="cmd">
        <arg value="arg1"/>
        <arg value="arg2"/>
    </exec>
</target>

See the Exec Task for Ant. https://ant.apache.org/manual/Tasks/exec.html

Code templates that can be accessed from Tools -> Templates are a completely separate matter. The templates are used when File -> New for the appropriate type is executed.

WillShackleford
  • 6,918
  • 2
  • 17
  • 33
  • Thank you. The link was a little confusing but with some try and error, I managed to run my jar file before compile. – AaA Nov 18 '15 at 02:34