brief-engineer-67497
11/07/2018, 11:20 AMenough-analyst-54434
11/07/2018, 1:16 PMself.get_options()
- an instance method of Task
and the classmethod register_options
- which is the pair. You can get a rich set of examples closely tracking what you're doing with the following in the Pants repo: $ git grep SimpleCodegenTask | cut -d: -f1 | sort -u | xargs grep "def register_options(" | cut -d: -f1 | sort -u | xargs grep "self.get_options()"
As far as diamonds go, you can stay out of the woods and not think about them if you follow examples like you have and inherit from mixins first and then finally a single concrete super class, ei: class MyTask(Mixin1, Mixin2, Task):
.brief-engineer-67497
11/07/2018, 1:36 PMXXXMixin
?brief-engineer-67497
11/07/2018, 1:41 PMclass QueryDslGen(SimpleCodegenTask, JavacCompile):
def __init__(self, *args, **kwargs):
super(QueryDslGen, self).__init__(*args, **kwargs)
def synthetic_target_type(self, target):
return JavaLibrary
def is_gentarget(self, target):
return isinstance(target, QueryDslLibrary)
def execute(self):
return super(SimpleCodegenTask).execute()
def execute_codegen(self, target, target_workdir):
if not isinstance(target, QueryDslLibrary):
raise TaskError('Invalid target type "{class_type}" (expected QueryDslLibrary)'
.format(class_type=type(target).__name__))
<http://self.context.log.info|self.context.log.info>('toto')
<http://self.context.log.info|self.context.log.info>(self.context)
result = 1
if result != 0:
raise TaskError('twirl-gen ... exited non-zero ({code})'.format(code=result))
but then I have a cycle detected :
Exception caught: (<class 'pants.engine.round_engine.GoalCycleError'>)
Exception message: Cycle detected in goal dependencies:
gen <- [resolve]
resolve <- [gen]
deferred-sources <- [gen]
imports <- [gen, unpack-jars]
bootstrap <- [resolve, gen, imports]
jvm-platform-validate <- [resolve, gen]
unpack-jars <- [deferred-sources]
So I tried to delegate the compilation part :
class QueryDslGen(SimpleCodegenTask):
compiler_delegate = None
def __init__(self, *args, **kwargs):
super(QueryDslGen, self).__init__(*args, **kwargs)
compiler_delegate = JavacCompile(*args, **kwargs)
def synthetic_target_type(self, target):
return JavaLibrary
def is_gentarget(self, target):
return isinstance(target, QueryDslLibrary)
def execute_codegen(self, target, target_workdir):
if not isinstance(target, QueryDslLibrary):
raise TaskError('Invalid target type "{class_type}" (expected QueryDslLibrary)'
.format(class_type=type(target).__name__))
<http://self.context.log.info|self.context.log.info>('toto')
<http://self.context.log.info|self.context.log.info>(self.context)
result = 1
if result != 0:
raise TaskError('twirl-gen ... exited non-zero ({code})'.format(code=result))
but now I have the following error :
Exception caught: (<type 'exceptions.NotImplementedError'>)
Exception message: <class 'pants.backend.jvm.tasks.jvm_compile.javac.javac_compile.JavacCompile'> must set an options_scope class-level property.
enough-analyst-54434
11/07/2018, 2:11 PMsubsystem_dependencies
classmethod of JavacCompile and it's hierarchy). Subsystems, unlike tasks, can be called directly. Even with this there is likely a good bit of logic to tie together the subsystems to get a compile.brief-engineer-67497
11/07/2018, 2:33 PMbrief-engineer-67497
11/07/2018, 3:07 PMbrief-engineer-67497
11/07/2018, 3:09 PMenough-analyst-54434
11/07/2018, 3:10 PMsrc/python
folder in the left hand pane view as a 'Sources Root'?enough-analyst-54434
11/07/2018, 3:11 PMbrief-engineer-67497
11/07/2018, 3:16 PMbrief-engineer-67497
11/07/2018, 3:17 PMbrief-engineer-67497
11/07/2018, 3:17 PMbrief-engineer-67497
11/07/2018, 3:17 PMenough-analyst-54434
11/07/2018, 3:18 PMhundreds-father-404
11/07/2018, 4:21 PMbrief-engineer-67497
11/08/2018, 9:01 AM