From 44637cc6fc2c2bc6690fb6812fe282007282a45a Mon Sep 17 00:00:00 2001 From: Geert Bevin Date: Mon, 13 Feb 2023 08:30:34 -0500 Subject: [PATCH] Updated for RIFE2 1.1.1. Added RIFE2 agent and relevant instructions. Improved README. --- README.md | 28 +++++++++++++++++++++++++++- app/build.gradle.kts | 22 ++++++++++++++-------- war/build.gradle.kts | 2 +- 3 files changed, 42 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 079e257..47258fb 100644 --- a/README.md +++ b/README.md @@ -42,6 +42,10 @@ Go to: The resulting archive will be in: `war/build/libs` +If you use any of the byte-code instrumented features , like continuations, +metadata merging or lazy-loaded database entities, you'll need to launch your +servlet container with the `-javaagent:[path-to]/rife2-*-agent.jar` argument. +Exactly how is dependent on each servlet container. ## Making an UberJar @@ -54,4 +58,26 @@ Then run it with: ```bash java -jar app/build/libs/hello-uber-1.0.jar -``` \ No newline at end of file +``` + +If you use any of the byte-code instrumented features, you'll need to also tell +`java` to use the RIFE2 agent. + +For example: + +```bash +java -javaagent:[path-to]/rife2-*-agent.jar -jar app/build/libs/hello-uber-1.0.jar +``` + +## Get in touch + +Thanks for using RIFE2! + +If you have any questions, suggestions, ideas or just want to chat, feel free +to post on the [forums](https://github.com/gbevin/rife2/discussions), to join +me on [Discord](https://discord.gg/DZRYPtkb6J) or to connect with me on +[Mastodon](https://uwyn.net/@gbevin). + + +**Read more in the [full documentation](https://github.com/gbevin/rife2/wiki) +and [RIFE2 Javadocs](https://gbevin.github.io/rife2/).** diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 72ca334..b7a96de 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -2,8 +2,7 @@ import org.gradle.api.tasks.testing.logging.TestExceptionFormat import org.gradle.api.tasks.testing.logging.TestLogEvent plugins { - // Apply the application plugin to add support for building a CLI application in Java. - application + java } base { @@ -28,7 +27,8 @@ sourceSets.main { } dependencies { - implementation("com.uwyn.rife2:rife2:1.1.0") + implementation("com.uwyn.rife2:rife2:1.1.1") + runtimeOnly("com.uwyn.rife2:rife2:1.1.1:agent") runtimeOnly("org.eclipse.jetty:jetty-server:11.0.13") runtimeOnly("org.eclipse.jetty:jetty-servlet:11.0.13") runtimeOnly("org.slf4j:slf4j-simple:2.0.5") @@ -37,11 +37,6 @@ dependencies { testImplementation("org.junit.jupiter:junit-jupiter:5.9.1") } -application { - // Define the main class for the application. - mainClass.set("hello.App") -} - tasks { named("test") { useJUnitPlatform() @@ -72,6 +67,16 @@ tasks { dependsOn("precompileTemplates") } + // Replace the run task with one that uses the RIFE2 agent + register("run") { + classpath = sourceSets["main"].runtimeClasspath + mainClass.set("hello.App") + val rifeAgentJar = configurations.runtimeClasspath.get().files + .filter { it.toString().contains("rife2") } + .filter { it.toString().endsWith("-agent.jar") }[0] + jvmArgs = listOf("-javaagent:$rifeAgentJar") + } + // These two tasks create a self-container UberJar register("copyWebapp") { from("src/main/") @@ -89,6 +94,7 @@ tasks { } val dependencies = configurations .runtimeClasspath.get() + .exclude("**/rife2*-agent.jar") .map(::zipTree) from(dependencies, "$buildDir/webapp") with(jar.get()) diff --git a/war/build.gradle.kts b/war/build.gradle.kts index 78639a2..206f003 100644 --- a/war/build.gradle.kts +++ b/war/build.gradle.kts @@ -19,5 +19,5 @@ dependencies { tasks.war { webAppDirectory.set(file("../app/src/main/webapp")) webXml = file("src/web.xml") - rootSpec.exclude("**/jetty*.jar", "**/slf4j*.jar") + rootSpec.exclude("**/jetty*.jar", "**/slf4j*.jar", "**/rife2*-agent.jar") } \ No newline at end of file