How to Run/Debug project with two executables?

已回答

My project produces two executables, the main application and a matching updater. The two share some code.

However, the Module is “pointed” to the main application src/ directory, and the updater is in a separate directory in the same project.  I use an ant script to build both for Linux, Windows and Mac.

Is it possible to Run/Debug the updater somehow without creating entirely separate projects for the two executables and a library of shared code? The class chooser for the main method only shows that of the main application.

It's at ELS on GitHub if anyone is interested.

Thank you for your time.

0

Hi, Todd!

Thank you for reaching out to us and my apologies for the delay in answering your question.

Yes, this should be possible by creating a second module. A module, generally speaking, consists of one or more content roots and a module file (but it is also possible to exist without any) and is automatically created with a new project. You can find more about the modules here.

To achieve what you're looking for, please follow these steps:

Create a new module:

  1. Go File | Project Structures… and click the + button in the Modules section;
  2. Select New Module;
  3. Choose Java as the Module type and give it a name;
  4. Set the Location to your updater's directory and click Create;

Configure the module sources:

  1. Back to the Project Structures… dialog, select your new updater module;
  2. In the Sources tab, mark your updater's source directory as Sources (blue folder);
  3. (Optional) If needed, any resource directories as Resources;
  4. (Optional) If you would like to customize where the compiled classes go to, then also configure the output path;

Set up module dependencies:

  1. Still, in the Project Structures… dialog, go to the Dependencies tab of your updater module;
  2. Click the + button and select Module Dependency;
  3. Select your main application module to share its code;
  4. Select the appropriate scope (usually Compile or Implementation);

Create a run configuration for the updater:

  1. Now go to Run | Edit Configurations…
  2. Click +, select Application, and give it a name;
  3. Set the Main class to your updater's main class;
  4. In the Build and Run section, select your new updater module;

    If this part is not showing, then just enable it by clicking Modify options and check the Use classpath of module option.

  5. Configure any other options as needed;

A bit of a long tutorial, but I hope this helps on the way. Pllease do let me know in case you have any questions.

0

请先登录再写评论。