Java code to convert a list of dependencies into a build order?

Posted by Egon Willighagen on Stack Overflow See other posts from Stack Overflow or by Egon Willighagen
Published on 2010-05-14T07:47:52Z Indexed on 2010/05/14 7:54 UTC
Read the original article Hit count: 360

Filed under:
|
|

Given I have a list of dependencies, like:

module1
module2 dependsOn module1
module3 dependsOn module1
module4 dependsOn module3

I would like to create a build order where each build step is found on one line, and each line contains a list of one or more modules which can be compiled at the same time, and which only depend on modules compiled earlier.

So, for the above data set, create a list like:

module1
module2,module3
module4

Now, this is basically just a problem of creating a directed graph, and analyzing it. Now, I am using Ant, and would very much like to use something off-the-shelf... what is the minimum of custom code I need to have it create such a dependency-aware build list starting from the given input?

BTW, these modules are actually custom modules, so maven will not work.

© Stack Overflow or respective owner

Related posts about java

Related posts about build-automation