-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Don't restart in test mode, it slows down continuous testing - Processors only produce DevServicesConfigResultBuildItem, quarkus handles turning it into runtime config - If no changes are made Quarkus handles the cached config, so the processor does not have to Fixes #19044
- Loading branch information
1 parent
b5f2637
commit 64781be
Showing
17 changed files
with
178 additions
and
190 deletions.
There are no files selected for viewing
29 changes: 29 additions & 0 deletions
29
...yment/src/main/java/io/quarkus/deployment/builditem/DevServicesConfigResultBuildItem.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package io.quarkus.deployment.builditem; | ||
|
||
import io.quarkus.builder.item.MultiBuildItem; | ||
|
||
/** | ||
* Configuration property that is the result of start dev services. | ||
* | ||
* Used to start and configure dev services, any processor starting dev services should produce these items. | ||
* | ||
* Quarkus will make sure the relevant settings are present in both JVM and native modes. | ||
*/ | ||
public final class DevServicesConfigResultBuildItem extends MultiBuildItem { | ||
|
||
final String key; | ||
final String value; | ||
|
||
public DevServicesConfigResultBuildItem(String key, String value) { | ||
this.key = key; | ||
this.value = value; | ||
} | ||
|
||
public String getKey() { | ||
return key; | ||
} | ||
|
||
public String getValue() { | ||
return value; | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
...c/main/java/io/quarkus/deployment/builditem/DevServicesLauncherConfigResultBuildItem.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package io.quarkus.deployment.builditem; | ||
|
||
import java.util.Map; | ||
|
||
import io.quarkus.builder.item.SimpleBuildItem; | ||
|
||
/** | ||
* Build item that contains the final results of all | ||
*/ | ||
public final class DevServicesLauncherConfigResultBuildItem extends SimpleBuildItem { | ||
|
||
final Map<String, String> config; | ||
|
||
public DevServicesLauncherConfigResultBuildItem(Map<String, String> config) { | ||
this.config = config; | ||
} | ||
|
||
public Map<String, String> getConfig() { | ||
return config; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
core/deployment/src/main/java/io/quarkus/deployment/steps/DevServicesConfigBuildStep.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package io.quarkus.deployment.steps; | ||
|
||
import java.util.Collections; | ||
import java.util.HashMap; | ||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.stream.Collectors; | ||
|
||
import org.eclipse.microprofile.config.Config; | ||
import org.eclipse.microprofile.config.ConfigProvider; | ||
|
||
import io.quarkus.deployment.annotations.BuildProducer; | ||
import io.quarkus.deployment.annotations.BuildStep; | ||
import io.quarkus.deployment.annotations.Produce; | ||
import io.quarkus.deployment.builditem.DevServicesConfigResultBuildItem; | ||
import io.quarkus.deployment.builditem.DevServicesLauncherConfigResultBuildItem; | ||
import io.quarkus.deployment.builditem.DevServicesNativeConfigResultBuildItem; | ||
import io.quarkus.deployment.builditem.RunTimeConfigurationDefaultBuildItem; | ||
import io.quarkus.deployment.builditem.ServiceStartBuildItem; | ||
|
||
class DevServicesConfigBuildStep { | ||
|
||
private static volatile Map<String, String> oldProperties = Collections.emptyMap(); | ||
|
||
@BuildStep | ||
List<DevServicesConfigResultBuildItem> deprecated(List<DevServicesNativeConfigResultBuildItem> items) { | ||
return items.stream().map(s -> new DevServicesConfigResultBuildItem(s.getKey(), s.getValue())) | ||
.collect(Collectors.toList()); | ||
} | ||
|
||
@BuildStep | ||
@Produce(ServiceStartBuildItem.class) | ||
DevServicesLauncherConfigResultBuildItem setup(BuildProducer<RunTimeConfigurationDefaultBuildItem> runtimeConfig, | ||
List<DevServicesConfigResultBuildItem> devServicesConfigResultBuildItems) { | ||
Map<String, String> newProperties = new HashMap<>(devServicesConfigResultBuildItems.stream().collect( | ||
Collectors.toMap(DevServicesConfigResultBuildItem::getKey, DevServicesConfigResultBuildItem::getValue))); | ||
Config config = ConfigProvider.getConfig(); | ||
//check if there are existing already started dev services | ||
//if there were no changes to the processors they don't produce config | ||
//so we merge existing config from previous runs | ||
//we also check the current config, as the dev service may have been disabled by explicit config | ||
for (Map.Entry<String, String> entry : oldProperties.entrySet()) { | ||
if (!newProperties.containsKey(entry.getKey()) && config.getOptionalValue(entry.getKey(), String.class).isEmpty()) { | ||
newProperties.put(entry.getKey(), entry.getValue()); | ||
} | ||
} | ||
for (Map.Entry<String, String> entry : newProperties.entrySet()) { | ||
runtimeConfig.produce(new RunTimeConfigurationDefaultBuildItem(entry.getKey(), entry.getValue())); | ||
} | ||
oldProperties = newProperties; | ||
return new DevServicesLauncherConfigResultBuildItem(Collections.unmodifiableMap(newProperties)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.