https://pantsbuild.org/ logo
b

brief-engineer-67497

11/09/2018, 4:08 PM
perhaps a quick question to be sure that I don't go in a wall. Somebody told me on this chanel that code gen needs to be run before compile. This statement is only valid for one target, right ? If a code gen target
a
depends on java_library target
b
, code gen of
a
is run after compilation of
b
?
e

enough-analyst-54434

11/09/2018, 6:27 PM
False. Today all codegen is done in a single pass. Compiles then come after, they cannot interleave.
a

aloof-angle-91616

11/10/2018, 10:12 PM
(this is only if you're asking about pants task(s) you are developing -- the dilemma john described is one of the things that the v2 engine's declarative model makes easier in some ways. but if you need to, for example, run a task that generates code, then run another task that generates code off of that, you can override the
product_types()
and
prepare()
classmethods on your tasks in order to enforce an ordering between the two code generating tasks -- you have probably seen this page already: https://www.pantsbuild.org/dev_tasks.html)
we should update that page with an example of using a
type
as the product instead of a string, i might make a small PR
h

happy-kitchen-89482

11/11/2018, 3:52 PM
To clarify, currently all tasks registered in the “codegen” goal are done in a single pass. But you can register yours in a “myspecialcodegen” goal and set up the product dependencies as needed.
☝️ 1
a

aloof-angle-91616

11/11/2018, 9:48 PM
thanks benjy that is a crucial point i completely missed
b

brief-engineer-67497

11/12/2018, 8:45 AM
thank you for the anwers !
actually it seems I completely missed the
annotation_processor
target which furiously looks like what I'm trying to achieve