-
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.
Showing
12 changed files
with
338 additions
and
30 deletions.
There are no files selected for viewing
48 changes: 48 additions & 0 deletions
48
core/deployment/src/main/java/io/quarkus/deployment/configuration/ClassLoadingConfig.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,48 @@ | ||
package io.quarkus.deployment.configuration; | ||
|
||
import java.util.Optional; | ||
|
||
import io.quarkus.runtime.annotations.ConfigItem; | ||
import io.quarkus.runtime.annotations.ConfigPhase; | ||
import io.quarkus.runtime.annotations.ConfigRoot; | ||
|
||
/** | ||
* WARNING: This is not normal quarkus config, this is only read from application.properties. | ||
* <p> | ||
* This is because it is needed before any of the config infrastructure is setup. | ||
*/ | ||
@ConfigRoot(phase = ConfigPhase.BUILD_TIME) | ||
public class ClassLoadingConfig { | ||
|
||
/** | ||
* Artifacts that are loaded in a parent first manner. This can be used to work around issues where a given | ||
* class needs to be loaded by the system ClassLoader. Note that if you | ||
* make a library parent first all its dependencies should generally also be parent first. | ||
* <p> | ||
* Artifacts should be configured as a comma separated list of artifact ids, with the group, artifact-id and optional | ||
* classifier separated by a colon. | ||
* <p> | ||
* WARNING: This config property can only be set in application.properties | ||
*/ | ||
@ConfigItem(defaultValue = "") | ||
public Optional<String> parentFirstArtifacts; | ||
|
||
/** | ||
* Artifacts that are loaded in the runtime ClassLoader in dev mode, so they will be dropped | ||
* and recreated on change. | ||
* <p> | ||
* This is an advanced option, it should only be used if you have a problem with | ||
* libraries holding stale state between reloads. Note that if you use this any library that depends on the listed libraries | ||
* will also need to be reloadable. | ||
* <p> | ||
* This setting has no impact on production builds. | ||
* <p> | ||
* Artifacts should be configured as a comma separated list of artifact ids, with the group, artifact-id and optional | ||
* classifier separated by a colon. | ||
* <p> | ||
* WARNING: This config property can only be set in application.properties | ||
*/ | ||
@ConfigItem(defaultValue = "") | ||
public Optional<String> reloadableArtifacts; | ||
|
||
} |
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
34 changes: 34 additions & 0 deletions
34
...x-http/deployment/src/test/java/io/quarkus/vertx/http/devmode/LiveReloadArtifactTest.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,34 @@ | ||
package io.quarkus.vertx.http.devmode; | ||
|
||
import org.jboss.shrinkwrap.api.ShrinkWrap; | ||
import org.jboss.shrinkwrap.api.asset.StringAsset; | ||
import org.jboss.shrinkwrap.api.spec.JavaArchive; | ||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import io.quarkus.test.QuarkusDevModeTest; | ||
import io.restassured.RestAssured; | ||
|
||
/** | ||
* tests the reload-dependencies option | ||
*/ | ||
public class LiveReloadArtifactTest { | ||
|
||
@RegisterExtension | ||
static final QuarkusDevModeTest test = new QuarkusDevModeTest() | ||
.setArchiveProducer(() -> ShrinkWrap.create(JavaArchive.class) | ||
.addAsResource(new StringAsset("quarkus.class-loading.reloadable-artifacts=io.vertx:vertx-web-client\n"), | ||
"application.properties") | ||
.addClasses(LiveReloadEndpoint.class)); | ||
|
||
@Test | ||
public void test() { | ||
String firstClassToString = RestAssured.get("/test").then().statusCode(200).extract().body().asString(); | ||
test.modifySourceFile(LiveReloadEndpoint.class, s -> s.replace("\"/test\"", "\"/test2\"")); | ||
|
||
String secondClassToString = RestAssured.get("/test2").then().statusCode(200).extract().body().asString(); | ||
Assertions.assertNotEquals(firstClassToString, secondClassToString); | ||
} | ||
|
||
} |
26 changes: 26 additions & 0 deletions
26
...vertx-http/deployment/src/test/java/io/quarkus/vertx/http/devmode/LiveReloadEndpoint.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,26 @@ | ||
package io.quarkus.vertx.http.devmode; | ||
|
||
import javax.enterprise.context.ApplicationScoped; | ||
import javax.enterprise.event.Observes; | ||
import javax.inject.Inject; | ||
import javax.inject.Named; | ||
|
||
import io.quarkus.vertx.http.runtime.HttpBuildTimeConfig; | ||
import io.vertx.ext.web.Router; | ||
import io.vertx.ext.web.client.HttpRequest; | ||
import io.vertx.ext.web.client.WebClient; | ||
|
||
@Named | ||
@ApplicationScoped | ||
public class LiveReloadEndpoint { | ||
|
||
@Inject | ||
HttpBuildTimeConfig httpConfig; | ||
|
||
void addConfigRoute(@Observes Router router) { | ||
router.route("/test") | ||
.produces("text/plain") | ||
.handler(rc -> rc.response().end(WebClient.class.hashCode() + "-" + HttpRequest.class.hashCode())); | ||
} | ||
|
||
} |
31 changes: 31 additions & 0 deletions
31
...-http/deployment/src/test/java/io/quarkus/vertx/http/devmode/ParentFirstArtifactTest.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,31 @@ | ||
package io.quarkus.vertx.http.devmode; | ||
|
||
import org.jboss.shrinkwrap.api.ShrinkWrap; | ||
import org.jboss.shrinkwrap.api.asset.StringAsset; | ||
import org.jboss.shrinkwrap.api.spec.JavaArchive; | ||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import io.quarkus.test.QuarkusDevModeTest; | ||
import io.restassured.RestAssured; | ||
|
||
/** | ||
* tests the parent first artifacts option | ||
*/ | ||
public class ParentFirstArtifactTest { | ||
|
||
@RegisterExtension | ||
static final QuarkusDevModeTest test = new QuarkusDevModeTest() | ||
.setArchiveProducer(() -> ShrinkWrap.create(JavaArchive.class) | ||
.addAsResource(new StringAsset("quarkus.class-loading.parent-first-artifacts=io.vertx:vertx-web-client\n"), | ||
"application.properties") | ||
.addClasses(ParentFirstEndpoint.class)); | ||
|
||
@Test | ||
public void test() { | ||
String firstClassToString = RestAssured.get("/test").then().statusCode(200).extract().body().asString(); | ||
Assertions.assertEquals("false", firstClassToString); | ||
} | ||
|
||
} |
27 changes: 27 additions & 0 deletions
27
...ertx-http/deployment/src/test/java/io/quarkus/vertx/http/devmode/ParentFirstEndpoint.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,27 @@ | ||
package io.quarkus.vertx.http.devmode; | ||
|
||
import javax.enterprise.context.ApplicationScoped; | ||
import javax.enterprise.event.Observes; | ||
import javax.inject.Inject; | ||
import javax.inject.Named; | ||
|
||
import io.quarkus.bootstrap.classloading.QuarkusClassLoader; | ||
import io.quarkus.vertx.http.runtime.HttpBuildTimeConfig; | ||
import io.vertx.ext.web.Router; | ||
import io.vertx.ext.web.client.WebClient; | ||
|
||
@Named | ||
@ApplicationScoped | ||
public class ParentFirstEndpoint { | ||
|
||
@Inject | ||
HttpBuildTimeConfig httpConfig; | ||
|
||
void addConfigRoute(@Observes Router router) { | ||
router.route("/test") | ||
.produces("text/plain") | ||
.handler(rc -> rc.response() | ||
.end(WebClient.class.getClassLoader() instanceof QuarkusClassLoader ? "true" : "false")); | ||
} | ||
|
||
} |
65 changes: 65 additions & 0 deletions
65
...dent-projects/bootstrap/core/src/main/java/io/quarkus/bootstrap/app/BootstrapProfile.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,65 @@ | ||
package io.quarkus.bootstrap.app; | ||
|
||
/** | ||
* Mirror of the logic in ProfileManager, but this is needed pre-bootstrap so there is nowhere to really share it. | ||
* | ||
* This is only used for reading the class loading config | ||
*/ | ||
public class BootstrapProfile { | ||
|
||
public static final String QUARKUS_PROFILE_ENV = "QUARKUS_PROFILE"; | ||
public static final String QUARKUS_PROFILE_PROP = "quarkus.profile"; | ||
public static final String QUARKUS_TEST_PROFILE_PROP = "quarkus.test.profile"; | ||
private static final String BACKWARD_COMPATIBLE_QUARKUS_PROFILE_PROP = "quarkus-profile"; | ||
public static final String DEV = "dev"; | ||
public static final String PROD = "prod"; | ||
public static final String TEST = "test"; | ||
|
||
private static String runtimeDefaultProfile = null; | ||
|
||
public static void setRuntimeDefaultProfile(final String profile) { | ||
runtimeDefaultProfile = profile; | ||
} | ||
|
||
public static String getActiveProfile(QuarkusBootstrap.Mode mode) { | ||
if (mode == QuarkusBootstrap.Mode.TEST) { | ||
String profile = System.getProperty(QUARKUS_TEST_PROFILE_PROP); | ||
if (profile != null) { | ||
return profile; | ||
} | ||
return "test"; | ||
} | ||
|
||
String profile = System.getProperty(QUARKUS_PROFILE_PROP); | ||
if (profile != null) { | ||
return profile; | ||
} | ||
|
||
profile = System.getProperty(BACKWARD_COMPATIBLE_QUARKUS_PROFILE_PROP); | ||
if (profile != null) { | ||
return profile; | ||
} | ||
|
||
profile = System.getenv(QUARKUS_PROFILE_ENV); | ||
if (profile != null) { | ||
return profile; | ||
} | ||
|
||
profile = runtimeDefaultProfile; | ||
if (profile != null) { | ||
return profile; | ||
} | ||
switch (mode) { | ||
case REMOTE_DEV_SERVER: | ||
case DEV: | ||
return DEV; | ||
case REMOTE_DEV_CLIENT: | ||
case PROD: | ||
return PROD; | ||
case TEST: | ||
return TEST; | ||
default: | ||
throw new RuntimeException("unknown mode:" + mode); | ||
} | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
...rojects/bootstrap/core/src/main/java/io/quarkus/bootstrap/app/ConfiguredClassLoading.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,16 @@ | ||
package io.quarkus.bootstrap.app; | ||
|
||
import io.quarkus.bootstrap.model.AppArtifactKey; | ||
import java.io.Serializable; | ||
import java.util.Set; | ||
|
||
public class ConfiguredClassLoading implements Serializable { | ||
|
||
public final Set<AppArtifactKey> parentFirstArtifacts; | ||
public final Set<AppArtifactKey> reloadableArtifacts; | ||
|
||
public ConfiguredClassLoading(Set<AppArtifactKey> parentFirstArtifacts, Set<AppArtifactKey> reloadableArtifacts) { | ||
this.parentFirstArtifacts = parentFirstArtifacts; | ||
this.reloadableArtifacts = reloadableArtifacts; | ||
} | ||
} |
Oops, something went wrong.