Skip to content
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package io.quarkus.deployment;

import java.util.function.BooleanSupplier;

import io.quarkus.deployment.annotations.BuildStep;
import io.quarkus.runtime.LaunchMode;

/**
* boolean supplier that returns true if Dev Resources are enabled.
* Intended for use with {@link BuildStep#onlyIf()}
*/
public class IsDevResourcesSupportedByLaunchMode implements BooleanSupplier {

private final LaunchMode launchMode;

public IsDevResourcesSupportedByLaunchMode(LaunchMode launchMode) {
this.launchMode = launchMode;
}

@Override
public boolean getAsBoolean() {
return launchMode.isDevResourcesSupported();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package io.quarkus.deployment;

import java.util.function.BooleanSupplier;

import io.quarkus.deployment.annotations.BuildStep;
import io.quarkus.runtime.LaunchMode;

/**
* boolean supplier that returns true if Dev Services are enabled.
* Intended for use with {@link BuildStep#onlyIf()}
*/
public class IsDevServicesSupportedByLaunchMode implements BooleanSupplier {

private final LaunchMode launchMode;

public IsDevServicesSupportedByLaunchMode(LaunchMode launchMode) {
this.launchMode = launchMode;
}

@Override
public boolean getAsBoolean() {
return launchMode.isDevServicesSupported();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package io.quarkus.deployment;

import java.util.function.BooleanSupplier;

import io.quarkus.deployment.annotations.BuildStep;
import io.quarkus.runtime.LaunchMode;

/**
* boolean supplier that returns true if live reload is enabled.
* Intended for use with {@link BuildStep#onlyIf()}
*/
public class IsLiveReloadSupportedByLaunchMode implements BooleanSupplier {

private final LaunchMode launchMode;

public IsLiveReloadSupportedByLaunchMode(LaunchMode launchMode) {
this.launchMode = launchMode;
}

@Override
public boolean getAsBoolean() {
return launchMode.isLiveReloadSupported();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@ public IsNormal(LaunchMode launchMode) {

@Override
public boolean getAsBoolean() {
return launchMode == LaunchMode.NORMAL;
return launchMode == LaunchMode.NORMAL || launchMode == LaunchMode.RUN;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,10 @@ public AugmentActionImpl(CuratedApplication curatedApplication, List<Consumer<Bu
launchMode = LaunchMode.NORMAL;
devModeType = null;
break;
case RUN:
launchMode = LaunchMode.RUN;
devModeType = null;
break;
case TEST:
launchMode = LaunchMode.TEST;
devModeType = null;
Expand Down
31 changes: 27 additions & 4 deletions core/runtime/src/main/java/io/quarkus/runtime/LaunchMode.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,20 @@ public enum LaunchMode {
* A normal production build. At the moment this can be both native image or
* JVM mode, but eventually these will likely be split
*/
NORMAL(LaunchMode.PROD_PROFILE, "quarkus.profile"),
NORMAL(LaunchMode.PROD_PROFILE, "quarkus.profile", false, false),
/**
* A normal production build. At the moment this can be both native image or
* JVM mode, but eventually these will likely be split
*/
RUN(LaunchMode.PROD_PROFILE, "quarkus.profile", true, false),
/**
* quarkus:dev or an IDE launch (when we support IDE launch)
*/
DEVELOPMENT(LaunchMode.DEV_PROFILE, "quarkus.profile"),
DEVELOPMENT(LaunchMode.DEV_PROFILE, "quarkus.profile", true, true),
/**
* a test run
*/
TEST(LaunchMode.TEST_PROFILE, "quarkus.test.profile");
TEST(LaunchMode.TEST_PROFILE, "quarkus.test.profile", true, true);

public static final String DEV_PROFILE = "dev";
public static final String PROD_PROFILE = "prod";
Expand All @@ -36,10 +41,15 @@ public static boolean isRemoteDev() {

private final String defaultProfile;
private final String profileKey;
private final boolean devServicesSupported;
private final boolean liveReloadSupported;

LaunchMode(final String defaultProfile, final String profileKey) {
LaunchMode(final String defaultProfile, final String profileKey, final boolean devServicesSupported,
final boolean liveReloadSupported) {
this.defaultProfile = defaultProfile;
this.profileKey = profileKey;
this.devServicesSupported = devServicesSupported;
this.liveReloadSupported = liveReloadSupported;
}

public String getDefaultProfile() {
Expand All @@ -50,6 +60,19 @@ public String getProfileKey() {
return profileKey;
}

public boolean isDevServicesSupported() {
return devServicesSupported;
}

public boolean isDevResourcesSupported() {
// for now, we support Dev Resources when Dev Services are supported but we have the option to split it later
return devServicesSupported;
}

public boolean isLiveReloadSupported() {
return liveReloadSupported;
}

private static volatile LaunchMode launchMode = LaunchMode.NORMAL;

public static void set(LaunchMode mode) {
Expand Down
4 changes: 2 additions & 2 deletions devtools/maven/src/main/java/io/quarkus/maven/RunMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,12 @@ protected void doExecute() throws MojoExecutionException, MojoFailureException {
}
}

try (CuratedApplication curatedApplication = bootstrapApplication(LaunchMode.NORMAL,
try (CuratedApplication curatedApplication = bootstrapApplication(LaunchMode.RUN,
new Consumer<QuarkusBootstrap.Builder>() {
@Override
public void accept(QuarkusBootstrap.Builder builder) {
// we need this for dev services
builder.setMode(QuarkusBootstrap.Mode.TEST);
builder.setMode(QuarkusBootstrap.Mode.RUN);
}
})) {
AugmentAction action = curatedApplication.createAugmentor();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import io.quarkus.amazon.lambda.runtime.LambdaHotReplacementRecorder;
import io.quarkus.amazon.lambda.runtime.MockEventServer;
import io.quarkus.deployment.Feature;
import io.quarkus.deployment.IsLiveReloadSupportedByLaunchMode;
import io.quarkus.deployment.IsNormal;
import io.quarkus.deployment.annotations.BuildProducer;
import io.quarkus.deployment.annotations.BuildStep;
Expand All @@ -26,7 +27,7 @@
public class DevServicesLambdaProcessor {
private static final Logger log = Logger.getLogger(DevServicesLambdaProcessor.class);

@BuildStep(onlyIfNot = IsNormal.class)
@BuildStep(onlyIf = IsLiveReloadSupportedByLaunchMode.class)
@Record(STATIC_INIT)
public void enableHotReplacementChecker(LaunchModeBuildItem launchMode,
LambdaHotReplacementRecorder recorder,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import io.quarkus.datasource.runtime.DataSourcesBuildTimeConfig;
import io.quarkus.deployment.Capabilities;
import io.quarkus.deployment.Capability;
import io.quarkus.deployment.IsNormal;
import io.quarkus.deployment.IsDevServicesSupportedByLaunchMode;
import io.quarkus.deployment.annotations.BuildProducer;
import io.quarkus.deployment.annotations.BuildStep;
import io.quarkus.deployment.annotations.BuildSteps;
Expand All @@ -42,7 +42,7 @@
import io.quarkus.runtime.LaunchMode;
import io.quarkus.runtime.configuration.ConfigUtils;

@BuildSteps(onlyIfNot = IsNormal.class, onlyIf = DevServicesConfig.Enabled.class)
@BuildSteps(onlyIf = { IsDevServicesSupportedByLaunchMode.class, DevServicesConfig.Enabled.class })
public class DevServicesDatasourceProcessor {

private static final Logger log = Logger.getLogger(DevServicesDatasourceProcessor.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@
import com.github.dockerjava.api.model.Container;
import com.github.dockerjava.api.model.ContainerNetworkSettings;

import io.quarkus.deployment.IsDevServicesSupportedByLaunchMode;
import io.quarkus.deployment.IsDevelopment;
import io.quarkus.deployment.IsNormal;
import io.quarkus.deployment.annotations.BuildProducer;
import io.quarkus.deployment.annotations.BuildStep;
import io.quarkus.deployment.annotations.Produce;
Expand Down Expand Up @@ -89,7 +89,7 @@ public DevServicesNetworkIdBuildItem networkId(
return new DevServicesNetworkIdBuildItem(networkId);
}

@BuildStep(onlyIfNot = IsNormal.class)
@BuildStep(onlyIf = IsDevServicesSupportedByLaunchMode.class)
@Produce(ServiceStartBuildItem.class)
public DevServicesCustomizerBuildItem containerCustomizer(LaunchModeBuildItem launchModeBuildItem,
DevServicesConfig globalDevServicesConfig) {
Expand Down Expand Up @@ -140,7 +140,7 @@ private Optional<String> getSharedNetworkId() {
}
}

@BuildStep(onlyIfNot = IsNormal.class)
@BuildStep(onlyIf = IsDevServicesSupportedByLaunchMode.class)
@Produce(ServiceStartBuildItem.class)
DevServicesRegistryBuildItem devServicesRegistry(LaunchModeBuildItem launchMode,
ApplicationInstanceIdBuildItem applicationId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import org.jboss.logging.Logger;

import io.quarkus.deployment.Feature;
import io.quarkus.deployment.IsNormal;
import io.quarkus.deployment.IsDevServicesSupportedByLaunchMode;
import io.quarkus.deployment.annotations.BuildProducer;
import io.quarkus.deployment.annotations.BuildStep;
import io.quarkus.deployment.annotations.BuildSteps;
Expand Down Expand Up @@ -56,7 +56,7 @@
/**
* Processor that starts the Compose dev services.
*/
@BuildSteps(onlyIfNot = IsNormal.class, onlyIf = DevServicesConfig.Enabled.class)
@BuildSteps(onlyIf = { IsDevServicesSupportedByLaunchMode.class, DevServicesConfig.Enabled.class })
public class ComposeDevServicesProcessor {

private static final Logger log = Logger.getLogger(ComposeDevServicesProcessor.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@
import org.testcontainers.containers.wait.strategy.Wait;
import org.testcontainers.utility.DockerImageName;

import io.quarkus.deployment.IsDevServicesSupportedByLaunchMode;
import io.quarkus.deployment.IsDevelopment;
import io.quarkus.deployment.IsNormal;
import io.quarkus.deployment.annotations.BuildProducer;
import io.quarkus.deployment.annotations.BuildStep;
import io.quarkus.deployment.annotations.BuildSteps;
Expand Down Expand Up @@ -82,7 +82,7 @@
import io.vertx.mutiny.ext.web.client.HttpResponse;
import io.vertx.mutiny.ext.web.client.WebClient;

@BuildSteps(onlyIfNot = IsNormal.class, onlyIf = DevServicesConfig.Enabled.class)
@BuildSteps(onlyIf = { IsDevServicesSupportedByLaunchMode.class, DevServicesConfig.Enabled.class })
public class KeycloakDevServicesProcessor {

private static final Logger LOG = Logger.getLogger(KeycloakDevServicesProcessor.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
import org.jboss.logging.Logger;
import org.jose4j.base64url.Base64Url;

import io.quarkus.deployment.IsNormal;
import io.quarkus.deployment.IsDevServicesSupportedByLaunchMode;
import io.quarkus.deployment.annotations.BuildProducer;
import io.quarkus.deployment.annotations.BuildStep;
import io.quarkus.deployment.annotations.BuildSteps;
Expand All @@ -51,7 +51,7 @@
import io.vertx.mutiny.ext.web.RoutingContext;
import io.vertx.mutiny.ext.web.handler.BodyHandler;

@BuildSteps(onlyIfNot = IsNormal.class, onlyIf = DevServicesConfig.Enabled.class)
@BuildSteps(onlyIf = { IsDevServicesSupportedByLaunchMode.class, DevServicesConfig.Enabled.class })
public class OidcDevServicesProcessor {

private static final Logger LOG = Logger.getLogger(OidcDevServicesProcessor.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

import io.quarkus.builder.BuildException;
import io.quarkus.deployment.Feature;
import io.quarkus.deployment.IsNormal;
import io.quarkus.deployment.IsDevServicesSupportedByLaunchMode;
import io.quarkus.deployment.annotations.BuildStep;
import io.quarkus.deployment.annotations.BuildSteps;
import io.quarkus.deployment.builditem.CuratedApplicationShutdownBuildItem;
Expand All @@ -48,7 +48,7 @@
/**
* Starts an Elasticsearch server as dev service if needed.
*/
@BuildSteps(onlyIfNot = IsNormal.class, onlyIf = DevServicesConfig.Enabled.class)
@BuildSteps(onlyIf = { IsDevServicesSupportedByLaunchMode.class, DevServicesConfig.Enabled.class })
public class DevServicesElasticsearchProcessor {
private static final Logger log = Logger.getLogger(DevServicesElasticsearchProcessor.class);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

import io.quarkus.agroal.spi.JdbcDataSourceSchemaReadyBuildItem;
import io.quarkus.datasource.common.runtime.DataSourceUtil;
import io.quarkus.deployment.IsNormal;
import io.quarkus.deployment.IsDevServicesSupportedByLaunchMode;
import io.quarkus.deployment.annotations.BuildProducer;
import io.quarkus.deployment.annotations.BuildStep;
import io.quarkus.deployment.annotations.BuildSteps;
Expand All @@ -23,7 +23,7 @@
import io.quarkus.hibernate.orm.runtime.HibernateOrmRuntimeConfig;
import io.quarkus.runtime.configuration.ConfigUtils;

@BuildSteps(onlyIf = HibernateOrmEnabled.class, onlyIfNot = IsNormal.class)
@BuildSteps(onlyIf = { IsDevServicesSupportedByLaunchMode.class, HibernateOrmEnabled.class })
public class HibernateOrmDevServicesProcessor {

private static final Logger LOG = Logger.getLogger(HibernateOrmDevServicesProcessor.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
import org.jboss.logging.Logger;

import io.quarkus.arc.deployment.UnremovableBeanBuildItem;
import io.quarkus.deployment.IsNormal;
import io.quarkus.deployment.IsDevServicesSupportedByLaunchMode;
import io.quarkus.deployment.annotations.BuildProducer;
import io.quarkus.deployment.annotations.BuildStep;
import io.quarkus.deployment.annotations.BuildSteps;
Expand Down Expand Up @@ -261,7 +261,7 @@ void setRuntimeConfig(HibernateSearchElasticsearchRecorder recorder,
}
}

@BuildStep(onlyIfNot = IsNormal.class)
@BuildStep(onlyIf = IsDevServicesSupportedByLaunchMode.class)
DevservicesElasticsearchBuildItem devServices(HibernateSearchElasticsearchBuildTimeConfig buildTimeConfig) {
var defaultPUConfig = buildTimeConfig.persistenceUnits().get(PersistenceUnitUtil.DEFAULT_PERSISTENCE_UNIT_NAME);
if (defaultPUConfig == null) {
Expand Down Expand Up @@ -289,7 +289,7 @@ DevservicesElasticsearchBuildItem devServices(HibernateSearchElasticsearchBuildT
Distribution.valueOf(version.distribution().toString().toUpperCase()));
}

@BuildStep(onlyIfNot = IsNormal.class)
@BuildStep(onlyIf = IsDevServicesSupportedByLaunchMode.class)
void devServicesDropAndCreateAndDropByDefault(
List<HibernateSearchElasticsearchPersistenceUnitConfiguredBuildItem> configuredPersistenceUnits,
BuildProducer<DevServicesAdditionalConfigBuildItem> devServicesAdditionalConfigProducer) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
import io.quarkus.arc.deployment.BeanDefiningAnnotationBuildItem;
import io.quarkus.arc.deployment.SyntheticBeanBuildItem;
import io.quarkus.arc.processor.DotNames;
import io.quarkus.deployment.IsNormal;
import io.quarkus.deployment.IsDevServicesSupportedByLaunchMode;
import io.quarkus.deployment.annotations.BuildProducer;
import io.quarkus.deployment.annotations.BuildStep;
import io.quarkus.deployment.annotations.BuildSteps;
Expand Down Expand Up @@ -210,7 +210,7 @@ void boot(Optional<HibernateSearchStandaloneEnabledBuildItem> enabled,
serviceStart.produce(new ServiceStartBuildItem("Hibernate Search Standalone"));
}

@BuildStep(onlyIfNot = IsNormal.class)
@BuildStep(onlyIf = IsDevServicesSupportedByLaunchMode.class)
void devServices(Optional<HibernateSearchStandaloneEnabledBuildItem> enabled,
HibernateSearchStandaloneBuildTimeConfig buildTimeConfig,
BuildProducer<DevservicesElasticsearchBuildItem> buildItemBuildProducer,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import org.testcontainers.containers.BindMode;

import io.quarkus.deployment.Feature;
import io.quarkus.deployment.IsNormal;
import io.quarkus.deployment.IsDevServicesSupportedByLaunchMode;
import io.quarkus.deployment.annotations.BuildStep;
import io.quarkus.deployment.annotations.BuildSteps;
import io.quarkus.deployment.builditem.CuratedApplicationShutdownBuildItem;
Expand All @@ -49,7 +49,7 @@
import io.quarkus.runtime.LaunchMode;
import io.quarkus.runtime.configuration.ConfigUtils;

@BuildSteps(onlyIfNot = IsNormal.class, onlyIf = DevServicesConfig.Enabled.class)
@BuildSteps(onlyIf = { IsDevServicesSupportedByLaunchMode.class, DevServicesConfig.Enabled.class })
public class InfinispanDevServiceProcessor {
private static final Logger log = Logger.getLogger(InfinispanDevServiceProcessor.class);

Expand Down
Loading
Loading