def _convert_poms(self): modules = PomUtils.get_modules() logger.debug('Re-generating {count} modules'.format(count=len(modules))) # Convert pom files to BUILD files context = GenerationContext() for module_name in modules: if not module_name in _MODULES_TO_SKIP: pom_file_name = os.path.join(module_name, 'pom.xml') PomToBuild().convert_pom(pom_file_name, rootdir=self.baseroot, generation_context=context) context.os_to_java_homes = JavaHomesInfo.from_pom('parents/base/pom.xml', self.baseroot).home_map # Write jvm platforms and distributions. with open(context.generated_ini_file, 'w+') as f: f.write('# Generated by regenerate_all.py. Do not hand-edit.\n\n') f.write('\n'.join(context.get_pants_ini_gen())) local_ini = 'pants-local.ini' if not os.path.exists(local_ini): with open(local_ini, 'w') as f: f.write('\n'.join([ '# Local pants.ini file, not tracked by git.', '# Use this to make your own custom changes/overrides to pants settings.', '# Note: This is for local settings only. Changes you make here will', '# not be used in CI (use pants.ini for that).', '', '# Uncomment to use local build cache ', '# (Saves time when switching between branches frequently.)', '#[cache]', '#read_from: ["~/.cache/pants/local-build-cache"]', '#read: True', '#write_to: ["~/.cache/pants/local-build-cache"]', '#write: True', '', ]))
def _rebuild_everything(self, gens_dir, builds_index): # The cached BUILD files are now invalid. Remove them first rmtree(gens_dir, ignore_errors=True) poms = [x + '/pom.xml' for x in PomUtils.get_modules()] # Convert pom files to BUILD files for pom_file_name in poms: PomToBuild().convert_pom(pom_file_name, rootdir=self.baseroot) logger.info('Re-generating 3rdparty/BUILD.gen') with open('3rdparty/BUILD.gen', 'w') as build_file: build_file.write(ThirdPartyBuildGenerator().generate()) new_gens = find_files([self.baseroot], _GEN_NAMES) logger.info( 'Caching {num_build_files} regenerated BUILD.* files. '.format( num_build_files=len(new_gens))) os.makedirs(gens_dir) gen_pairs = set() for gen in new_gens: if gen == '': continue cache_name = sha1(gen).hexdigest() index = 0 while os.path.exists( os.path.join(gens_dir, cache_name + str(index))): index += 1 cache_name += str(index) cache_path = os.path.join(gens_dir, cache_name) copyfile(gen, cache_path) gen_pairs.add((cache_path, gen)) write_index(builds_index, gen_pairs)
def _rebuild_everything(self, gens_dir, builds_index): # The cached BUILD files are now invalid. Remove them first rmtree(gens_dir, ignore_errors=True) poms = [x + '/pom.xml' for x in PomUtils.get_modules()] # Convert pom files to BUILD files for pom_file_name in poms: PomToBuild().convert_pom(pom_file_name, rootdir=self.baseroot) logger.info('Re-generating 3rdparty/BUILD.gen') with open('3rdparty/BUILD.gen', 'w') as build_file: build_file.write(ThirdPartyBuildGenerator().generate()) new_gens = find_files([self.baseroot], _GEN_NAMES) logger.info('Caching {num_build_files} regenerated BUILD.* files. ' .format(num_build_files=len(new_gens))) os.makedirs(gens_dir) gen_pairs = set() for gen in new_gens: if gen == '': continue cache_name = sha1(gen).hexdigest() index = 0 while os.path.exists(os.path.join(gens_dir, cache_name+str(index))): index += 1 cache_name += str(index) cache_path = os.path.join(gens_dir, cache_name) copyfile(gen, cache_path) gen_pairs.add((cache_path, gen)) write_index(builds_index, gen_pairs)
def generate(self): modules = PomUtils.get_modules() contents = "# Automatically generated by {0}\n\n".format(os.path.basename(sys.argv[0])) for module in modules: contents += "square_maven_layout('{0}')\n".format(module) return contents
def _generate_module_list_file(self): modules = PomUtils.get_modules() context = GenerationContext() with open(context.module_list_file, 'w+') as f: f.write("# List of modules for pants's reference. This are currently generated directly\n" "# from pom.xml, but in the future we can simply use\n" "# ./pants filter --target-type=jvm_binary ::\n\n") for module in modules: f.write('{}\n'.format(module.strip()))
def generate(self): modules = PomUtils.get_modules() contents = "# Automatically generated by {0}\n\n".format( os.path.basename(sys.argv[0])) for module in modules: contents += "square_maven_layout('{0}')\n".format(module) return contents
def _generate_module_list_file(self): modules = PomUtils.get_modules() context = GenerationContext() with open(context.module_list_file, 'w+') as f: f.write( "# List of modules for pants's reference. This are currently generated directly\n" "# from pom.xml, but in the future we can simply use\n" "# ./pants filter --target-type=jvm_binary ::\n\n") for module in modules: f.write('{}\n'.format(module.strip()))
def _convert_poms(self): modules = PomUtils.get_modules() logger.debug( 'Re-generating {count} modules'.format(count=len(modules))) # Convert pom files to BUILD files context = GenerationContext() for module_name in modules: if not module_name in _MODULES_TO_SKIP: pom_file_name = os.path.join(module_name, 'pom.xml') PomToBuild().convert_pom(pom_file_name, rootdir=self.baseroot, generation_context=context) context.os_to_java_homes = JavaHomesInfo.from_pom( 'parents/base/pom.xml', self.baseroot).home_map # Write jvm platforms and distributions. with open(context.generated_ini_file, 'w+') as f: f.write('# Generated by regenerate_all.py. Do not hand-edit.\n\n') f.write('\n'.join(context.get_pants_ini_gen())) local_ini = 'pants-local.ini' if not os.path.exists(local_ini): with open(local_ini, 'w') as f: f.write('\n'.join([ '# Local pants.ini file, not tracked by git.', '# Use this to make your own custom changes/overrides to pants settings.', '# Note: This is for local settings only. Changes you make here will', '# not be used in CI (use pants.ini for that).', '', '# Uncomment to use local build cache ', '# (Saves time when switching between branches frequently.)', '#[cache]', '#read_from: ["~/.cache/pants/local-build-cache"]', '#read: True', '#write_to: ["~/.cache/pants/local-build-cache"]', '#write: True', '', ]))