> On 22 Apr 2020, at 02:42, Olivier Lamy <[email protected]> wrote:
>
>>
>>
>> Should I be targeting my change at the assembly plugin or would it make
>> more sense to try and get this deeper into plexus-archiver? Do you have any
>> further advice where best to start??
>>
>
> Well you're hitting the real problem: where to start :)
> the first question is how do you know nothing changed in the m-assembly-p
> inputs before you're starting it? (inputs are so many: jars, files,
> directories etc...)
> the first is to identify those inputs and then try to figure out how do I
> store the state of those inputs between 2 builds
For my purposes, checking that none of the source files is newer than the
destination would probably suffice but clearly that fails in the general case
when the set of source files changes, or the assembly model changes. Something
along those lines could be implemented at either assembly or archiver level,
but is clearly enough of a hack that it’d need yet another option so that folks
can opt out of the behaviour.
As you point out, to implement properly we’d need to reliably know whether the
state has changed for the assembly. I propose that we store a hash of the
inputs (assembly model xml + path & size & lastModified for each of the
sources), which can quickly be recomputed on a second run and compared with the
original to detect changes. My initial plan for storing the state was to store
the hash in a file with the name derived from the assembly’s destination file
path.
Ultimately it would be nice if such infrastructure was general enough that it
could be easily reused in other plugins too… I’m currently pondering an API
along the following lines:
final ChecksumStore checksums = // ideally a project-wide component
new FileChecksumStore("target/checksums/");
final Checksum checksum = checksums.builder()
.addInputFileDescriptors(Arrays.asList(inputFiles)) // primary use case
.addInputFileContents(Arrays.asList(inputFiles)) // future use case??
.addInputString(project.getVersion()) // arbitrary input could be hashed
.build(destFile);
if (checksum.matches()) {
getLogger().debug("Skipping unnecessary operation");
} else {
getLogger().debug("Checksum mismatch, doing operation");
// ...
checksum.store();
}
What do you think?
Thanks,
Rob