Sunday, August 23, 2009

Using Eclipse With Large Code Bases, Part IV

Previous posts described how we created a set of Eclipse projects that break up our million-line, single-rooted source tree into manageable chunks.

Today, I'll describe how we solved a similar problem with our runtime classes:

5. JAXB is used to generate some .class files into a runtime directory "rt", but that same directory contains all of the .class files for the system

Some details on the situation:
  • Our project currently uses gmake to compile the million-plus lines of code.
  • Builds output to a runtime directory on the developer's machine called "rt". All classes required to launch the application are either in rt, or in JARs in a "lib" directory.
  • Many of the classes in the rt directory are duplicates of classes Eclipse compiles in the projects, but some of the classes in the rt directory are generated by JAXB (which is executed by gmake as part of the builds), and are not in the source tree.
  • Eclipse needs to see the generated classes in order to compile.
For example:
package com.parent.child1;

import com.parent.Parent;

import com.parent.child1.generated.Gen1;

public class Child1 extends Parent
{
private Gen1 gen1;
}
Eclipse supports linked resources, so at first it seemed like we just needed to define a linked resource for external classes that pointed to rt. Unfortunately, there are so many classes in rt that Eclipse again ground to a halt.

Fortunately, by now we were experienced with using links to subset a source directory hierarchy, so I just used the same approach to subset the runtime directory hierarchy.

First, run commands to add a link into the rt directory at the desired location:

mkdir C:\projects\Child1\rt\com\parent\child1\generated
junction C:\projects\Child1\rt\com\parent\child1\generated C:\rt\com\parent\child1\generated


Then add the rt directory to the .classpath:
<classpathentry kind="lib" path="rt"/>
Refresh in Eclipse, and the code builds:



Notes:
  • As was the case with source files, multiple links to runtime-class directories can be created for a single project.
  • If multiple projects need the same .class files from an rt directory, the rt link should be set only in the project that generates the .class files. Other projects should point to that rt link via Build Path → Add Class Folder...

In Part V, I'll describe how we fixed a problem with the Perforce Eclipse plugin caused by using links.

No comments:

Post a Comment