Skip to content

Commit

Permalink
Fix #1886 Sync error in ForgeGradle composite builds
Browse files Browse the repository at this point in the history
Also remove duplicate tasks before executing them
  • Loading branch information
RedNesto committed Oct 5, 2024
1 parent f5ea374 commit 8bd000f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class McpProjectResolverExtension : AbstractProjectResolverExtension() {

val projectDirPath = Paths.get(projectDataNode.data.linkedExternalProjectPath)
runGradleTask(project, projectDirPath) { settings ->
settings.taskNames = allTaskNames
settings.taskNames = allTaskNames.distinct()
}

super.resolveFinished(projectDataNode)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import com.intellij.openapi.vfs.LocalFileSystem
import org.gradle.tooling.model.idea.IdeaModule
import org.jetbrains.plugins.gradle.model.data.GradleSourceSetData
import org.jetbrains.plugins.gradle.service.project.ProjectResolverContext
import org.jetbrains.plugins.gradle.util.gradleIdentityPath

object McpModelFG3Handler : McpModelDataHandler {

Expand Down Expand Up @@ -68,9 +69,10 @@ object McpModelFG3Handler : McpModelDataHandler {
forgeVersion,
)

val gradleProjectPath = gradleModule.gradleProject.projectIdentifier.projectPath
val suffix = if (gradleProjectPath.endsWith(':')) "" else ":"
val taskName = gradleProjectPath + suffix + data.taskName
// gradleIdentityPath makes it work with composite builds
val identityPath = node.data.gradleIdentityPath
// But ignore it if it is the root project, as taskName already starts with a colon
val taskName = if (identityPath == ":") data.taskName else identityPath + ':' + data.taskName

val ats = data.accessTransformers
if (ats != null && ats.isNotEmpty()) {
Expand Down

0 comments on commit 8bd000f

Please sign in to comment.