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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,6 @@
.qodana
build
.claude/

local.properties
CLAUDE.local.md
61 changes: 61 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import org.jetbrains.changelog.Changelog
import org.jetbrains.changelog.markdownToHTML
import org.jetbrains.intellij.platform.gradle.TestFrameworkType
import java.util.Properties

plugins {
id("java") // Java support
Expand All @@ -9,6 +10,7 @@ plugins {
alias(libs.plugins.changelog) // Gradle Changelog Plugin
alias(libs.plugins.qodana) // Gradle Qodana Plugin
alias(libs.plugins.kover) // Gradle Kover Plugin
alias(libs.plugins.protobuf) // Protocol Buffers
}

group = providers.gradleProperty("pluginGroup").get()
Expand Down Expand Up @@ -39,6 +41,10 @@ dependencies {
implementation("com.google.code.gson:gson:2.11.0")
// OGG Vorbis audio support for asset preview
implementation("com.github.trilarion:java-vorbis-support:1.2.1")
// WebSocket server for Dev Bridge
implementation(libs.javaWebsocket)
// Protocol Buffers runtime
implementation(libs.protobuf)

testImplementation(libs.junit)
testImplementation(libs.opentest4j)
Expand Down Expand Up @@ -136,6 +142,49 @@ kover {
}
}

// Configure Protocol Buffers - read more: https://github.com/google/protobuf-gradle-plugin
protobuf {
protoc {
artifact = "com.google.protobuf:protoc:${libs.versions.protobuf.get()}"
}
}

// Ensure generated protobuf sources are included in the source set
sourceSets {
main {
java {
srcDirs(layout.buildDirectory.dir("generated/source/proto/main/java"))
}
}
}

// Gradle Tooling Extension configuration - following MinecraftDev pattern
// This extension runs in Gradle's process during IntelliJ sync to detect the hytale-dev plugin
val gradleToolingExtension: Configuration by configurations.creating

val gradleToolingExtensionSourceSet: SourceSet = sourceSets.create("gradle-tooling-extension") {
configurations.named(compileOnlyConfigurationName) {
extendsFrom(gradleToolingExtension)
}
}

// Create a separate JAR for the tooling extension
val gradleToolingExtensionJar = tasks.register<Jar>(gradleToolingExtensionSourceSet.jarTaskName) {
from(gradleToolingExtensionSourceSet.output)
archiveClassifier.set("gradle-tooling-extension")
}

dependencies {
// Embed the tooling extension JAR in the plugin
implementation(files(gradleToolingExtensionJar))

// Dependencies for the gradle-tooling-extension (runs in Gradle, not IntelliJ)
gradleToolingExtension(gradleApi())
gradleToolingExtension(kotlin("stdlib"))
gradleToolingExtension(libs.gradleToolingExtension)
gradleToolingExtension(libs.annotations)
}

tasks {
wrapper {
gradleVersion = providers.gradleProperty("gradleVersion").get()
Expand All @@ -154,6 +203,18 @@ tasks {
"-Dide.locale=fr_FR"
)
}

// Allow overwriting the IDE runtime with local JBR for testing/compatibility
val localProperties = project.rootProject.file("local.properties")
if (localProperties.exists()) {
val p = Properties().apply { load(localProperties.inputStream()) }
val jbrPath = p.getProperty("idea.runtimeDir")

if (jbrPath != null) {
logger.info("Using overridden JBR path: $jbrPath")
runtimeDirectory.set(file(jbrPath))
}
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ platformVersion = 2025.3.1.1
# Example: platformPlugins = com.jetbrains.php:203.4449.22, org.intellij.scala:2023.3.27@EAP
platformPlugins =
# Example: platformBundledPlugins = com.intellij.java
platformBundledPlugins = com.intellij.java
platformBundledPlugins = com.intellij.java, org.jetbrains.plugins.gradle
# Example: platformBundledModules = intellij.spellchecker
platformBundledModules =

Expand Down
11 changes: 11 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,32 @@
# libraries
junit = "4.13.2"
opentest4j = "1.3.0"
protobuf = "3.25.1"
javaWebsocket = "1.5.7"

# plugins
changelog = "2.5.0"
intelliJPlatform = "2.10.5"
kotlin = "2.2.21"
kover = "0.9.3"
qodana = "2025.2.2"
protobufPlugin = "0.9.4"

[libraries]
junit = { group = "junit", name = "junit", version.ref = "junit" }
opentest4j = { group = "org.opentest4j", name = "opentest4j", version.ref = "opentest4j" }
protobuf = { group = "com.google.protobuf", name = "protobuf-java", version.ref = "protobuf" }
javaWebsocket = { group = "org.java-websocket", name = "Java-WebSocket", version.ref = "javaWebsocket" }

# Gradle Tooling Extension - version must match IntelliJ build number
# Find version with: afterEvaluate { println(intellijPlatform.productInfo.buildNumber) }
gradleToolingExtension = { module = "com.jetbrains.intellij.gradle:gradle-tooling-extension", version = "253.29346.240" }
annotations = { group = "org.jetbrains", name = "annotations", version = "24.0.0" }

[plugins]
changelog = { id = "org.jetbrains.changelog", version.ref = "changelog" }
intelliJPlatform = { id = "org.jetbrains.intellij.platform", version.ref = "intelliJPlatform" }
kotlin = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" }
kover = { id = "org.jetbrains.kotlinx.kover", version.ref = "kover" }
qodana = { id = "org.jetbrains.qodana", version.ref = "qodana" }
protobuf = { id = "com.google.protobuf", version.ref = "protobufPlugin" }
Empty file modified gradlew
100644 → 100755
Empty file.
2 changes: 1 addition & 1 deletion settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
rootProject.name = "hytale-intellij-plugin"

plugins {
id("org.gradle.toolchains.foojay-resolver-convention") version "0.9.0"
id("org.gradle.toolchains.foojay-resolver-convention") version "1.0.0"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.hytaledocs.intellij.gradle.tooling;

/**
* Model interface for querying Hytale Dev plugin information during Gradle sync.
* This interface is used by both the ModelBuilder (in Gradle process) and the
* ProjectResolverExtension (in IntelliJ process).
*/
public interface HytaleDevModel {
/**
* Returns true if the net.janrupf.hytale-dev Gradle plugin is applied to this project.
*/
boolean hasHytaleDevPlugin();

/**
* Returns the version of the Hytale Dev plugin, if available.
*/
String getPluginVersion();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package com.hytaledocs.intellij.gradle.tooling;

import java.io.Serializable;

/**
* Serializable implementation of HytaleDevModel.
* This class is instantiated in the Gradle process and serialized to IntelliJ.
*/
public class HytaleDevModelImpl implements HytaleDevModel, Serializable {
private static final long serialVersionUID = 1L;

private final boolean hasPlugin;
private final String version;

public HytaleDevModelImpl(boolean hasPlugin, String version) {
this.hasPlugin = hasPlugin;
this.version = version;
}

@Override
public boolean hasHytaleDevPlugin() {
return hasPlugin;
}

@Override
public String getPluginVersion() {
return version;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package com.hytaledocs.intellij.gradle.tooling

import org.gradle.api.Project
import org.jetbrains.plugins.gradle.tooling.ErrorMessageBuilder
import org.jetbrains.plugins.gradle.tooling.ModelBuilderService

/**
* ModelBuilder that runs in the Gradle process during IntelliJ Gradle sync.
* Detects whether the net.janrupf.hytale-dev plugin is applied to the project.
*/
class HytaleDevModelBuilder : ModelBuilderService {

companion object {
private const val HYTALE_DEV_PLUGIN_ID = "net.janrupf.hytale-dev"
}

override fun canBuild(modelName: String): Boolean {
return HytaleDevModel::class.java.name == modelName
}

override fun buildAll(modelName: String, project: Project): Any {
val hasPlugin = project.plugins.hasPlugin(HYTALE_DEV_PLUGIN_ID)
var version: String? = null

if (hasPlugin) {
// Try to get plugin version from the applied plugin
val appliedPlugin = project.plugins.findPlugin(HYTALE_DEV_PLUGIN_ID)
if (appliedPlugin != null) {
// The plugin class might expose version info, but for now we leave it null
// Future: could extract from plugin metadata
}
}

return HytaleDevModelImpl(hasPlugin, version)
}

override fun getErrorMessageBuilder(project: Project, e: Exception): ErrorMessageBuilder {
return ErrorMessageBuilder.create(project, e, "HytaleDocs import errors")
.withDescription("Unable to detect Hytale Dev plugin")
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
com.hytaledocs.intellij.gradle.tooling.HytaleDevModelBuilder
Loading