Skip to content
Open
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ See the official [plugin documentation](https://www.appdevforall.org/codeonthego
| [`plugins/Get-AI-Models/`](plugins/Get-AI-Models/) | Downloads small language models for on-device AI addons. |
| [`plugins/Icons-Repository/`](plugins/Icons-Repository/) | Adds vector icons to a project from inside the editor. |
| [`plugins/Jetpack-Compose-Preview/`](plugins/Jetpack-Compose-Preview/) | Renders Compose preview functions on the device. |
| [`plugins/JVM-Tools/`](plugins/JVM-Tools/) | Runs Java and Kotlin programs, with a main-class picker and program arguments. |
| [`plugins/Keystore-Generator/`](plugins/Keystore-Generator/) | Creates and manages app signing keystores on the device. |
| [`plugins/Layout-Editor/`](plugins/Layout-Editor/) | Edits Android XML layouts by dragging views. |
| [`plugins/Markdown-Previewer/`](plugins/Markdown-Previewer/) | Shows a live preview of Markdown and HTML files. |
Expand Down
29 changes: 29 additions & 0 deletions plugins/JVM-Tools/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Gradle
.gradle/
build/
gradle-app.setting
!gradle-wrapper.jar
.gradletasknamecache

# IDE
.idea/
*.iml
*.ipr
*.iws
.project
.classpath
.settings/
.kotlin/

# Local configuration
local.properties

# OS
.DS_Store
Thumbs.db

# Logs
*.log

# Test outputs
test-results/
43 changes: 43 additions & 0 deletions plugins/JVM-Tools/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# JVM Tools

Runs Java and Kotlin programs in Code on the Go, the way a desktop IDE does: choose the main class,
give it program arguments, and tap Run.

## What it adds

In a JVM project, a folder of `.java` and `.kt` files with no Gradle build, the editor toolbar gets:

- **Run** - compiles every Java and Kotlin file in the project on the device and runs the chosen main
class. Compiler errors and the program's output stream into Build Output, and the button becomes
**Cancel Run** while the program runs.
- **Run configuration** - lists every class with a `main` method and takes the program arguments.
The choice is saved for each project.

The Gradle actions (Quick Run, Quick Build, Sync, Debug, Run Tasks, Launch App) are hidden in a JVM
project. Android projects are left alone.

The **Java/Kotlin Program** template on the New Project screen creates a two-class program in
`src/`, in the language you choose.

## How it runs code

Nothing is downloaded. Java is compiled with the JDK that ships with Code on the Go, and Kotlin with
the `kotlin-compiler-embeddable` already in the IDE's local Maven repository. Classes go to a folder
under `$PREFIX/tmp/jvm-tools`, not into the project.

## Limits

- Programs cannot read keyboard input; pass values as program arguments.
- Only the Java class library and the Kotlin standard library are on the classpath.
- Gradle projects are not handled.

## Build

```sh
cd plugins/JVM-Tools
../../gradlew assemblePlugin # build/plugin/jvm-tools.cgp
../../gradlew assemblePluginDebug # build/plugin/jvm-tools-debug.cgp
../../gradlew testDebugUnitTest
```

Supports Code on the Go 26.37 through 26.99.
15 changes: 15 additions & 0 deletions plugins/JVM-Tools/addon.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"summary": "Runs Java and Kotlin programs, with a main-class picker and program arguments.",
"description": "Compiles a folder of Java and Kotlin files on the device and runs the main class you choose, with the arguments you give it. Output appears in Build Output. Adds a Java/Kotlin Program template.",
"tags": [
"java",
"kotlin",
"templates"
],
"origin": "appdevforall",
"license": "AGPL-3.0-or-later",
"author": {
"name": "App Dev For All",
"url": "https://www.appdevforall.org"
}
}
75 changes: 75 additions & 0 deletions plugins/JVM-Tools/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
import org.jetbrains.kotlin.gradle.dsl.JvmTarget

plugins {
id("com.android.application")
id("com.itsaky.androidide.plugins.build")
}

pluginBuilder {
pluginName = "jvm-tools"
}

android {
namespace = "com.appdevforall.jvm.plugin"
compileSdk = 36

defaultConfig {
applicationId = "com.appdevforall.jvm.plugin"
minSdk = 26
targetSdk = 36
versionCode = 1
versionName = "1.0.0"
}

buildTypes {
release {
isMinifyEnabled = false
proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro")
}
}

compileOptions {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}

packaging {
resources {
excludes += setOf(
"META-INF/versions/9/OSGI-INF/MANIFEST.MF",
"META-INF/DEPENDENCIES",
"META-INF/LICENSE",
"META-INF/LICENSE.txt",
"META-INF/NOTICE",
"META-INF/NOTICE.txt"
)
}
}

testOptions {
unitTests.isReturnDefaultValues = true
}
}

kotlin {
compilerOptions {
jvmTarget.set(JvmTarget.JVM_17)
}
}

dependencies {
compileOnly(files("../../libs/plugin-api.jar"))
compileOnly("com.google.android.material:material:1.12.0")

implementation("org.jetbrains.kotlin:kotlin-stdlib:2.3.21")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.8.1")

testImplementation("junit:junit:4.13.2")
}

tasks.matching {
it.name.contains("checkDebugAarMetadata") ||
it.name.contains("checkReleaseAarMetadata")
}.configureEach {
enabled = false
}
4 changes: 4 additions & 0 deletions plugins/JVM-Tools/gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
android.useAndroidX=true
android.nonTransitiveRClass=true
kotlin.code.style=official
org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
Loading
Loading