refined-hydrogen-4796703/14/2023, 3:03 AM
scala_source( name="test-trait-target", source="TestTrait.scala", dependencies=[ "!:test-trait-target", ] )
witty-crayon-2278603/14/2023, 3:28 AM
refined-hydrogen-4796703/14/2023, 4:01 AM
As for the advice in the message, I wouldn't expect this to constitute an import cycle. I could probably split it up into 2 or 3 files if there were also a companion object, but as it is there's only 1 file so I don't think it's possible to make any more granular targets. And when I try to use the recommended flag I get an error for an unknown flag. src/scala/com/TestTrait.scala
[ERROR] 1 Exception encountered: Engine traceback: in `check` goal in Check compilation for Scala - scalac in Resolve coarsened targets CycleException: The dependency graph contained a cycle: -> src/scala/com:test-trait-target -> src/scala/com:test-trait-target To fix this, first verify if your code has an actual import cycle. If it does, you likely need to re-architect your code to avoid the cycle. If there is no cycle in your code, then you may need to use more granular targets. Split up the problematic targets into smaller targets with more granular `sources` fields so that you can adjust the `dependencies` fields to avoid introducing a cycle. Alternatively, use Python dependency inference (`--python-infer-imports`), rather than explicit `dependencies`. Pants will infer dependencies on specific files, rather than entire targets. This extra precision means that you will only have cycles if your code actually does have cycles in it.
package com sealed trait TestTrait case object TestTraitA extends TestTrait case object TestTraitB extends TestTrait case object TestTraitC extends TestTrait
scala_source( name="test-trait-target", source="TestTrait.scala", )