javaintellij-ideacontinuous-integrationbuild-automation

How to automate the Java build process for IntelliJ IDEA 11 Projects?


I am trying to set up a continuous integration system for a Java project I am working on. I plan to use Jenkins or some equivalent for the front end. The Java project is configured to use the IntelliJ IDEA IDE, version 11. The problem is there is no way to build IntelliJ IDEA 11 projects from a command line interface, which is required so it can interface with the CI front-end (Jenkins).

There are a couple of potential solutions I have looked into. They are as follows.

Potential Solution # 1

Use the "Generate Ant Build" capability of IntelliJ IDEA. There are 2 problems with this solution:

  1. It means I would have to either maintain the generated ant files as well as the IntelliJ idea configuration files, which I don't want to do, or I would have to programatically recreate the ant files periodically or on the fly, which is not feasible since there is no command line interface for this either.
  2. It doesn't even work anyway. The project is fairly complex in that there are Java files that are configured to be excluded, and the generated ant files do not perform exclusion properly. Also, it looks like the dependencies are not even generated correctly. (Exhaustively) searching google tells me that this utility isn't even supported by IntelliJ, and it's use should be "avoided".

Potential Solution # 2

Use a 3rd party application to dynamically generate ant build files, namely ant-intellij-tasks. When I saw this project I was pretty excited, but unfortunately it looks like it hasn't been updated since 2009 and doesn't work with the new version of IntelliJ IDEA. I can't find any other libraries like this one that are up to date and working.

Some Additional Notes

This link suggests that others are having similar problems and want a command line interface (the link is a description of a plugin wanted for a contest - the source is IntelliJ IDEA themselves).

Has anyone else set up build automation using this tool set? How did you get it done? The answer I'm looking for ideally doesn't require management of additional configuration files and would allow me to type something on the command line and have the build happen.


Solution

  • Converting your project to fit with maven is easier to do than customizing Maven to work with your project structure.

    Although you could do the latter, most of the time people don't design the way their project is laid out very cleanly at all, and after they adopt the maven layout, their project becomes much more manageable.

    If you adapt the good patterns of a default maven project layout, IDEA will automatically read it and understand it completely - even sharing the same compiler output you use on the command line in the IDE. IDEA will use the pom.xml as its configuration file.

    You can't do this with Ant, because it's a build process wrapper. Maven is not only a dependency management mechanism - it's an abstraction of a project, which an IDE can use to configure itself.