How to handle clashing plugins generating code in SBT project?

I am stuck on a problem with my Scala SBT (1.7.2) project.

Situation:

I already have working configuration to generate code from *.avsc, *.avdl files via "com.julianpeeters" % "sbt-avrohugger" % "2.0.0-RC19" plugin. Now, I must add code generation from *.proto files. I have followed instruction of setting up ScalaPB (from here). Well, protobuf generation works as intended, but for some reason the avro code generation is affected – some files are created, but it looks like the plugin didn’t have time to finish up work and just stopped in the middle, making the tests fail in result.

Code:

plugins.sbt:

addSbtPlugin("com.julianpeeters" % "sbt-avrohugger" % "2.0.0-RC19")
addSbtPlugin("com.thesamet" % "sbt-protoc" % "1.0.7")

libraryDependencies += "com.thesamet.scalapb" %% "compilerplugin" % "0.11.15"

build.sbt:

lazy val `job` = (project in file("."))
  .settings(avroHuggerSettings)
  .settings(protobufSettings)

lazy val avroHuggerSettings = Seq.concat(
  inConfig(IntegrationTest)(SbtAvrohugger.baseSettings),
  Seq(
    Compile / sourceGenerators += (Compile / avroScalaGenerate).taskValue,
    Test / sourceGenerators += (Test / avroScalaGenerate).taskValue,
    IntegrationTest / sourceGenerators += (IntegrationTest / avroScalaGenerate).taskValue,
    Compile / avroSourceDirectories := Seq(new java.io.File(s"${baseDirectory.value}/src/main/resources/avro")),
    Test / avroSourceDirectories := Seq(new java.io.File(s"${baseDirectory.value}/src/test/resources/avro")),
    IntegrationTest / avroSourceDirectories := Seq(new java.io.File(s"${baseDirectory.value}/src/it/resources/avro")),
    Compile / avroScalaCustomTypes := avroCustomTypes,
    Test / avroScalaCustomTypes := avroCustomTypes,
    IntegrationTest / avroScalaCustomTypes := avroCustomTypes
  )
)

lazy val protobufSettings = Seq(
  Compile / PB.targets := Seq(
    scalapb.gen() -> (Compile / sourceManaged).value
  )

My Avro files are located in src/main/resources/avro, my Proto files are located in src/main/protobuf.

With such setup my proto files are generated correctly, but only some of the avro files are done. Mind you, both plugins generate code into target/scala-2.12/src_managed/main, but into different packages.

Output logs snippet (sbt assembly):

[info] Considering source directories ...resources/avro
[info] Compiling AVSC ... .avsc to .../target/scala-2.12/src_managed/main/compiled_avro
[info] Compiling AVSC ... .avsc to .../target/scala-2.12/src_managed/main/compiled_avro
[info] Compiling Avro IDL ... .avdl
[info] Compiling 4 protobuf files to .../target/scala-2.12/src_managed/main
[info] Compiling Avro IDL ... .avdl
[info] Compiling Avro IDL ... .avdl
[info] Compiling Avro IDL ... .avdl
[info] Compiling Avro IDL ... .avdl
[info] Compiling Avro IDL ... .avdl
[info] Compiling Avro IDL ... .avdl
[info] compiling 139 Scala sources to .../target/scala-2.12/classes
[info] done compiling
//same as above but for some test avro classes
//failing test output
[error] (Test / compileIncremental) Compilation failed
[error] Total time: 9 s, completed Jun 5, 2024, 4:11:10 PM

My attempts to fix:

I am not good with the SBT so it was a trial and error, but I’ve tried to make either plugin run before the other one, with no results. I tried to use the examples from this stack thread, like that:

lazy val generateAvro = taskKey[Unit]("Avro task")
lazy val generateProto = taskKey[Unit]("Proto task")

generateAvro := {
  println("Starting avro task ...")
  //tried both with Seq() and without, doesn't matter
    Seq(
      Compile / sourceGenerators += (Compile / avroScalaGenerate).taskValue,
      Test / sourceGenerators += (Test / avroScalaGenerate).taskValue,
      IntegrationTest / sourceGenerators += (IntegrationTest / avroScalaGenerate).taskValue,
      Compile / avroSourceDirectories := Seq(new java.io.File(s"${baseDirectory.value}/src/main/resources/avro")),
      Test / avroSourceDirectories := Seq(new java.io.File(s"${baseDirectory.value}/src/test/resources/avro")),
      IntegrationTest / avroSourceDirectories := Seq(new java.io.File(s"${baseDirectory.value}/src/it/resources/avro")),
      Compile / avroScalaCustomTypes := avroCustomTypes,
      Test / avroScalaCustomTypes := avroCustomTypes,
      IntegrationTest / avroScalaCustomTypes := avroCustomTypes,
      (Compile / avroScalaGenerate).value // tried with and without it
    )
  println("Avro task ended")
}

generateProto := {
  println("Starting proto task ...")
  Compile / PB.targets := Seq(
    scalapb.gen() -> (Compile / sourceManaged).value

  )
  println("Proto task ended")
}

Compile / compile := Def.taskDyn {
  val result = (Compile / compile).value
  Def.task {
    val _ = generateProto.value
    result
  }
}.dependsOn(generateAvro).value

Unfortunately it does not work, I guess that the content of those tasks is merely a config for the plugins, that work independently from my will during the compilation, right?

Please, show me some guidance how could I make those plugins work together in SBT? Making those plugins work in some orchestrated way, change the configuration for any of it, anything to get all the files generate please.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật