def java_sources(self): if self._raw_java_sources is not None: self._java_sources = list(Target.resolve_all(maybe_list(self._raw_java_sources, Target), JavaLibrary)) self._raw_java_sources = None # TODO(John Sirois): reconsider doing this auto-linking. # We have circular java/scala dep, add an inbound dependency edge from java to scala in this # case to force scala compilation to precede java - since scalac supports generating java # stubs for these cycles and javac does not this is both necessary and always correct. for java_target in self._java_sources: java_target.update_dependencies([self]) return self._java_sources
def _resolve_target_sources(self, target_sources, extension=None, relative_to_target_base=False): """Given a list of pants targets, extract their sources as a list. Filters against the extension if given and optionally returns the paths relative to the target base. """ resolved_sources = [] for resolved in Target.resolve_all(target_sources): if hasattr(resolved, 'sources'): resolved_sources.extend( source if relative_to_target_base else os.path.join(resolved.target_base, source) for source in resolved.sources if not extension or source.endswith(extension) ) return resolved_sources
def _link_java_cycles(self): if self._raw_java_sources is not None: self._java_sources = list(Target.resolve_all(maybe_list(self._raw_java_sources, Target), JavaLibrary)) self._raw_java_sources = None # TODO(John Sirois): reconsider doing this auto-linking. # We have circular java/scala dep, add an inbound dependency edge from java to scala in this # case to force scala compilation to precede java - since scalac supports generating java # stubs for these cycles and javac does not this is both necessary and always correct. for java_target in self._java_sources: # If this scala library provides an artifact, Fail if the java target also. if self.provides and java_target.provides: raise TargetDefinitionException(self, "Associated Java Target %s also provides an artifact" % java_target) self.update_dependencies(java_target.dependencies) java_target.update_dependencies([self])