def main(): usage = "usage: %prog [options] REPOSITORY_PATH" cliOptParser = optparse.OptionParser(usage=usage, description='Compare a local Maven repository' ' to a remote repository.') cliOptParser.add_option('-l', '--loglevel', default='info', help='Set the level of log output. Can be set to debug, info, warning, error, or critical') cliOptParser.add_option('-u', '--url', default='http://repo1.maven.org/maven2/', help='URL of the remote repository to use for comparison, defaults to Maven central') (options, args) = cliOptParser.parse_args() if (len(args) < 1): logging.error('Local repository path must be specified\n') cliOptParser.print_help() sys.exit() localRepoPath = args[0] # Set the log level maven_repo_util.setLogLevel(options.loglevel) # Read the list of dependencies if os.path.isfile(localRepoPath): logging.error('Local repository path is a file instead of a directory: %s', localRepoPath) sys.exit() elif not os.path.isdir(localRepoPath): logging.error('Local repository path must point to the root directory of a local maven repository: %s', localRepoPath) sys.exit() logging.info('Remote repository URL: %s', options.url) logging.info('Crawling local repository: %s', localRepoPath) compareArtifacts(localRepoPath, options.url)
def main(): description = "Generate artifact list from sources defined in the given congiguration file" cliOptParser = optparse.OptionParser(usage="Usage: %prog -c CONFIG", description=description) cliOptParser.add_option( '-c', '--config', dest='config', help='Configuration file to use for generation of an artifact list for the repository builder' ) cliOptParser.add_option( '-a', '--allclassifiers', default=False, action='store_true', help='Find all available classifiers' ) cliOptParser.add_option( '-l', '--loglevel', default='info', help='Set the level of log output. Can be set to debug, info, warning, error, or critical' ) cliOptParser.add_option( '-L', '--logfile', help='Set the file in which the log output should be written.' ) (options, args) = cliOptParser.parse_args() # Set the log level maven_repo_util.setLogLevel(options.loglevel, options.logfile) artifactList = _generateArtifactList(options) maven_repo_util.printArtifactList(artifactList, options.allclassifiers)
def main(): description = "Generate artifact list from sources defined in the given configuration file" cliOptParser = optparse.OptionParser(usage="Usage: %prog -c CONFIG", description=description) cliOptParser.add_option( '-c', '--config', dest='config', help='Configuration file to use for generation of an artifact list for the repository builder' ) cliOptParser.add_option( '-a', '--classifiers', default='sources', help='Comma-separated list of additional classifiers to download. It is possible to use "__all__" to ' 'request all available classifiers. There can be a type specified with each classifiers separated ' 'by colon, e.g. sources:jar.' ) cliOptParser.add_option( '-x', '--excludedtypes', default='zip:ear:war:tar:gz:tar.gz:bz2:tar.bz2:7z:tar.7z', help='Colon-separated list of filetypes to exclude. Defaults to ' 'zip:ear:war:tar:gz:tar.gz:bz2:tar.bz2:7z:tar.7z.' ) cliOptParser.add_option( '--nocache', dest="cache", default=True, action='store_false', help='Don\'t use any cache (dependency graph cache etc.).' ) cliOptParser.add_option( '-w', '--whitelist', help='Name of a file containing GATCV patterns allowing usage of stars or regular expressions when enclosed ' 'in "r/pattern/". It can force inclusion of artifacts with excluded types.' ) cliOptParser.add_option( "-R", '--reportdir', dest="reportdir", default=None, help='Dir where to generate the repository analysis report. If not specified no report will be generated.' ) cliOptParser.add_option( "-N", '--reportname', dest="reportname", default="Maven Repository", help='Name of the repository to be used in the analysis report. It is used only when reportdir value is specified.' ) cliOptParser.add_option( '-l', '--loglevel', default='info', help='Set the level of log output. Can be set to debug, info, warning, error, or critical' ) cliOptParser.add_option( '-L', '--logfile', help='Set the file in which the log output should be written.' ) (options, args) = cliOptParser.parse_args() # Set the log level maven_repo_util.setLogLevel(options.loglevel, options.logfile) artifactList = _generateArtifactList(options, args) _printArtifactList(artifactList)
def main(): description = "Generate artifact list from sources defined in the given congiguration file" cliOptParser = optparse.OptionParser(usage="Usage: %prog -c CONFIG", description=description) cliOptParser.add_option( '-c', '--config', dest='config', help= 'Configuration file to use for generation of an artifact list for the repository builder' ) cliOptParser.add_option('-a', '--allclassifiers', default=False, action='store_true', help='Find all available classifiers') cliOptParser.add_option( '-l', '--loglevel', default='info', help= 'Set the level of log output. Can be set to debug, info, warning, error, or critical' ) cliOptParser.add_option( '-L', '--logfile', help='Set the file in which the log output should be written.') (options, args) = cliOptParser.parse_args() # Set the log level maven_repo_util.setLogLevel(options.loglevel, options.logfile) artifactList = _generateArtifactList(options) maven_repo_util.printArtifactList(artifactList, options.allclassifiers)
def main(): description = "Generate artifact list from sources defined in the given congiguration file" cliOptParser = optparse.OptionParser(usage="Usage: %prog -c CONFIG", description=description) cliOptParser.add_option('-c', '--config', dest='config', help='Configuration file to use for generation of an artifact list for the repository builder') cliOptParser.add_option('-l', '--loglevel', default='info', help='Set the level of log output. Can be set to debug, info, warning, error, or critical') (options, args) = cliOptParser.parse_args() # Set the log level maven_repo_util.setLogLevel(options.loglevel) artifactList = _generateArtifactList(options) maven_repo_util.printArtifactList(artifactList)
def main(): usage = "usage: %prog [options] REPOSITORY_PATH" cliOptParser = optparse.OptionParser( usage=usage, description="Compare a local Maven repository to a remote repository." ) cliOptParser.add_option( "-l", "--loglevel", default="info", help="Set the level of log output. Can be set to debug, info, warning, error, or critical", ) cliOptParser.add_option("-L", "--logfile", help="Set the file in which the log output should be written.") cliOptParser.add_option( "-u", "--url", default="http://repo1.maven.org/maven2/", help="URL of the remote repository to use for comparison, defaults to Maven central", ) (options, args) = cliOptParser.parse_args() if len(args) < 1: logging.error("Local repository path must be specified\n") cliOptParser.print_help() sys.exit() localRepoPath = args[0] # Set the log level maven_repo_util.setLogLevel(options.loglevel, options.logfile) # Read the list of dependencies if os.path.isfile(localRepoPath): logging.error("Local repository path is a file instead of a directory: %s", localRepoPath) sys.exit() elif not os.path.isdir(localRepoPath): logging.error( "Local repository path must point to the root directory of a local maven repository: %s", localRepoPath ) sys.exit() logging.info("Remote repository URL: %s", options.url) logging.info("Crawling local repository: %s", localRepoPath) compareArtifacts(localRepoPath, options.url)
def main(): usage = "usage: %prog [options] REPOSITORY_PATH" cliOptParser = optparse.OptionParser( usage=usage, description='Compare a local Maven repository to a remote repository.' ) cliOptParser.add_option( '-l', '--loglevel', default='info', help='Set the level of log output. Can be set to debug, info, warning, error, or critical' ) cliOptParser.add_option( '-L', '--logfile', help='Set the file in which the log output should be written.' ) cliOptParser.add_option( '-u', '--url', default='http://repo1.maven.org/maven2/', help='URL of the remote repository to use for comparison, defaults to Maven central' ) (options, args) = cliOptParser.parse_args() if (len(args) < 1): logging.error('Local repository path must be specified\n') cliOptParser.print_help() sys.exit() localRepoPath = args[0] # Set the log level maven_repo_util.setLogLevel(options.loglevel, options.logfile) # Read the list of dependencies if os.path.isfile(localRepoPath): logging.error('Local repository path is a file instead of a directory: %s', localRepoPath) sys.exit() elif not os.path.isdir(localRepoPath): logging.error('Local repository path must point to the root directory of a local maven repository: %s', localRepoPath) sys.exit() logging.info('Remote repository URL: %s', options.url) logging.info('Crawling local repository: %s', localRepoPath) compareArtifacts(localRepoPath, options.url)
def main(): usage = "Usage: %prog [-c CONFIG] [-a CLASSIFIERS] [-u URL] [-o OUTPUT_DIRECTORY] [FILE...]" description = ("Generate a Maven repository based on a file (or files) containing " "a list of artifacts. Each list file must contain a single artifact " "per line in the format groupId:artifactId:fileType:<classifier>:version " "The example artifact list contains more information. Another usage is " "to provide Artifact List Generator configuration file. There is also " "sample configuration file in examples.") # TODO: pkocandr - use argparse instead of optparse, which is deprecated since python 2.7 cliOptParser = optparse.OptionParser(usage=usage, description=description) cliOptParser.add_option( '-c', '--config', dest='config', help='Configuration file to use for generation of an artifact list for the repository builder' ) cliOptParser.add_option( '-u', '--url', default='http://repo1.maven.org/maven2/', help='URL of the remote repository from which artifacts are downloaded. ' 'It is used along with artifact list files when no config file is specified.' ) cliOptParser.add_option( '-o', '--output', default='local-maven-repository', help='Local output directory for the new repository' ) cliOptParser.add_option( '-a', '--classifiers', default='sources', help='Colon-separated list of additional classifiers to download. It is ' 'possible to use "__all__" to request all available classifiers ' '(works only when artifact list is generated from config).' ) cliOptParser.add_option( '-s', '--checksummode', default=ChecksumMode.generate, choices=(ChecksumMode.generate, ChecksumMode.download, ChecksumMode.check), help='Mode of dealing with MD5 and SHA1 checksums. Possible choices are: ' 'generate - generate the checksums (default) ' 'download - download the checksums if available, if not, generate them ' 'check - check if downloaded and generated checksums are equal' ) cliOptParser.add_option( '-x', '--excludedtypes', default='zip:ear:war:tar:gz:tar.gz:bz2:tar.bz2:7z:tar.7z', help='Colon-separated list of filetypes to exclude. Defaults to ' 'zip:ear:war:tar:gz:tar.gz:bz2:tar.bz2:7z:tar.7z.' ) cliOptParser.add_option( '-l', '--loglevel', default='info', help='Set the level of log output. Can be set to debug, info, warning, error, or critical' ) cliOptParser.add_option( '-L', '--logfile', help='Set the file in which the log output should be written.' ) (options, args) = cliOptParser.parse_args() # Set the log level maven_repo_util.setLogLevel(options.loglevel, options.logfile) if not options.classifiers or options.classifiers == '__all__': classifiers = [] else: classifiers = options.classifiers.split(":") if not options.excludedtypes: excludedtypes = [] else: excludedtypes = options.excludedtypes.split(":") if options.config is None: if len(args) < 1: logging.error('Missing required command line argument: path to artifact list file') sys.exit(usage) # Read the list(s) of dependencies from the specified files artifacts = [] for filename in args: if not os.path.isfile(filename): logging.warning('Dependency list file does not exist, skipping: %s', filename) continue logging.info('Reading artifact list from file: %s', filename) depListFile = open(filename) try: dependencyListLines = depListFile.readlines() artifacts.extend(depListToArtifactList(dependencyListLines)) except IOError as e: logging.exception('Unable to read file %s: %s', filename, str(e)) sys.exit(1) finally: depListFile.close() fetchArtifacts(options.url, options.output, artifacts, classifiers, excludedtypes, options.checksummode) else: # generate lists of artifacts from configuration and the fetch them each list from it's repo artifactList = artifact_list_generator.generateArtifactList(options) for repoUrl in artifactList.keys(): artifacts = artifactList[repoUrl] fetchArtifacts(repoUrl, options.output, artifacts, classifiers, excludedtypes, options.checksummode) logging.info('Generating missing checksums...') generateChecksums(options.output) logging.info('Repository created in directory: %s', options.output) #cleanup maven_repo_util.cleanTempDir()
def main(): usage = "Usage: %prog [-c CONFIG] [-a CLASSIFIERS] [-u URL] [-o OUTPUT_DIRECTORY] [FILE...]" description = ("Generate a Maven repository based on a file (or files) containing " "a list of artifacts. Each list file must contain a single artifact " "per line in the format groupId:artifactId:fileType:<classifier>:version " "The example artifact list contains more information. Another usage is " "to provide Artifact List Generator configuration file. There is also " "sample configuration file in examples.") cliOptParser = optparse.OptionParser(usage=usage, description=description) cliOptParser.add_option( '-c', '--config', dest='config', help='Configuration file to use for generation of an artifact list for the repository builder' ) cliOptParser.add_option( '-u', '--url', default='http://repo1.maven.org/maven2/', help='Comma-separated list of URLs of the remote repositories from which artifacts ' 'are downloaded. It is used along with artifact list files when no config file ' 'is specified.' ) cliOptParser.add_option( '-o', '--output', default='local-maven-repository/maven-repository', help='Local output directory for the new repository' ) cliOptParser.add_option( '-a', '--classifiers', default='sources', help='Comma-separated list of additional classifiers to download. It is possible to use "__all__" to ' 'request all available classifiers (works only when artifact list is generated from config). There ' 'can be a type specified with each classifiers separated by colon, e.g. sources:jar. The old way ' 'of separation of classifiers by colon is deprecated' ) cliOptParser.add_option( '-s', '--checksummode', default=ChecksumMode.generate, choices=(ChecksumMode.generate, ChecksumMode.download, ChecksumMode.check), help='Mode of dealing with MD5 and SHA1 checksums. Possible choices are: ' 'generate - generate the checksums (default) ' 'download - download the checksums if available, if not, generate them ' 'check - check if downloaded and generated checksums are equal' ) cliOptParser.add_option( '-x', '--excludedtypes', default='zip:ear:war:tar:gz:tar.gz:bz2:tar.bz2:7z:tar.7z', help='Colon-separated list of filetypes to exclude. Defaults to ' 'zip:ear:war:tar:gz:tar.gz:bz2:tar.bz2:7z:tar.7z.' ) cliOptParser.add_option( '-w', '--whitelist', help='Name of a file containing GATCV patterns allowing usage of stars or regular expressions when enclosed ' 'in "r/pattern/". It can force inclusion of artifacts with excluded types.' ) cliOptParser.add_option( "-O", '--reportdir', dest="reportdir", default=None, help='Dir where to generate the repository analysis report. If not specified no report will be generated.' ) cliOptParser.add_option( '-l', '--loglevel', default='info', help='Set the level of log output. Can be set to debug, info, warning, error, or critical' ) cliOptParser.add_option( '-L', '--logfile', help='Set the file in which the log output should be written.' ) (options, args) = cliOptParser.parse_args() # Set the log level maven_repo_util.setLogLevel(options.loglevel, options.logfile) # generate lists of artifacts from configuration and the fetch them each list from it's repo artifactList = artifact_list_generator.generateArtifactList(options, args) artifact_downloader.fetchArtifactLists(artifactList, options.output, options.checksummode) logging.info('Generating missing checksums...') generateChecksums(options.output) logging.info('Repository created in directory: %s', options.output) #cleanup maven_repo_util.cleanTempDir()
def main(): description = "Generate artifact list from sources defined in the given configuration file" cliOptParser = optparse.OptionParser(usage="Usage: %prog -c CONFIG", description=description) cliOptParser.add_option( '-c', '--config', dest='config', help= 'Configuration file to use for generation of an artifact list for the repository builder' ) cliOptParser.add_option( '-a', '--classifiers', default='sources', help= 'Comma-separated list of additional classifiers to download. It is possible to use "__all__" to ' 'request all available classifiers. There can be a type specified with each classifiers separated ' 'by colon, e.g. sources:jar.') cliOptParser.add_option( '-x', '--excludedtypes', default='zip:ear:war:tar:gz:tar.gz:bz2:tar.bz2:7z:tar.7z', help='Colon-separated list of filetypes to exclude. Defaults to ' 'zip:ear:war:tar:gz:tar.gz:bz2:tar.bz2:7z:tar.7z.') cliOptParser.add_option( '--nocache', dest="cache", default=True, action='store_false', help='Don\'t use any cache (dependency graph cache etc.).') cliOptParser.add_option( '-w', '--whitelist', help= 'Name of a file containing GATCV patterns allowing usage of stars or regular expressions when enclosed ' 'in "r/pattern/". It can force inclusion of artifacts with excluded types.' ) cliOptParser.add_option( "-R", '--reportdir', dest="reportdir", default=None, help= 'Dir where to generate the repository analysis report. If not specified no report will be generated.' ) cliOptParser.add_option( "-N", '--reportname', dest="reportname", default="Maven Repository", help= 'Name of the repository to be used in the analysis report. It is used only when reportdir value is specified.' ) cliOptParser.add_option( '-l', '--loglevel', default='info', help= 'Set the level of log output. Can be set to debug, info, warning, error, or critical' ) cliOptParser.add_option( '-L', '--logfile', help='Set the file in which the log output should be written.') (options, args) = cliOptParser.parse_args() # Set the log level maven_repo_util.setLogLevel(options.loglevel, options.logfile) artifactList = _generateArtifactList(options, args) _printArtifactList(artifactList)
def main(): usage = "Usage: %prog [-c CONFIG] [-a CLASSIFIERS] [-u URL] [-o OUTPUT_DIRECTORY] [FILE...]" description = ( "Generate a Maven repository based on a file (or files) containing " "a list of artifacts. Each list file must contain a single artifact " "per line in the format groupId:artifactId:fileType:<classifier>:version " "The example artifact list contains more information. Another usage is " "to provide Artifact List Generator configuration file. There is also " "sample configuration file in examples.") # TODO: pkocandr - use argparse instead of optparse, which is deprecated since python 2.7 cliOptParser = optparse.OptionParser(usage=usage, description=description) cliOptParser.add_option( '-c', '--config', dest='config', help= 'Configuration file to use for generation of an artifact list for the repository builder' ) cliOptParser.add_option( '-u', '--url', default='http://repo1.maven.org/maven2/', help='URL of the remote repository from which artifacts are downloaded. ' 'It is used along with artifact list files when no config file is specified.' ) cliOptParser.add_option( '-o', '--output', default='local-maven-repository', help='Local output directory for the new repository') cliOptParser.add_option( '-a', '--classifiers', default='sources', help='Colon-separated list of additional classifiers to download. It is ' 'possible to use "__all__" to request all available classifiers ' '(works only when artifact list is generated from config).') cliOptParser.add_option( '-s', '--checksummode', default=ChecksumMode.generate, choices=(ChecksumMode.generate, ChecksumMode.download, ChecksumMode.check), help= 'Mode of dealing with MD5 and SHA1 checksums. Possible choices are: ' 'generate - generate the checksums (default) ' 'download - download the checksums if available, if not, generate them ' 'check - check if downloaded and generated checksums are equal') cliOptParser.add_option( '-x', '--excludedtypes', default='zip:ear:war:tar:gz:tar.gz:bz2:tar.bz2:7z:tar.7z', help='Colon-separated list of filetypes to exclude. Defaults to ' 'zip:ear:war:tar:gz:tar.gz:bz2:tar.bz2:7z:tar.7z.') cliOptParser.add_option( '-l', '--loglevel', default='info', help= 'Set the level of log output. Can be set to debug, info, warning, error, or critical' ) cliOptParser.add_option( '-L', '--logfile', help='Set the file in which the log output should be written.') (options, args) = cliOptParser.parse_args() # Set the log level maven_repo_util.setLogLevel(options.loglevel, options.logfile) if not options.classifiers or options.classifiers == '__all__': classifiers = [] else: classifiers = options.classifiers.split(":") if not options.excludedtypes: excludedtypes = [] else: excludedtypes = options.excludedtypes.split(":") if options.config is None: if len(args) < 1: logging.error( 'Missing required command line argument: path to artifact list file' ) sys.exit(usage) # Read the list(s) of dependencies from the specified files artifacts = [] for filename in args: if not os.path.isfile(filename): logging.warning( 'Dependency list file does not exist, skipping: %s', filename) continue logging.info('Reading artifact list from file: %s', filename) depListFile = open(filename) try: dependencyListLines = depListFile.readlines() artifacts.extend(depListToArtifactList(dependencyListLines)) except IOError as e: logging.exception('Unable to read file %s: %s', filename, str(e)) sys.exit(1) finally: depListFile.close() fetchArtifacts(options.url, options.output, artifacts, classifiers, excludedtypes, options.checksummode) else: # generate lists of artifacts from configuration and the fetch them each list from it's repo artifactList = artifact_list_generator.generateArtifactList(options) for repoUrl in artifactList.keys(): artifacts = artifactList[repoUrl] fetchArtifacts(repoUrl, options.output, artifacts, classifiers, excludedtypes, options.checksummode) logging.info('Generating missing checksums...') generateChecksums(options.output) logging.info('Repository created in directory: %s', options.output) #cleanup maven_repo_util.cleanTempDir()