Skip to content

Commit e8a34a9

Browse files
reid-spencerclaude
andcommitted
Fix sbt-riddl validateOnCompile for Root projects
Move the Compile/compile hook from unconditional projectSettings into the riddlc() curried helper, so it only applies to projects that explicitly .configure(riddlc()). Root aggregator projects (like riddl-models) no longer get RuntimeUndefined errors. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 8e8e03b commit e8a34a9

1 file changed

Lines changed: 11 additions & 16 deletions

File tree

sbt-riddl/src/main/scala/com/ossuminc/riddl/sbt/plugin/RiddlSbtPlugin.scala

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -94,13 +94,22 @@ object RiddlSbtPlugin extends AutoPlugin {
9494
confExclusions: Seq[String] = Seq("patterns"),
9595
options: Seq[String] = Seq("--show-times")
9696
)(project: Project): Project = {
97-
project.settings(
97+
val base = Seq(
9898
riddlcVersion := version,
9999
riddlcSourceDir := baseDirectory.value / sourceDir,
100100
riddlcValidateOnCompile := validateOnCompile,
101101
riddlcConfExclusions := confExclusions,
102102
riddlcOptions := options
103103
)
104+
val hook = if (validateOnCompile) Seq(
105+
Compile / compile := Def.taskDyn {
106+
Def.task {
107+
riddlcValidate.value
108+
(Compile / compile).value
109+
}
110+
}.value
111+
) else Seq.empty
112+
project.settings(base ++ hook)
104113
}
105114
}
106115

@@ -461,7 +470,7 @@ object RiddlSbtPlugin extends AutoPlugin {
461470
riddlcSourceDir := baseDirectory.value / "src" /
462471
"main" / "riddl",
463472
riddlcConfExclusions := Seq("patterns"),
464-
riddlcValidateOnCompile := true,
473+
riddlcValidateOnCompile := false,
465474

466475
// --- Task implementations ---
467476

@@ -639,20 +648,6 @@ object RiddlSbtPlugin extends AutoPlugin {
639648
}
640649
},
641650

642-
// Pre-compile validation hook
643-
Compile / compile := Def.taskDyn {
644-
if (riddlcValidateOnCompile.value) {
645-
Def.task {
646-
riddlcValidate.value
647-
(Compile / compile).value
648-
}
649-
} else {
650-
Def.task {
651-
(Compile / compile).value
652-
}
653-
}
654-
}.value,
655-
656651
// Command wrappers for interactive sbt use
657652
commands ++= Seq(
658653
Command.command("validate") { s =>

0 commit comments

Comments
 (0)