alesch
alesch

Reputation: 842

How to run external built project on IntelliJ?

The project I'm working on is built by a complex set of shell and ant scripts.
The build can be runed externally or from within ItelliJ as external tool.

1) How do I tell IntelliJ not to build my project?
I want to launch the build manually.

2) How do I tell IntelliJ the location of my class files? Classpath?
Setting CLASSPATH as an environment variable in the run configuration seems not to have any effect.

My goal is to be able to debug the code inside IntelliJ.

Thanks in advance!

Upvotes: 1

Views: 1917

Answers (1)

Steinar
Steinar

Reputation: 5950

I'm providing the answer for Intellij IDEA 12 here. It is basically the same for earlier versions, though it has been changed slightly.

You have at least two options to achieve your goal:

  • To skip the build step in idea and modify the classpath (i.e. the steps you outlined yourself)
  • To debug remote process, which might be easier if you're already building outside IDEA anyway.

I'll provide a quick overview on both.


How to tell IntelliJ IDEA not to build.

  1. Select Run > Edit Configurations from the menu.
  2. Select (or create) your configuration.
  3. Remove the "Before launch: Make" step, by selecting the Make step and clicking on the '-' icon. Remove Make from the Run/Debug configuration

How to modify the classpath

You do this for both the project and for each individual module.

First, select File > Project structure from the menu.

Project:

  1. Select Project in the left side menu.
  2. Change the "Project compiler output" path to whereever your external build tools put your classfiles. Change project compiler output

Module:

  1. Select Modules in the left side menu.
  2. Choose the module to modify.
  3. Select the "Paths" tab.
  4. Select "Inherit project compile output path" or "Use module compile output path", depending on whether you want to override the path for this module. Change module compiler output

Debug remote process

In this case you simply start your remote java process with debug options. These options differ a bit for different versions of java, but IntelliJ will tell you the correct flags to use for each version.

  1. Select Run > Edit Configurations from the menu.
  2. Choose the + sign in the top-right corner.
  3. Select "Remote".
  4. Choose host and port for the remote process, as shown in the image below.
  5. Copy the correct command line option for the remote process - I'v outlined the button for the latest Java versions.
  6. Make sure the remote process is started with these options.
  7. Give it a name and save your configuration for later re-use! Remote run/debug configuration

Upvotes: 1

Related Questions