Skip to content
Merged
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
2 changes: 1 addition & 1 deletion .github/workflows/develop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:

- name: Build
run: |
./gradlew build
./gradlew build IdeaPlugin:verifyPlugin
mv scripting-host/build/distributions/scripting-host-release*.tar.gz scripting-host-release.tar.gz

- name: Upload build
Expand Down
11 changes: 6 additions & 5 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
java-version: 17

- name: Build
run: ./gradlew assembleReleaseDist
run: ./gradlew scripting-host:assembleReleaseDist IdeaPlugin:buildPlugin

- name: Create info variables
id: variables
Expand All @@ -36,10 +36,10 @@ jobs:

- name: Get Changelog
id: changelog
uses: mindsers/changelog-reader-action@v2.2.3
with:
version: ${{ steps.variables.outputs.version }}
validation_level: error
run: |
echo 'changes<<END_OF_CHANGELOG' >> $GITHUB_OUTPUT
./gradlew -q getChangelog --project-version='${{ steps.variables.outputs.version }}' --no-links --no-header >> $GITHUB_OUTPUT
echo END_OF_CHANGELOG >> $GITHUB_OUTPUT

- name: Create Release
uses: softprops/action-gh-release@v2
Expand All @@ -49,5 +49,6 @@ jobs:
files: |
scripting-host/build/distributions/scripting-host-release*.tar.gz
scripting-host/build/distributions/scripting-host-release*.zip
IdeaPlugin/build/distributions/IdeaPlugin-*.zip
draft: false
prerelease: false
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ build/

### IntelliJ IDEA ###
.idea/
.intellijPlatform/

### Eclipse ###
.apt_generated
Expand Down Expand Up @@ -34,3 +35,6 @@ bin/

### Project ###
/kss.properties

### Kotlin ###
.kotlin
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# CHANGELOG

## [UNRELEASED]
## [Unreleased]

### Added

- IntelliJ Plugin

## [0.6.0] - 2025-01-25

Expand Down
96 changes: 96 additions & 0 deletions IdeaPlugin/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
import org.jetbrains.changelog.Changelog
import org.jetbrains.changelog.tasks.GetChangelogTask

/*
* Copyright 2025 Eduard Wolf
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

plugins {
alias(libs.plugins.changelog)
alias(libs.plugins.kotlin.jvm)
alias(libs.plugins.intellij.platform)
}

group = "net.edwardday.kss"

repositories {
mavenCentral()
intellijPlatform {
defaultRepositories()
}
}

kotlin {
jvmToolchain(21)
}

changelog {
versionPrefix.set("")
path.set(rootProject.file("CHANGELOG.md").canonicalPath)

}

intellijPlatform {
pluginConfiguration {
ideaVersion {
sinceBuild = "252"
untilBuild = "252.*"
}
val projectVersion = project.version.toString()
val changelog = tasks.getChangelog.flatMap(GetChangelogTask::changelog).map { changelog ->
val item = if (projectVersion.endsWith("SNAPSHOT")) changelog.unreleasedItem!! else changelog.getLatest()
changelog.renderItem(item, Changelog.OutputType.HTML)
}
changeNotes.set(changelog)
version = projectVersion
}
buildSearchableOptions = false

pluginVerification {
ides {
recommended()
}
}
autoReload = false
}

dependencies {
// Configure Gradle IntelliJ Plugin
// Read more: https://plugins.jetbrains.com/docs/intellij/tools-intellij-platform-gradle-plugin.html#setup
intellijPlatform {
// needed until 2025.3 can be targeted
@Suppress("DEPRECATION")
intellijIdeaCommunity("2025.2.2")

bundledPlugins("org.jetbrains.kotlin")

compileOnly(libs.kotlin.scripting.common)
compileOnly(libs.kotlinx.coroutines)
}
implementation(project(":scripting-definition")) {
exclude(group = "org.jetbrains.kotlin", module = "kotlin-stdlib")
exclude(group = "org.jetbrains.kotlin", module = "kotlin-scripting-common")
exclude(group = "org.jetbrains.kotlin", module = "kotlin-scripting-jvm")
exclude(group = "org.jetbrains.kotlin", module = "kotlin-script-runtime")
exclude(group = "org.jetbrains.kotlin", module = "kotlin-scripting-dependencies-maven")
exclude(group = "org.jetbrains.kotlinx", module = "kotlinx-coroutines-core")
}
implementation(libs.kotlin.scripting.dependencies.maven.all) {
exclude(group = "org.jetbrains.kotlin", module = "kotlin-stdlib")
exclude(group = "org.jetbrains.kotlin", module = "kotlin-scripting-common")
exclude(group = "org.jetbrains.kotlin", module = "kotlin-scripting-jvm")
exclude(group = "org.jetbrains.kotlin", module = "kotlin-script-runtime")
}
}
24 changes: 24 additions & 0 deletions IdeaPlugin/gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#
# Copyright 2025 Eduard Wolf
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

# Opt-out flag for bundling Kotlin standard library -> https://jb.gg/intellij-platform-kotlin-stdlib
kotlin.stdlib.default.dependency = false

# Enable Gradle Configuration Cache -> https://docs.gradle.org/current/userguide/configuration_cache.html
org.gradle.configuration-cache = true

# Enable Gradle Build Cache -> https://docs.gradle.org/current/userguide/build_cache.html
org.gradle.caching = true
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/*
* Copyright 2025 Eduard Wolf
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package net.edwardday.kss.ideaplugin

import com.intellij.util.PathUtil
import kotlinx.coroutines.Job
import net.edwardday.serverscript.scriptdefinition.ServerScriptDefinition
import net.edwardday.serverscript.scriptdefinition.script.ServerScript
import org.jetbrains.kotlin.idea.base.plugin.artifacts.KotlinArtifacts
import org.jetbrains.kotlin.scripting.definitions.ScriptDefinition
import org.jetbrains.kotlin.scripting.definitions.ScriptDefinitionsSource
import java.io.File
import kotlin.script.experimental.dependencies.maven.MavenDependenciesResolver
import kotlin.script.experimental.host.ScriptingHostConfiguration
import kotlin.script.experimental.host.configurationDependencies
import kotlin.script.experimental.jvm.JvmDependency
import kotlin.script.experimental.jvm.defaultJvmScriptingHostConfiguration

internal class KssScriptDefinitionSource : ScriptDefinitionsSource {
override val definitions: Sequence<ScriptDefinition>
get() {
val definition = ScriptDefinition.FromTemplate(
baseHostConfiguration = ScriptingHostConfiguration(defaultJvmScriptingHostConfiguration) {
val kotlinArtifacts = listOf(KotlinArtifacts.kotlinStdlib, KotlinArtifacts.kotlinScriptRuntime)
val kssArtifacts =
listOf(ServerScript::class, MavenDependenciesResolver::class, Job::class)
.map { File(PathUtil.getJarPathForClass(it.java)) }
val dependencies = (kssArtifacts + kotlinArtifacts).distinct()
configurationDependencies(listOf(JvmDependency(dependencies)))
},
contextClass = ServerScriptDefinition::class,
template = ServerScriptDefinition::class,
)
definition.order = Int.MIN_VALUE
return sequenceOf(definition)
}
}
43 changes: 43 additions & 0 deletions IdeaPlugin/src/main/resources/META-INF/plugin.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<!--
Copyright 2025 Eduard Wolf
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<!-- Plugin Configuration File. Read more: https://plugins.jetbrains.com/docs/intellij/plugin-configuration-file.html -->
<idea-plugin require-restart="true">
<!-- Unique identifier of the plugin. It should be FQN. It cannot be changed between the plugin versions. -->
<id>net.edwardday.kss.IdeaPlugin</id>

<!-- Public plugin name should be written in Title Case.
Guidelines: https://plugins.jetbrains.com/docs/marketplace/plugin-overview-page.html#plugin-name -->
<name>Kotlin Server Scripts</name>

<!-- A displayed Vendor name or Organization ID displayed on the Plugins Page. -->
<vendor email="edwardday@canis-tech.de" url="https://edwardday.net">Edwar D Day</vendor>

<!-- Description of the plugin displayed on the Plugin Page and IDE Plugin Manager.
Simple HTML elements (text formatting, paragraphs, and lists) can be added inside of <![CDATA[ ]]> tag.
Guidelines: https://plugins.jetbrains.com/docs/marketplace/plugin-overview-page.html#plugin-description -->
<description><![CDATA[
Plugin for <a href="https://github.com/EdwarDDay/kotlin-server-scripts">Kotlin server scripts</a> in the IDE.
]]></description>

<!-- Product and plugin compatibility requirements.
Read more: https://plugins.jetbrains.com/docs/intellij/plugin-compatibility.html -->
<depends>com.intellij.modules.platform</depends>
<depends>org.jetbrains.kotlin</depends>

<!-- Extension points defined by the plugin.
Read more: https://plugins.jetbrains.com/docs/intellij/plugin-extension-points.html -->
<extensions defaultExtensionNs="org.jetbrains.kotlin">
<supportsKotlinPluginMode supportsK2="true" supportsK1="false" />
<scriptDefinitionsSource implementation="net.edwardday.kss.ideaplugin.KssScriptDefinitionSource"/>
</extensions>
</idea-plugin>
25 changes: 25 additions & 0 deletions IdeaPlugin/src/main/resources/META-INF/pluginIcon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
![KSS Logo](IdeaPlugin/src/main/resources/META-INF/pluginIcon.svg)

# Kotlin Server Scripts

Kotlin Server Scripts let you run kotlin scripts in response to server requests, without setting up a complete project.
Expand Down Expand Up @@ -78,6 +80,16 @@ You can reference a [logback configuration file](https://logback.qos.ch/manual/c
`kss.properties` configuration file via `logging.logback.configurationFile=<path to file>`. This way you can change the
log level from the default `info` or log to a file instead of the command line as it's done by default.

## Plugin

You can use the IntelliJ plugin from the latest release to get proper code completion when writing scripts.

### Install

Download the plugin from the [latest release](https://github.com/EdwarDDay/kotlin-server-scripts/releases/latest),
check the [IDEA documentation](https://www.jetbrains.com/help/idea/managing-plugins.html#install_plugin_from_disk) to
get the latest information of how to install a plugin from disk.

## Building

To build the library just run `./gradlew scripting-host:build`.
5 changes: 5 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
[versions]
changelog = "2.2.1"
clikt = "5.0.3"
intellij-platform = "2.9.0"
kotlin = "2.2.21"
kotlinx-coroutines = "1.10.2"
logback = "1.5.20"
Expand All @@ -11,6 +13,7 @@ clikt = { module = "com.github.ajalt.clikt:clikt", version.ref = "clikt" }
kotlin-scripting-common = { module = "org.jetbrains.kotlin:kotlin-scripting-common", version.ref = "kotlin" }
kotlin-scripting-dependencies = { module = "org.jetbrains.kotlin:kotlin-scripting-dependencies", version.ref = "kotlin" }
kotlin-scripting-dependencies-maven = { module = "org.jetbrains.kotlin:kotlin-scripting-dependencies-maven", version.ref = "kotlin" }
kotlin-scripting-dependencies-maven-all = { module = "org.jetbrains.kotlin:kotlin-scripting-dependencies-maven-all", version.ref = "kotlin" }
kotlin-scripting-jvm = { module = "org.jetbrains.kotlin:kotlin-scripting-jvm", version.ref = "kotlin" }
kotlin-scripting-jvm-host = { module = "org.jetbrains.kotlin:kotlin-scripting-jvm-host", version.ref = "kotlin" }
kotlin-test = { module = "org.jetbrains.kotlin:kotlin-test", version.ref = "kotlin" }
Expand All @@ -22,4 +25,6 @@ oshai-logging = { module = "io.github.oshai:kotlin-logging-jvm", version.ref = "
okio = { module = "com.squareup.okio:okio", version.ref = "okio" }

[plugins]
changelog = { id = "org.jetbrains.changelog", version.ref = "changelog" }
kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" }
intellij-platform = { id = "org.jetbrains.intellij.platform", version.ref = "intellij-platform" }
Loading