Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Detect install changes in dev mode #880

Merged
merged 3 commits into from
Feb 22, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 63 additions & 0 deletions src/main/groovy/io/openliberty/tools/gradle/tasks/DevTask.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -538,6 +538,17 @@ class DevTask extends AbstractFeatureTask {
return false;
}

// Detect change in installation configuration that requires restart of dev mode. Throw error.
if (hasInstallationConfigChanged(newProject, project)) {
// Note that a change in some config values requires a 'clean' because the install location is the same, but the
// artifact that gets installed would be different. This can happen when using 'libertyRuntime' for example and
// only changing the 'version'. The 'installLiberty' task cannot detect that difference today and would report the task as upToDate.
// It only detects changes in install location currently. It would not be trivial to detect the other types of changes.
logger.error("A change in Liberty runtime installation configuration requires a 'clean'. Stopping dev mode.");
util.stopServer();
throw new PluginExecutionException("A change in Liberty runtime installation configuration requires a 'clean'. After running the 'clean' task, please run the 'libertyDev' task again for the change to take effect.");
}

if(hasServerConfigBootstrapPropertiesChanged(newProject, project)) {
logger.debug('Bootstrap properties changed');
restartServer = true;
Expand Down Expand Up @@ -688,6 +699,58 @@ class DevTask extends AbstractFeatureTask {
}
}

private boolean hasInstallationConfigChanged(Project newProject, Project oldProject) {
// The following project configuration is used for the Liberty installation
// liberty extension: installDir, baseDir, cacheDir, outputDir, userDir, runtime
// libertyRuntime dependency
// liberty->install block: type, runtimeUrl, version, useOpenLiberty
if (newProject.liberty.installDir != oldProject.liberty.installDir) {
logger.debug('liberty.installDir changed')
return true
}
if (newProject.liberty.baseDir != oldProject.liberty.baseDir) {
cherylking marked this conversation as resolved.
Show resolved Hide resolved
logger.debug('liberty.baseDir changed')
return true
}
if (newProject.liberty.cacheDir != oldProject.liberty.cacheDir) {
logger.debug('liberty.cacheDir changed')
return true
}
if (newProject.liberty.outputDir != oldProject.liberty.outputDir) {
logger.debug('liberty.outputDir changed')
return true
}
if (newProject.liberty.userDir != oldProject.liberty.userDir) {
logger.debug('liberty.userDir changed')
return true
}
if (newProject.liberty.install.type != oldProject.liberty.install.type) {
logger.debug('liberty.install.type changed')
return true
}
if (newProject.liberty.install.runtimeUrl != oldProject.liberty.install.runtimeUrl) {
logger.debug('liberty.install.runtimeUrl changed')
return true
}
if (newProject.liberty.install.version != oldProject.liberty.install.version) {
logger.debug('liberty.install.version changed')
return true
}
if (newProject.liberty.install.useOpenLiberty != oldProject.liberty.install.useOpenLiberty) {
logger.debug('liberty.install.useOpenLiberty changed')
return true
}
if (newProject.liberty.runtime != oldProject.liberty.runtime) {
logger.debug('liberty.runtime changed')
return true
}
if (newProject.configurations.libertyRuntime != oldProject.configurations.libertyRuntime) {
logger.debug('libertyRuntime changed')
return true
}
return false
}

private boolean hasServerConfigBootstrapPropertiesChanged(Project newProject, Project oldProject) {
return newProject.liberty.server.bootstrapProperties != oldProject.liberty.server.bootstrapProperties;
}
Expand Down
Loading