Skip to content

Commit

Permalink
Generate IntelliJ run configurations on sync
Browse files Browse the repository at this point in the history
  • Loading branch information
Yeregorix committed Dec 28, 2024
1 parent 8fa0e2c commit 4854c57
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package org.spongepowered.gradle.impl;

public class IdeHelper {

public static boolean isIdeaActive() {
return Boolean.getBoolean("idea.active");
}

public static boolean isIdeaSync() {
return Boolean.getBoolean("idea.sync.active");
}
}
6 changes: 3 additions & 3 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -22,22 +22,22 @@ val recommendedVersion: String by project
val organization: String by project
val projectUrl: String by project

version = spongeImpl.generateImplementationVersionString(apiVersion, minecraftVersion, recommendedVersion)

val commonManifest = java.manifest {
attributes(
"Specification-Title" to "Sponge",
"Specification-Vendor" to "SpongePowered",
"Specification-Version" to apiVersion,
"Implementation-Title" to project.name,
"Implementation-Version" to spongeImpl.generateImplementationVersionString(apiVersion, minecraftVersion, recommendedVersion),
"Implementation-Version" to version,
"Implementation-Vendor" to "SpongePowered"
)
// These two are included by most CI's
System.getenv()["GIT_COMMIT"]?.apply { attributes("Git-Commit" to this) }
System.getenv()["GIT_BRANCH"]?.apply { attributes("Git-Branch" to this) }
}

version = spongeImpl.generateImplementationVersionString(apiVersion, minecraftVersion, recommendedVersion)

// SpongeCommon configurations
val applaunchConfig by configurations.register("applaunch")

Expand Down
8 changes: 8 additions & 0 deletions forge/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
import net.minecraftforge.gradle.userdev.UserDevExtension
import org.gradle.internal.DefaultTaskExecutionRequest
import org.spongepowered.gradle.impl.AWToAT
import org.spongepowered.gradle.impl.IdeHelper

buildscript {
repositories {
Expand Down Expand Up @@ -384,6 +386,12 @@ tasks {
}
}

if (IdeHelper.isIdeaSync()) {
afterEvaluate {
gradle.startParameter.taskRequests.add(DefaultTaskExecutionRequest(listOf(":SpongeForge:genIntellijRuns")))
}
}

sourceSets {
main {
blossom.resources {
Expand Down
3 changes: 2 additions & 1 deletion vanilla/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
import org.spongepowered.gradle.impl.IdeHelper

plugins {
id("org.spongepowered.gradle.vanilla")
Expand Down Expand Up @@ -272,7 +273,7 @@ minecraft {
targetVersion(apiJavaTarget.toInt())
workingDirectory(project.file("run/"))

if (org.spongepowered.gradle.vanilla.internal.util.IdeConfigurer.isIdeaImport()) { // todo(zml): promote to API... eventually
if (IdeHelper.isIdeaActive()) {
// IntelliJ does not properly report its compatibility
jvmArgs("-Dterminal.ansi=true", "-Djansi.mode=force")
}
Expand Down

0 comments on commit 4854c57

Please sign in to comment.