Skip to content

Commit

Permalink
more
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexey Loubyansky committed Nov 13, 2024
1 parent b045e8e commit 9d8d021
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 42 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -563,19 +563,20 @@ private Set<String> addExtensionJvmOptions() {
log.debugf("Skipped JVM options from %s", extDevMode.getExtensionKey());
continue;
}
log.debugf("Adding JVM options from %s", extDevMode.getExtensionKey());
if (extDevMode.getJvmOptions() != null) {
jvmOptionsBuilder.addAll(extDevMode.getJvmOptions());
final JvmOptions jvmOptions = extDevMode.getJvmOptions();
if (jvmOptions != null && !jvmOptions.isEmpty()) {
jvmOptionsBuilder.addAll(jvmOptions);
if (log.isDebugEnabled()) {
for (var arg : extDevMode.getJvmOptions().asCollection()) {
log.debugf("Adding JVM options from %s", extDevMode.getExtensionKey());
for (var arg : jvmOptions.asCollection()) {
log.debug(" " + arg.getName() + ": " + arg.getValues());
}
}
}
mergedLockedOptions = collectLockedOptions(mergedLockedOptions, extDevMode.getLockDefaultJvmOptions(),
extDevMode.getExtensionKey());
mergedLockedOptions = collectLockedOptions(mergedLockedOptions, extDevMode.getLockDefaultXxJvmOptions(),
extDevMode.getExtensionKey());
if (!extDevMode.getLockJvmOptions().isEmpty()) {
mergedLockedOptions = collectLockedOptions(mergedLockedOptions, extDevMode.getLockJvmOptions(),
extDevMode.getExtensionKey());
}
}
return mergedLockedOptions;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -609,32 +609,31 @@ private Set<String> setExtensionJvmOptions() {
debug("Skipped JVM options from %s", extDevMode.getExtensionKey());
continue;
}
debug("Adding JVM options from %s", extDevMode.getExtensionKey());
if (extDevMode.getJvmOptions() != null) {
jvmOptionsBuilder.addAll(extDevMode.getJvmOptions());
if (isDebugEnabled()) {
debug("Adding JVM options from %s", extDevMode.getExtensionKey());
for (var arg : extDevMode.getJvmOptions().asCollection()) {
debug(" " + arg.getName() + ": " + arg.getValues());
}
}
}
if (!extDevMode.getLockDefaultXxJvmOptions().isEmpty()) {
if (!extDevMode.getLockJvmOptions().isEmpty()) {
if (mergedLockedOptions != null) {
mergedLockedOptions.addAll(extDevMode.getLockDefaultXxJvmOptions());
mergedLockedOptions.addAll(extDevMode.getLockJvmOptions());
} else if (extLockingOptions == null) {
extLockingOptions = extDevMode;
} else {
mergedLockedOptions = new HashSet<>();
mergedLockedOptions.addAll(extLockingOptions.getLockDefaultXxJvmOptions());
mergedLockedOptions.addAll(extDevMode.getLockDefaultXxJvmOptions());
mergedLockedOptions.addAll(extLockingOptions.getLockJvmOptions());
mergedLockedOptions.addAll(extDevMode.getLockJvmOptions());
extLockingOptions = null;
}
debug("%s locks XX JVM options %s", extDevMode.getExtensionKey(),
extDevMode.getLockDefaultXxJvmOptions());
debug("%s locks XX JVM options %s", extDevMode.getExtensionKey(), extDevMode.getLockJvmOptions());
}
}
return mergedLockedOptions == null
? (extLockingOptions == null ? Set.of() : extLockingOptions.getLockDefaultXxJvmOptions())
? (extLockingOptions == null ? Set.of() : extLockingOptions.getLockJvmOptions())
: mergedLockedOptions;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,7 @@ public WorkspaceModule.Mutable getOrCreateProjectModule(WorkspaceModuleId id, Fi
*/
public void handleExtensionProperties(Properties props, ArtifactKey extensionKey) {
JvmOptionsBuilder jvmOptionsBuilder = null;
Set<String> lockJvmOptions = null;
Set<String> lockXxJvmOptions = null;
Set<String> lockJvmOptions = Set.of();
for (Map.Entry<Object, Object> prop : props.entrySet()) {
if (prop.getValue() == null) {
continue;
Expand Down Expand Up @@ -212,23 +211,35 @@ public void handleExtensionProperties(Properties props, ArtifactKey extensionKey
addLesserPriorityArtifacts(extensionKey, value);
break;
case BootstrapConstants.EXT_DEV_MODE_LOCK_XX_JVM_OPTIONS:
lockXxJvmOptions = Set.of(value.split(COMMA));
break;
case BootstrapConstants.EXT_DEV_MODE_LOCK_JVM_OPTIONS:
lockJvmOptions = Set.of(value.split(COMMA));
lockJvmOptions = splitByCommaAndAddAll(value, lockJvmOptions);
break;
default:
if (name.startsWith(REMOVED_RESOURCES_DOT)) {
addRemovedResources(extensionKey, name, value);
}
}
}
if (jvmOptionsBuilder != null || lockXxJvmOptions != null || lockJvmOptions != null) {
if (jvmOptionsBuilder != null || lockJvmOptions != null) {
extensionDevConfig.add(new ExtensionDevModeConfig(extensionKey,
jvmOptionsBuilder == null ? JvmOptions.builder().build() : jvmOptionsBuilder.build(),
lockJvmOptions == null ? Set.of() : lockJvmOptions,
lockXxJvmOptions == null ? Set.of() : lockXxJvmOptions));
lockJvmOptions));
}
}

private static Set<String> splitByCommaAndAddAll(String commaList, Set<String> set) {
var arr = commaList.split(COMMA);
if (arr.length == 0) {
return set;
}
if (set.isEmpty()) {
return Set.of(arr);
}
set = new HashSet<>(set);
for (int i = 0; i < arr.length; ++i) {
set.add(arr[i]);
}
return set;
}

private void addRemovedResources(ArtifactKey extension, String name, String value) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,12 @@ public class ExtensionDevModeConfig implements Serializable {

private final ArtifactKey extensionKey;
private final JvmOptions jvmOptions;
private final Set<String> lockDefaultJvmOptions;
private final Set<String> lockDefaultXxJvmOptions;
private final Set<String> lockJvmOptions;

public ExtensionDevModeConfig(ArtifactKey extensionKey, JvmOptions jvmOptions, Set<String> lockDefaultJvmOptions,
Set<String> lockDefaultXxJvmOptions) {
public ExtensionDevModeConfig(ArtifactKey extensionKey, JvmOptions jvmOptions, Set<String> lockDefaultJvmOptions) {
this.extensionKey = extensionKey;
this.jvmOptions = jvmOptions;
this.lockDefaultJvmOptions = lockDefaultJvmOptions;
this.lockDefaultXxJvmOptions = lockDefaultXxJvmOptions;
this.lockJvmOptions = lockDefaultJvmOptions;
}

/**
Expand All @@ -47,17 +44,7 @@ public JvmOptions getJvmOptions() {
*
* @return JVM options that shouldn't be overridden
*/
public Set<String> getLockDefaultJvmOptions() {
return lockDefaultJvmOptions;
}

/**
* XX JVM options whose default values should not be overridden with values that otherwise would be recommended
* as defaults for Quarkus dev mode by the Quarkus Maven and Gradle plugins.
*
* @return XX JVM options that shouldn't be overridden
*/
public Set<String> getLockDefaultXxJvmOptions() {
return lockDefaultXxJvmOptions;
public Set<String> getLockJvmOptions() {
return lockJvmOptions;
}
}

0 comments on commit 9d8d021

Please sign in to comment.