forked from minecraft-dev/MinecraftDev
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
dae0cec
commit 32de983
Showing
16 changed files
with
288 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
[*.{kt,kts}] | ||
max_line_length=120 | ||
indent_size = 4 | ||
ij_kotlin_imports_layout=* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 62 additions & 0 deletions
62
...nsion/groovy/com/demonwav/mcdev/platform/mcp/gradle/tooling/McpModelRFGBuilderImpl.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/* | ||
* Minecraft Dev for IntelliJ | ||
* | ||
* https://minecraftdev.org | ||
* | ||
* Copyright (c) 2023 minecraft-dev | ||
* | ||
* MIT License | ||
*/ | ||
|
||
package com.demonwav.mcdev.platform.mcp.gradle.tooling | ||
|
||
import org.gradle.api.Project | ||
import org.jetbrains.annotations.NotNull | ||
import org.jetbrains.plugins.gradle.tooling.ErrorMessageBuilder | ||
import org.jetbrains.plugins.gradle.tooling.ModelBuilderService | ||
|
||
final class McpModelRFGBuilderImpl implements ModelBuilderService { | ||
|
||
@Override | ||
boolean canBuild(String modelName) { | ||
return McpModelRFG.name == modelName | ||
} | ||
|
||
@Override | ||
Object buildAll(String modelName, Project project) { | ||
System.err.println("Attempting build of " + modelName + " in " + project) | ||
def extension = project.extensions.findByName('minecraft') | ||
if (extension == null) { | ||
return null | ||
} | ||
|
||
def mcpTasksObj = project.extensions.findByName('mcpTasks') | ||
if (mcpTasksObj == null) { | ||
return null | ||
} | ||
|
||
if (project.tasks.findByName("generateForgeSrgMappings") == null) { | ||
return null | ||
} | ||
|
||
def mappingFiles = project.tasks.generateForgeSrgMappings.outputs.files.files.collect { it.absolutePath } | ||
def atFiles = mcpTasksObj.deobfuscationATs.files.collect {it} | ||
System.err.println("Done build of " + modelName + " in " + project) | ||
try { | ||
def implObj = new McpModelRFGImpl(extension.mcVersion.get(), extension.mcpMappingChannel.get() + "-" + extension.mcpMappingVersion.get(), mappingFiles.toSet(), atFiles) | ||
System.err.println("Impl: " + implObj) | ||
return implObj | ||
} catch (Throwable t) { | ||
System.err.println(t.message) | ||
t.printStackTrace() | ||
throw t | ||
} | ||
} | ||
|
||
@Override | ||
ErrorMessageBuilder getErrorMessageBuilder(@NotNull Project project, @NotNull Exception e) { | ||
return ErrorMessageBuilder.create( | ||
project, e, "MinecraftDev import errors" | ||
).withDescription("Unable to build MinecraftDev MCP project configuration") | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
...ng-extension/groovy/com/demonwav/mcdev/platform/mcp/gradle/tooling/McpModelRFGImpl.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/* | ||
* Minecraft Dev for IntelliJ | ||
* | ||
* https://minecraftdev.org | ||
* | ||
* Copyright (c) 2023 minecraft-dev | ||
* | ||
* MIT License | ||
*/ | ||
|
||
package com.demonwav.mcdev.platform.mcp.gradle.tooling | ||
|
||
import groovy.transform.CompileStatic | ||
|
||
@CompileStatic | ||
final class McpModelRFGImpl implements McpModelRFG, Serializable { | ||
|
||
final String minecraftVersion | ||
final String mcpVersion | ||
final Set<String> mappingFiles | ||
final List<File> accessTransformers | ||
|
||
McpModelRFGImpl(String minecraftVersion, String mcpVersion, Set<String> mappingFiles, List<File> accessTransformers) { | ||
this.minecraftVersion = minecraftVersion | ||
this.mcpVersion = mcpVersion | ||
this.mappingFiles = mappingFiles | ||
this.accessTransformers = accessTransformers | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "McpModelRFGImpl{" + | ||
"minecraftVersion='" + minecraftVersion + '\'' + | ||
", mcpVersion='" + mcpVersion + '\'' + | ||
", mappingFiles=" + mappingFiles + | ||
", accessTransformers=" + accessTransformers + | ||
'}'; | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
...le-tooling-extension/java/com/demonwav/mcdev/platform/mcp/gradle/tooling/McpModelRFG.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/* | ||
* Minecraft Dev for IntelliJ | ||
* | ||
* https://minecraftdev.org | ||
* | ||
* Copyright (c) 2023 minecraft-dev | ||
* | ||
* MIT License | ||
*/ | ||
|
||
package com.demonwav.mcdev.platform.mcp.gradle.tooling; | ||
|
||
import java.io.File; | ||
import java.util.List; | ||
import java.util.Set; | ||
|
||
public interface McpModelRFG extends McpModel { | ||
String getMinecraftVersion(); | ||
Set<String> getMappingFiles(); | ||
List<File> getAccessTransformers(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 69 additions & 0 deletions
69
src/main/kotlin/platform/mcp/gradle/datahandler/McpModelRFGHandler.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
/* | ||
* Minecraft Dev for IntelliJ | ||
* | ||
* https://minecraftdev.org | ||
* | ||
* Copyright (c) 2023 minecraft-dev | ||
* | ||
* MIT License | ||
*/ | ||
|
||
package com.demonwav.mcdev.platform.mcp.gradle.datahandler | ||
|
||
import com.demonwav.mcdev.platform.mcp.McpModuleSettings | ||
import com.demonwav.mcdev.platform.mcp.gradle.McpModelData | ||
import com.demonwav.mcdev.platform.mcp.gradle.tooling.McpModelRFG | ||
import com.demonwav.mcdev.platform.mcp.srg.SrgType | ||
import com.intellij.openapi.externalSystem.model.DataNode | ||
import com.intellij.openapi.externalSystem.model.project.ModuleData | ||
import org.gradle.tooling.model.idea.IdeaModule | ||
import org.jetbrains.plugins.gradle.model.data.GradleSourceSetData | ||
import org.jetbrains.plugins.gradle.service.project.ProjectResolverContext | ||
|
||
object McpModelRFGHandler : McpModelDataHandler { | ||
|
||
override fun build( | ||
gradleModule: IdeaModule, | ||
node: DataNode<ModuleData>, | ||
resolverCtx: ProjectResolverContext | ||
) { | ||
val data = resolverCtx.getExtraProject(gradleModule, McpModelRFG::class.java) ?: return | ||
|
||
val state = McpModuleSettings.State( | ||
data.minecraftVersion, | ||
data.mcpVersion, | ||
data.mappingFiles.find { it.endsWith("mcp-srg.srg") }, | ||
SrgType.SRG, | ||
data.minecraftVersion | ||
) | ||
|
||
val modelData = McpModelData( | ||
node.data, | ||
state, | ||
"generateForgeSrgMappings", | ||
data.accessTransformers | ||
) | ||
|
||
node.createChild( | ||
McpModelData.KEY, | ||
McpModelData( | ||
node.data, | ||
McpModuleSettings.State( | ||
data.minecraftVersion, | ||
data.mcpVersion, | ||
data.mappingFiles.find { it.endsWith("mcp-srg.srg") }, | ||
SrgType.SRG | ||
), | ||
"generateForgeSrgMappings", | ||
data.accessTransformers | ||
) | ||
) | ||
|
||
for (child in node.children) { | ||
val childData = child.data | ||
if (childData is GradleSourceSetData) { | ||
child.createChild(McpModelData.KEY, modelData.copy(module = childData)) | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.