On 27 Feb 2014, at 8:42 am, Daz DeBoer <darrell.deb...@gradleware.com> wrote:

> On Wed, Feb 26, 2014 at 2:05 PM, Adam Murdoch <adam.murd...@gradleware.com> 
> wrote:
> 
> On 27 Feb 2014, at 12:17 am, Joachim Nilsson <jocce.nils...@gmail.com> wrote:
> 
>> Thanks Adam.
>> 
>> A follow up question:
>> CONTRIBUTION.md states 'Avoid using features introduced in Java 1.6 or 
>> later'.
>> Is this a hard requirement or could I use java.nio.Path from java7? 
>> That would really simplify the use of relative paths, which I will need if I 
>> use cache dir as base.
>> 
>> I have one concern, that is if output or input resides in directories 
>> outside of the root project.
>> In that case, forcing the use of relative paths may destroy portability as 
>> well, if the destination directory is not on 'same path depth' as the 
>> origin. 
>> With my first simple approach to use rootDir as detector of when a path 
>> could be rewritten, paths and files outside the project would remain 
>> absolute when serialised.
> 
> You can (and should) still use the same approach. You can always change 
> TaskArtifactStateCacheAccess to provide the root directory instead of the 
> cache directory.
> 
>> This may be a minor concern and can probably be handled by documentation. 
>> Just something to think about. 
> 
> The plan is at some point to switch from using paths, and instead use input 
> and output content as the key incremental state. Then, when a task executes, 
> we can check if any task of the same type has run with the same input content 
> anywhere on the machine, and what output content it produced. We can then 
> compare the content of the actual outputs to see if the task is out of date.
> 
> Once we're using the task inputs as the key, it might be easier to move to a 
> distributed cache of build outputs that would mean the we could re-use 
> artifacts previously built by another developer or by CI. That would be a big 
> build-avoidance step forward.

That’s exactly the idea.

Once we’re more tolerant to things moving around, we can start reusing the 
outputs from one task to produce the outputs for some other task with the same 
input content, by simply copying the outputs into place.

For example, when compiling c++ sources for multiple variants with the same 
source files and same compiler settings, I can compile once and then reuse the 
resulting object files. Similarly when generating the resources for variants of 
an Android app. Or when I rename a jar without changing the inputs (eg the 
version changes), I can just rename the jar.

Then, if we move this cache so that it’s shared by all builds on the machine, 
we can reuse outputs between builds, whether I’ve moved the build or have 
multiple check outs. Which is nice for people working on branches of the same 
thing, or for CI machines.

And then it’s a (conceptually) simple step to share this cache across machines.

Of course, it’s not quite that simple, but that’s the rough plan.


--
Adam Murdoch
Gradle Co-founder
http://www.gradle.org
VP of Engineering, Gradleware Inc. - Gradle Training, Support, Consulting
http://www.gradleware.com



Reply via email to