def create_ant_builds(self, workspace_root, targets, flags, target): if target._id in targets: return targets[target._id] # Link in libraries required by ant targets as needed if target.target_base == 'tests/java': junit = target.do_in_context( lambda: Pants('3rdparty:junit').resolve()) target.update_dependencies(junit) elif target.target_base == 'tests/scala': explicit_specs_runner = target.do_in_context(lambda: Pants( 'src/scala/com/twitter/common/testing:explicit-specs-runner'). resolve()) target.update_dependencies(explicit_specs_runner) try: library_template_data = target._create_template_data() except: self.ferror("Problem creating template data for %s(%s): %s" % (type(target).__name__, target.address, traceback.format_exc())) workspace = os.path.join(workspace_root, library_template_data.id) if not os.path.exists(workspace): os.makedirs(workspace) ivyxml = os.path.join(workspace, 'ivy.xml') AntBuilder._generate(self.root_dir, 'ivy', library_template_data, ivyxml) buildxml = os.path.join(workspace, 'build.xml') if target.custom_antxml_path: shutil.copyfile(target.custom_antxml_path, buildxml) pants_buildxml = os.path.join(workspace, 'pants-build.xml') flags.add('-Dpants.build.file=pants-build.xml') else: pants_buildxml = buildxml build_template = os.path.join(library_template_data.template_base, 'build') AntBuilder._generate(self.root_dir, build_template, library_template_data, pants_buildxml) targets[target._id] = buildxml for additional_library in target.internal_dependencies: self.create_ant_builds(workspace_root, targets, flags, additional_library) return buildxml, ivyxml
def resolve_thriftdeps(): all_deps = [ Pants('3rdparty:commons-lang'), JarDependency(org='org.apache.thrift', name='libthrift', rev='${thrift.library.version}'), Pants('3rdparty:slf4j-api'), # finagle thrift extra deps Pants('3rdparty:finagle-core'), Pants('3rdparty:finagle-thrift'), Pants('3rdparty:util'), ] for dep in all_deps: target.update_dependencies(dep.resolve())
def resolve(self, spec): """Returns an iterator over the target(s) the given address points to.""" with ParseContext.temp(): return Pants(spec).resolve()
def create_ant_builds(self, workspace_root, targets, flags, target): if target.id in targets: return targets[target.id] # Link in libraries required by ant targets as needed def add_scaladeps(tgt): scaladeps = target.do_in_context(lambda: JarDependency( org='org.scala-lang', name='scala-library', rev='${scala.version}').with_sources().resolve()) target.update_dependencies(scaladeps) if is_jvm(target): if not target.sources: target.sources = ['_not_a_real_file_'] if isinstance(target, JavaProtobufLibrary): protobufdeps = target.do_in_context(lambda: JarDependency( org='com.google.protobuf', name='protobuf-java', rev='${protobuf.library.version}').resolve()) target.update_dependencies(protobufdeps) elif isinstance(target, JavaThriftLibrary): def resolve_thriftdeps(): all_deps = [ Pants('3rdparty:commons-lang'), JarDependency(org='org.apache.thrift', name='libthrift', rev='${thrift.library.version}'), Pants('3rdparty:slf4j-api'), # finagle thrift extra deps Pants('3rdparty:finagle-core'), Pants('3rdparty:finagle-thrift'), Pants('3rdparty:util'), ] for dep in all_deps: target.update_dependencies(dep.resolve()) target.do_in_context(resolve_thriftdeps) elif isinstance(target, JavaTests): junit = target.do_in_context( lambda: Pants('3rdparty:junit').resolve()) target.update_dependencies(junit) elif isinstance(target, ScalaLibrary): add_scaladeps(target) elif isinstance(target, ScalaTests): add_scaladeps(target) specdeps = target.do_in_context(lambda: JarDependency( org='org.scala-tools.testing', name='${specs.name}', rev='${specs.version}').with_sources().resolve()) target.update_dependencies(specdeps) try: library_template_data = target._create_template_data() except: self.ferror("Problem creating template data for %s(%s): %s" % (type(target).__name__, target.address, traceback.format_exc())) workspace = os.path.join(workspace_root, library_template_data.id) if not os.path.exists(workspace): os.makedirs(workspace) ivyxml = os.path.join(workspace, 'ivy.xml') AntBuilder._generate(self.root_dir, 'ivy', library_template_data, ivyxml) buildxml = os.path.join(workspace, 'build.xml') if target.custom_antxml_path: shutil.copyfile(target.custom_antxml_path, buildxml) pants_buildxml = os.path.join(workspace, 'pants-build.xml') flags.add('-Dpants.build.file=pants-build.xml') else: pants_buildxml = buildxml build_template = os.path.join(library_template_data.template_base, 'build') AntBuilder._generate(self.root_dir, build_template, library_template_data, pants_buildxml) targets[target.id] = buildxml for additional_library in target.internal_dependencies: self.create_ant_builds(workspace_root, targets, flags, additional_library) return buildxml, ivyxml