-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Do not reset on server restart and allow configuring reuse (#145)
* Revert reuse * Allow configuring reuse * Do not reset on server restart
- Loading branch information
Showing
6 changed files
with
97 additions
and
75 deletions.
There are no files selected for viewing
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
54 changes: 54 additions & 0 deletions
54
deployment/src/main/java/io/quarkus/jgit/deployment/JGitDevServicesProcessor.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,54 @@ | ||
package io.quarkus.jgit.deployment; | ||
|
||
import java.util.Map; | ||
import java.util.function.BooleanSupplier; | ||
|
||
import org.jboss.logging.Logger; | ||
|
||
import io.quarkus.deployment.IsNormal; | ||
import io.quarkus.deployment.annotations.BuildStep; | ||
import io.quarkus.deployment.builditem.CuratedApplicationShutdownBuildItem; | ||
import io.quarkus.deployment.builditem.DevServicesResultBuildItem; | ||
import io.quarkus.deployment.builditem.DevServicesResultBuildItem.RunningDevService; | ||
import io.quarkus.deployment.dev.devservices.GlobalDevServicesConfig; | ||
import io.quarkus.devservices.common.ContainerShutdownCloseable; | ||
|
||
public class JGitDevServicesProcessor { | ||
|
||
private static final Logger log = Logger.getLogger(JGitDevServicesProcessor.class); | ||
static volatile RunningDevService devService; | ||
|
||
@BuildStep(onlyIfNot = IsNormal.class, onlyIf = { GlobalDevServicesConfig.Enabled.class, DevServicesEnabled.class }) | ||
DevServicesResultBuildItem createContainer(JGitBuildTimeConfig config, | ||
CuratedApplicationShutdownBuildItem closeBuildItem) { | ||
if (devService != null) { | ||
// only produce DevServicesResultBuildItem when the dev service first starts. | ||
return null; | ||
} | ||
var gitServer = new GiteaContainer(config.devservices()); | ||
gitServer.start(); | ||
String httpUrl = gitServer.getHttpUrl(); | ||
log.infof("Gitea HTTP URL: %s", httpUrl); | ||
Map<String, String> configOverrides = Map.of("quarkus.jgit.devservices.http-url", httpUrl); | ||
|
||
ContainerShutdownCloseable closeable = new ContainerShutdownCloseable(gitServer, JGitProcessor.FEATURE); | ||
closeBuildItem.addCloseTask(closeable::close, true); | ||
devService = new RunningDevService(JGitProcessor.FEATURE, gitServer.getContainerId(), closeable, configOverrides); | ||
return devService.toBuildItem(); | ||
} | ||
|
||
public static class DevServicesEnabled implements BooleanSupplier { | ||
|
||
final JGitBuildTimeConfig config; | ||
|
||
public DevServicesEnabled(JGitBuildTimeConfig config) { | ||
this.config = config; | ||
} | ||
|
||
@Override | ||
public boolean getAsBoolean() { | ||
return config.devservices().enabled(); | ||
} | ||
} | ||
|
||
} |
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