Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[examples] Adds gradle tasks for each example #3466

Merged
merged 1 commit into from
Sep 12, 2024
Merged
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
54 changes: 40 additions & 14 deletions examples/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -38,20 +38,46 @@ tasks {
}
}

register<JavaExec>("listmodels") {
for (prop in System.getProperties().iterator()) {
val key = prop.key.toString()
if (key.startsWith("ai.djl.")) {
systemProperty(key, prop.value)
}
distTar { enabled = false }
distZip { enabled = false }

sourceSets.main.get().java.files
.filter { it.text.contains("public static void main(String[] args)") }
.map {
it.path.substringAfter("java${File.separatorChar}").replace(File.separatorChar, '.')
.substringBefore(".java")
}
if (!systemProperties.containsKey("ai.djl.logging.level")) {
systemProperty("ai.djl.logging.level", "debug")
.forEach { className ->
val taskName = className.substringAfterLast(".")

register<JavaExec>(name = taskName) {
classpath = sourceSets.main.get().runtimeClasspath
mainClass = className
group = "application"
for (prop in System.getProperties().iterator()) {
val key = prop.key.toString()
if (key.startsWith("ai.djl.")) {
systemProperty(key, prop.value)
}
}
if (!systemProperties.containsKey("ai.djl.logging.level")) {
systemProperty("ai.djl.logging.level", "debug")
}

allJvmArgs = allJvmArgs + listOf(
// kryo compatability
// from https://github.com/EsotericSoftware/kryo/blob/cb255af4f8df4f539778a325b8b4836d41f84de9/pom.xml#L435
"--add-opens=java.base/java.lang=ALL-UNNAMED",
"--add-opens=java.base/java.lang.invoke=ALL-UNNAMED",
"--add-opens=java.base/java.net=ALL-UNNAMED",
"--add-opens=java.base/java.nio=ALL-UNNAMED",
"--add-opens=java.base/java.time=ALL-UNNAMED",
"--add-opens=java.base/java.util=ALL-UNNAMED",
"--add-opens=java.base/java.util.concurrent.atomic=ALL-UNNAMED",
"--add-opens=java.base/sun.nio.ch=ALL-UNNAMED",
"--add-opens=java.base/sun.util.calendar=ALL-UNNAMED"
)
}
}
classpath = sourceSets.main.get().runtimeClasspath
mainClass = "ai.djl.examples.inference.ListModels"
}
}

distTar { enabled = false }
distZip { enabled = false }
}
Loading