buildSummarizerIfNotExists function
Future<void>
buildSummarizerIfNotExists(
{ - bool force = false,
})
Implementation
Future<void> buildSummarizerIfNotExists({bool force = false}) async {
// TODO(#43): This function cannot be invoked concurrently because 2 processes
// will start building summarizer at once. Introduce a locking mechnanism so
// that when one process is building summarizer JAR, other process waits using
// exponential backoff.
final jarExists = await File(jarFile).exists();
final isJarStale = jarExists &&
await isPackageModifiedAfter(
'jnigen', await File(jarFile).lastModified(), 'java/');
if (isJarStale) {
log.info('Rebuilding ApiSummarizer component since sources '
'have changed. This might take some time.');
}
if (!jarExists) {
log.info('Building ApiSummarizer component. '
'This might take some time. '
'The build will be cached for subsequent runs.');
}
if (!jarExists || isJarStale || force) {
await buildApiSummarizer();
} else {
log.info('ApiSummarizer.jar exists. Skipping build..');
}
}