def download_pom(self, artifact): if artifact in self.pom_not_found_cache: return None if artifact in self.pom_cache: return self.pom_cache[artifact] if artifact.is_snapshot(): snapshot_info = self.get_snapshot_info(artifact) if snapshot_info is not None: ts, bn = snapshot_info artifact.timestamp = ts artifact.build_number = bn maven_path = self.get_artifact_uri(artifact, 'pom') try: logger.info('[Checking] pom file %s' % maven_path) data = download_string(maven_path) # cache self.pom_cache[artifact] = data return data except DownloadException: self.pom_not_found_cache.append(artifact) logger.info('[Skipped] Pom file not found at %s' % maven_path) return None
def download_jar(self, artifact, local_path): maven_path = self.get_artifact_uri(artifact, 'jar') logger.info('[Downloading] jar from %s' % maven_path) local_jip_path = os.path.join(local_path, artifact.to_jip_name()) local_f = open(local_jip_path, 'wb') # download jar asyncly download(maven_path, local_f, True)
def download_pom(self, artifact): maven_file_path = self.get_artifact_uri(artifact, 'pom') logger.info('[Checking] pom file %s' % maven_file_path) if os.path.exists(maven_file_path): pom_file = open(maven_file_path, 'r') data = pom_file.read() pom_file.close() return data else: logger.info('[Skipped] pom file not found at %s' % maven_file_path) return None
def _retrieve_latest_version(group, artifact) -> str: import requests import re url = 'https://oss.sonatype.org/content/repositories/public/%s/%s' % (group.replace('.', '/'), artifact) result = requests.get(url).text result = [line[0].split('/')[-1] for line in re.findall('%s/(\\d+\\.\\d+\\.\\d+(-[A-Za-z]+(\\.\\d+)?)?)/' % url, result)] version = max(result, key=_parse_version_string) logger.info('[INFO] Latest version of %s:%s (%s) will be used.', group, artifact, version) return version
def _retrieve_latest_version(group, artifact) -> str: import requests import re url = 'https://repo1.maven.org/maven2/%s/%s' % (group.replace( '.', '/'), artifact) result = requests.get(url).text result = [ line[0].split('/')[-1] for line in re.findall( 'href="(\\d+\\.\\d+\\.\\d+(-[A-Za-z]+(\\.\\d+)?)?)/"', result) ] version = max(result, key=_parse_version_string) logger.info('[INFO] Latest version of %s:%s (%s) will be used.', group, artifact, version) return version
def download_jar(self, artifact, local_path): maven_file_path = self.get_artifact_uri(artifact, 'jar') logger.info("[Checking] jar package from %s" % self.name) if os.path.exists(maven_file_path): local_jip_path = os.path.join(local_path, artifact.to_jip_name()) logger.info("[Downloading] %s" % maven_file_path) shutil.copy(maven_file_path, local_jip_path) logger.info("[Finished] %s completed" % local_jip_path) else: logger.error("[Error] File not found %s" % maven_file_path) raise IOError('File not found:' + maven_file_path)