Skip to content

Commit

Permalink
Relativize the classpaths that are recorded during a JVM compile (#5139)
Browse files Browse the repository at this point in the history
### Problem

Currently, when we record classpaths during JVM compiles, we are recording the absolute paths. This is violating the idea that all builds are relatively homogenous. Additionally, if there is additional caching of jars, the absolute classpaths could cause unnecessary misses. 

### Solution

The solution is to relativize the classpaths. 

### Result

Instead of 
```
/var/lib/mesos/slaves/a3942c64-03ad-4d95-80d7-767c6ba796c5-S7111/hashed-run/workspace/pants/.pants.d/compile/zinc/27609ddd7aa2/target/current/classes
/var/lib/mesos/slaves/a3942c64-03ad-4d95-80d7-767c6ba796c5-S7111/hashed-run/workspace/pants/.pants.d/ivy/jars/org.apache.thrift/libthrift/jars/libthrift-0.5.0-5.jar
```
The file contains relative classpaths to the pants global workdir (ie .pants.d). For instance
```
compile/zinc/27609ddd7aa2/target/current/classes
ivy/jars/org.apache.thrift/libthrift/jars/libthrift-0.5.0-5.jar
```
  • Loading branch information
dotordogh authored and Stu Hood committed Dec 1, 2017
1 parent 5d39e84 commit eb77444
Showing 1 changed file with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -554,7 +554,8 @@ def do_compile(self,
raise TaskError("Compilation failure: {}".format(e))

def _record_compile_classpath(self, classpath, targets, outdir):
text = '\n'.join(classpath)
relative_classpaths = [fast_relpath(path, self.get_options().pants_workdir) for path in classpath]
text = '\n'.join(relative_classpaths)
for target in targets:
path = os.path.join(outdir, 'compile_classpath', '{}.txt'.format(target.id))
safe_mkdir(os.path.dirname(path), clean=False)
Expand Down

0 comments on commit eb77444

Please sign in to comment.