mirror of
https://github.com/ethauvin/rife2-hello.git
synced 2025-04-29 08:58:12 -07:00
Compare commits
No commits in common. "7a3d44a4121cdbc8556cf56c387bb98ba8546af3" and "3a9bbec85113c5f9bf1591d50d34207ef7e7c47f" have entirely different histories.
7a3d44a412
...
3a9bbec851
10 changed files with 120 additions and 73 deletions
23
.github/workflows/gradle.yml
vendored
23
.github/workflows/gradle.yml
vendored
|
@ -11,7 +11,7 @@ jobs:
|
||||||
|
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
java-version: [ 17, 19 ]
|
java-version: [ 17 ]
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout source repository
|
- name: Checkout source repository
|
||||||
|
@ -20,7 +20,7 @@ jobs:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
|
|
||||||
- name: Set up JDK ${{ matrix.java-version }}
|
- name: Set up JDK ${{ matrix.java-version }}
|
||||||
uses: actions/setup-java@v3
|
uses: actions/setup-java@v2
|
||||||
with:
|
with:
|
||||||
distribution: 'temurin'
|
distribution: 'temurin'
|
||||||
java-version: ${{ matrix.java-version }}
|
java-version: ${{ matrix.java-version }}
|
||||||
|
@ -28,7 +28,20 @@ jobs:
|
||||||
- name: Grant execute permission for gradlew
|
- name: Grant execute permission for gradlew
|
||||||
run: chmod +x gradlew
|
run: chmod +x gradlew
|
||||||
|
|
||||||
- name: Test with Gradle
|
- name: Cache Gradle packages
|
||||||
uses: gradle/gradle-build-action@v2
|
uses: actions/cache@v2
|
||||||
with:
|
with:
|
||||||
arguments: build check --stacktrace
|
path: |
|
||||||
|
~/.gradle/caches
|
||||||
|
~/.gradle/wrapper
|
||||||
|
key: ${{ runner.os }}-gradle-${{ matrix.java-version }}-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
|
||||||
|
restore-keys: |
|
||||||
|
${{ runner.os }}-gradle-${{ matrix.java-version }}-
|
||||||
|
|
||||||
|
- name: Test with Gradle
|
||||||
|
run: ./gradlew build check --stacktrace
|
||||||
|
|
||||||
|
- name: Cleanup Gradle Cache
|
||||||
|
run: |
|
||||||
|
rm -f ~/.gradle/caches/modules-2/modules-2.lock
|
||||||
|
rm -f ~/.gradle/caches/modules-2/gc.properties
|
15
README.md
15
README.md
|
@ -92,23 +92,18 @@ GraalVM supports creating a single Ahead-Of-Time
|
||||||
[native executable](https://www.graalvm.org/native-image/) from your java
|
[native executable](https://www.graalvm.org/native-image/) from your java
|
||||||
bytecode.
|
bytecode.
|
||||||
|
|
||||||
Once you have at least GraalVM 22.3.1 Java 17 installed, you can generate the native binary with:
|
Once you have at least GraalVM 22.3.1 Java 19 installed, you can generate the
|
||||||
|
UberJar as above, then create your native binary as such:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
./gradlew nativeCompile
|
native-image --no-fallback --enable-preview -jar app/build/libs/hello-uber-1.0.jar
|
||||||
```
|
```
|
||||||
|
|
||||||
You'll end up with a `hello-1.0` file that can be executed directly without
|
You'll end up with a `hello-uber-1.0` file that can be executed directly without
|
||||||
the need of a JVM:
|
the need of a JVM:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
./app/build/native/nativeCompile/hello-1.0
|
./hello-uber-1.0
|
||||||
```
|
|
||||||
|
|
||||||
Alternatively, you can run the native executable directly with:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
./gradlew nativeRun
|
|
||||||
```
|
```
|
||||||
|
|
||||||
> **NOTE:** RIFE2 support for GraalVM native-image is still in preliminary
|
> **NOTE:** RIFE2 support for GraalVM native-image is still in preliminary
|
||||||
|
|
|
@ -1,32 +1,13 @@
|
||||||
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
|
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
|
||||||
import org.gradle.api.tasks.testing.logging.TestLogEvent
|
import org.gradle.api.tasks.testing.logging.TestLogEvent
|
||||||
import com.uwyn.rife2.gradle.TemplateType.*
|
|
||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
application
|
java
|
||||||
id("com.uwyn.rife2") version "1.0.6"
|
|
||||||
`maven-publish`
|
|
||||||
id("org.graalvm.buildtools.native") version "0.9.20"
|
|
||||||
}
|
|
||||||
|
|
||||||
version = 1.0
|
|
||||||
group = "com.example"
|
|
||||||
|
|
||||||
rife2 {
|
|
||||||
version.set("1.4.0")
|
|
||||||
uberMainClass.set("hello.AppUber")
|
|
||||||
useAgent.set(true)
|
|
||||||
precompiledTemplateTypes.add(HTML)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
base {
|
base {
|
||||||
archivesName.set("hello")
|
archivesName.set("hello")
|
||||||
}
|
version = 1.0
|
||||||
|
|
||||||
java {
|
|
||||||
toolchain {
|
|
||||||
languageVersion.set(JavaLanguageVersion.of(17))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
|
@ -35,40 +16,90 @@ repositories {
|
||||||
maven { url = uri("https://s01.oss.sonatype.org/content/repositories/snapshots") } // only needed for SNAPSHOT
|
maven { url = uri("https://s01.oss.sonatype.org/content/repositories/snapshots") } // only needed for SNAPSHOT
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sourceSets {
|
||||||
|
main {
|
||||||
|
runtimeClasspath = files(file("src/main/resources"), runtimeClasspath);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
sourceSets.main {
|
||||||
|
resources.exclude("templates/**")
|
||||||
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
|
implementation("com.uwyn.rife2:rife2:1.3.0")
|
||||||
|
runtimeOnly("com.uwyn.rife2:rife2:1.3.0: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")
|
||||||
|
|
||||||
testImplementation("org.jsoup:jsoup:1.15.3")
|
testImplementation("org.jsoup:jsoup:1.15.3")
|
||||||
testImplementation("org.junit.jupiter:junit-jupiter:5.9.1")
|
testImplementation("org.junit.jupiter:junit-jupiter:5.9.1")
|
||||||
}
|
}
|
||||||
|
|
||||||
application {
|
|
||||||
mainClass.set("hello.App")
|
|
||||||
}
|
|
||||||
|
|
||||||
tasks {
|
tasks {
|
||||||
|
val dependencies = configurations
|
||||||
|
.runtimeClasspath.get().files;
|
||||||
|
val rifeAgentJar = dependencies
|
||||||
|
.filter { it.toString().contains("rife2") }
|
||||||
|
.filter { it.toString().endsWith("-agent.jar") }[0]
|
||||||
|
|
||||||
test {
|
test {
|
||||||
|
jvmArgs = listOf("-javaagent:$rifeAgentJar")
|
||||||
useJUnitPlatform()
|
useJUnitPlatform()
|
||||||
testLogging {
|
testLogging {
|
||||||
exceptionFormat = TestExceptionFormat.FULL
|
exceptionFormat = TestExceptionFormat.FULL
|
||||||
events = setOf(TestLogEvent.PASSED, TestLogEvent.SKIPPED, TestLogEvent.FAILED)
|
events = setOf(TestLogEvent.PASSED, TestLogEvent.SKIPPED, TestLogEvent.FAILED)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
publishing {
|
// Pre-compile the RIFE2 templates to bytecode for deployment
|
||||||
repositories {
|
register<JavaExec>("precompileHtmlTemplates") {
|
||||||
maven {
|
classpath = sourceSets["main"].runtimeClasspath
|
||||||
name = "Build"
|
mainClass.set("rife.template.TemplateDeployer")
|
||||||
url = uri(rootProject.layout.buildDirectory.dir("repo"))
|
args = listOf(
|
||||||
}
|
"-verbose",
|
||||||
|
"-t", "html",
|
||||||
|
"-d", "${projectDir}/build/classes/java/main",
|
||||||
|
"-encoding", "UTF-8", "${projectDir}/src/main/resources/templates"
|
||||||
|
)
|
||||||
}
|
}
|
||||||
publications {
|
|
||||||
create<MavenPublication>("maven") {
|
|
||||||
from(components["java"])
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
graalvmNative.binaries.all {
|
register("precompileTemplates") {
|
||||||
buildArgs.add("--enable-preview") // support for Jetty virtual threads with JDK 19
|
dependsOn("precompileHtmlTemplates")
|
||||||
imageName.set("hello-$version")
|
}
|
||||||
}
|
|
||||||
|
// Ensure that the templates are pre-compiled before building the jar
|
||||||
|
jar {
|
||||||
|
dependsOn("precompileTemplates")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Replace the run task with one that uses the RIFE2 agent
|
||||||
|
register<JavaExec>("run") {
|
||||||
|
classpath = sourceSets["main"].runtimeClasspath
|
||||||
|
mainClass.set("hello.App")
|
||||||
|
jvmArgs = listOf("-javaagent:$rifeAgentJar")
|
||||||
|
}
|
||||||
|
|
||||||
|
// These two tasks create a self-container UberJar
|
||||||
|
register<Copy>("copyWebapp") {
|
||||||
|
from("src/main/")
|
||||||
|
include("webapp/**")
|
||||||
|
into("$buildDir/webapp")
|
||||||
|
}
|
||||||
|
|
||||||
|
register<Jar>("uberJar") {
|
||||||
|
dependsOn("jar")
|
||||||
|
dependsOn("copyWebapp")
|
||||||
|
archiveBaseName.set("hello-uber")
|
||||||
|
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
|
||||||
|
manifest {
|
||||||
|
attributes["Main-Class"] = "hello.AppUber"
|
||||||
|
}
|
||||||
|
val uberDependencies = dependencies
|
||||||
|
.filter { !it.toString().matches("rife2-.*agent\\.jar".toRegex()) }
|
||||||
|
.map(::zipTree)
|
||||||
|
from(uberDependencies, "$buildDir/webapp")
|
||||||
|
with(jar.get())
|
||||||
|
}
|
||||||
|
}
|
|
@ -13,4 +13,4 @@ public class App extends Site {
|
||||||
.staticResourceBase("src/main/webapp")
|
.staticResourceBase("src/main/webapp")
|
||||||
.start(new App());
|
.start(new App());
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,6 +1,6 @@
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
"name":"rife.template.html.hello",
|
"name":"rife.template.html.hello",
|
||||||
"methods":[{"name":"<init>","parameterTypes":[] }]
|
"methods":[{"name":"<init>","parameterTypes":[] }]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
|
@ -0,0 +1,8 @@
|
||||||
|
{
|
||||||
|
"resources":{
|
||||||
|
"includes":[
|
||||||
|
{"pattern":"^webapp/.*$"}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"bundles":[]
|
||||||
|
}
|
|
@ -8,4 +8,4 @@
|
||||||
<body>
|
<body>
|
||||||
<p>Hello World</p>
|
<p>Hello World</p>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
|
@ -1,2 +0,0 @@
|
||||||
org.gradle.parallel=true
|
|
||||||
org.gradle.caching=true
|
|
|
@ -1,9 +1,11 @@
|
||||||
pluginManagement {
|
/*
|
||||||
repositories {
|
* This file was generated by the Gradle 'init' task.
|
||||||
mavenCentral()
|
*
|
||||||
gradlePluginPortal()
|
* The settings file is used to specify which projects to include in your build.
|
||||||
}
|
*
|
||||||
}
|
* Detailed information about configuring a multi-project build in Gradle can be found
|
||||||
|
* in the user manual at https://docs.gradle.org/7.6/userguide/multi_project_builds.html
|
||||||
|
*/
|
||||||
|
|
||||||
rootProject.name = "hello"
|
rootProject.name = "hello"
|
||||||
include("app","war")
|
include("app","war")
|
||||||
|
|
|
@ -2,10 +2,9 @@ plugins {
|
||||||
war
|
war
|
||||||
}
|
}
|
||||||
|
|
||||||
version = 1.0
|
|
||||||
|
|
||||||
base {
|
base {
|
||||||
archivesName.set("hello")
|
archivesName.set("hello")
|
||||||
|
version = 1.0
|
||||||
}
|
}
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
|
@ -20,4 +19,5 @@ dependencies {
|
||||||
tasks.war {
|
tasks.war {
|
||||||
webAppDirectory.set(file("../app/src/main/webapp"))
|
webAppDirectory.set(file("../app/src/main/webapp"))
|
||||||
webXml = file("src/web.xml")
|
webXml = file("src/web.xml")
|
||||||
|
rootSpec.exclude("**/jetty*.jar", "**/slf4j*.jar", "**/rife2*-agent.jar")
|
||||||
}
|
}
|
Loading…
Add table
Add a link
Reference in a new issue