mirror of
https://github.com/ethauvin/rife2-hello.git
synced 2025-04-28 16:38:12 -07:00
Compare commits
51 commits
3a9bbec851
...
7a3d44a412
Author | SHA1 | Date | |
---|---|---|---|
7a3d44a412 | |||
4999c040c0 | |||
a39fb686c3 | |||
7e1dcd82ec | |||
f10a228097 | |||
8e249a3f50 | |||
e3df16c5df | |||
122db8a40e | |||
b74de8c59a | |||
02d5b610be | |||
fbad18e011 | |||
f777a40a99 | |||
d4f9bb9ad4 | |||
e97239207a | |||
6bb4fcedd4 | |||
17a6fee9bb | |||
7f82944093 | |||
794f614e57 | |||
1d45241fae | |||
938372addc | |||
a3a5c7c380 | |||
b51e36ee73 | |||
83e52c0e06 | |||
|
d06124c26d | ||
|
a79e616d79 | ||
de5c974f15 | |||
0a2b061679 | |||
|
21c85ea93b | ||
cf4870745c | |||
5ca1fa305b | |||
d8c41b45d9 | |||
|
c9f286132c | ||
|
65e579966c | ||
86b7ec21d9 | |||
aeaadfb1cc | |||
ed8046e83d | |||
c8f47a935e | |||
d3dedfe189 | |||
a54ab9b23e | |||
f8b3078ba1 | |||
57a604c599 | |||
c33235a1ac | |||
269971663b | |||
d954e75cf5 | |||
834c75492b | |||
5e70147765 | |||
|
f6deafda3a | ||
|
c8b3cc7890 | ||
0d3f587bb4 | |||
e02ed25b5a | |||
|
2e025cd693 |
10 changed files with 73 additions and 120 deletions
23
.github/workflows/gradle.yml
vendored
23
.github/workflows/gradle.yml
vendored
|
@ -11,7 +11,7 @@ jobs:
|
|||
|
||||
strategy:
|
||||
matrix:
|
||||
java-version: [ 17 ]
|
||||
java-version: [ 17, 19 ]
|
||||
|
||||
steps:
|
||||
- name: Checkout source repository
|
||||
|
@ -20,7 +20,7 @@ jobs:
|
|||
fetch-depth: 0
|
||||
|
||||
- name: Set up JDK ${{ matrix.java-version }}
|
||||
uses: actions/setup-java@v2
|
||||
uses: actions/setup-java@v3
|
||||
with:
|
||||
distribution: 'temurin'
|
||||
java-version: ${{ matrix.java-version }}
|
||||
|
@ -28,20 +28,7 @@ jobs:
|
|||
- name: Grant execute permission for gradlew
|
||||
run: chmod +x gradlew
|
||||
|
||||
- name: Cache Gradle packages
|
||||
uses: actions/cache@v2
|
||||
with:
|
||||
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
|
||||
uses: gradle/gradle-build-action@v2
|
||||
with:
|
||||
arguments: build check --stacktrace
|
15
README.md
15
README.md
|
@ -92,18 +92,23 @@ GraalVM supports creating a single Ahead-Of-Time
|
|||
[native executable](https://www.graalvm.org/native-image/) from your java
|
||||
bytecode.
|
||||
|
||||
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:
|
||||
Once you have at least GraalVM 22.3.1 Java 17 installed, you can generate the native binary with:
|
||||
|
||||
```bash
|
||||
native-image --no-fallback --enable-preview -jar app/build/libs/hello-uber-1.0.jar
|
||||
./gradlew nativeCompile
|
||||
```
|
||||
|
||||
You'll end up with a `hello-uber-1.0` file that can be executed directly without
|
||||
You'll end up with a `hello-1.0` file that can be executed directly without
|
||||
the need of a JVM:
|
||||
|
||||
```bash
|
||||
./hello-uber-1.0
|
||||
./app/build/native/nativeCompile/hello-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
|
||||
|
|
|
@ -1,13 +1,32 @@
|
|||
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
|
||||
import org.gradle.api.tasks.testing.logging.TestLogEvent
|
||||
import com.uwyn.rife2.gradle.TemplateType.*
|
||||
|
||||
plugins {
|
||||
java
|
||||
application
|
||||
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 {
|
||||
archivesName.set("hello")
|
||||
version = 1.0
|
||||
}
|
||||
|
||||
java {
|
||||
toolchain {
|
||||
languageVersion.set(JavaLanguageVersion.of(17))
|
||||
}
|
||||
}
|
||||
|
||||
repositories {
|
||||
|
@ -16,90 +35,40 @@ repositories {
|
|||
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 {
|
||||
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.junit.jupiter:junit-jupiter:5.9.1")
|
||||
}
|
||||
|
||||
tasks {
|
||||
val dependencies = configurations
|
||||
.runtimeClasspath.get().files;
|
||||
val rifeAgentJar = dependencies
|
||||
.filter { it.toString().contains("rife2") }
|
||||
.filter { it.toString().endsWith("-agent.jar") }[0]
|
||||
application {
|
||||
mainClass.set("hello.App")
|
||||
}
|
||||
|
||||
tasks {
|
||||
test {
|
||||
jvmArgs = listOf("-javaagent:$rifeAgentJar")
|
||||
useJUnitPlatform()
|
||||
testLogging {
|
||||
exceptionFormat = TestExceptionFormat.FULL
|
||||
events = setOf(TestLogEvent.PASSED, TestLogEvent.SKIPPED, TestLogEvent.FAILED)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Pre-compile the RIFE2 templates to bytecode for deployment
|
||||
register<JavaExec>("precompileHtmlTemplates") {
|
||||
classpath = sourceSets["main"].runtimeClasspath
|
||||
mainClass.set("rife.template.TemplateDeployer")
|
||||
args = listOf(
|
||||
"-verbose",
|
||||
"-t", "html",
|
||||
"-d", "${projectDir}/build/classes/java/main",
|
||||
"-encoding", "UTF-8", "${projectDir}/src/main/resources/templates"
|
||||
)
|
||||
}
|
||||
|
||||
register("precompileTemplates") {
|
||||
dependsOn("precompileHtmlTemplates")
|
||||
}
|
||||
|
||||
// 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"
|
||||
publishing {
|
||||
repositories {
|
||||
maven {
|
||||
name = "Build"
|
||||
url = uri(rootProject.layout.buildDirectory.dir("repo"))
|
||||
}
|
||||
}
|
||||
publications {
|
||||
create<MavenPublication>("maven") {
|
||||
from(components["java"])
|
||||
}
|
||||
val uberDependencies = dependencies
|
||||
.filter { !it.toString().matches("rife2-.*agent\\.jar".toRegex()) }
|
||||
.map(::zipTree)
|
||||
from(uberDependencies, "$buildDir/webapp")
|
||||
with(jar.get())
|
||||
}
|
||||
}
|
||||
|
||||
graalvmNative.binaries.all {
|
||||
buildArgs.add("--enable-preview") // support for Jetty virtual threads with JDK 19
|
||||
imageName.set("hello-$version")
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
[
|
||||
{
|
||||
"name":"rife.template.html.hello",
|
||||
"methods":[{"name":"<init>","parameterTypes":[] }]
|
||||
}
|
||||
{
|
||||
"name":"rife.template.html.hello",
|
||||
"methods":[{"name":"<init>","parameterTypes":[] }]
|
||||
}
|
||||
]
|
||||
|
|
|
@ -1,8 +0,0 @@
|
|||
{
|
||||
"resources":{
|
||||
"includes":[
|
||||
{"pattern":"^webapp/.*$"}
|
||||
]
|
||||
},
|
||||
"bundles":[]
|
||||
}
|
2
gradle.properties
Normal file
2
gradle.properties
Normal file
|
@ -0,0 +1,2 @@
|
|||
org.gradle.parallel=true
|
||||
org.gradle.caching=true
|
|
@ -1,11 +1,9 @@
|
|||
/*
|
||||
* This file was generated by the Gradle 'init' task.
|
||||
*
|
||||
* 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
|
||||
*/
|
||||
pluginManagement {
|
||||
repositories {
|
||||
mavenCentral()
|
||||
gradlePluginPortal()
|
||||
}
|
||||
}
|
||||
|
||||
rootProject.name = "hello"
|
||||
include("app","war")
|
||||
|
|
|
@ -2,9 +2,10 @@ plugins {
|
|||
war
|
||||
}
|
||||
|
||||
version = 1.0
|
||||
|
||||
base {
|
||||
archivesName.set("hello")
|
||||
version = 1.0
|
||||
}
|
||||
|
||||
repositories {
|
||||
|
@ -19,5 +20,4 @@ dependencies {
|
|||
tasks.war {
|
||||
webAppDirectory.set(file("../app/src/main/webapp"))
|
||||
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