in archiva-artifact-downloader-cli/src/main/java/org/apache/archiva/artifact/downloader/CLI.java [65:149]
private void execute( String[] args )
{
CommandLineParser parser = new GnuParser();
try
{
CommandLine cmdline = parser.parse( getOptions(), args );
if ( cmdline.hasOption( OPT_HELP ) )
{
showHelp( getOptions() );
return;
}
if ( cmdline.hasOption( OPT_PROXY_CONFIG ) )
{
SwingUtilities.invokeLater( new Runnable()
{
public void run()
{
NetworkProxyDialog.collectAndSave();
System.exit( -1 );
}
} );
return;
}
List<ArtifactKey> artifactKeys = new ArrayList<ArtifactKey>();
for ( String arg : cmdline.getArgs() )
{
artifactKeys.add( new ArtifactKey( arg ) );
}
if ( artifactKeys.isEmpty() )
{
System.err
.println( "ERROR: You must specify at least 1 Artifact Key in format groupId:artifactId:version" );
showHelp( getOptions() );
return;
}
Config config = loadDefaultConfig();
if ( cmdline.hasOption( OPT_CONFIG ) )
{
String configPath = cmdline.getOptionValue( OPT_CONFIG );
File configFile = new File( configPath );
if ( configFile.exists() == false )
{
System.err.println( "Unable to find config file: " + configFile.getAbsolutePath() );
return;
}
FileReader reader = new FileReader( configFile );
config = ConfigParser.parseConfig( reader );
}
String outputDir = cmdline.getOptionValue( OPT_REPO_DIR );
if ( outputDir == null )
{
outputDir = System.getProperty( "user.dir" );
}
File repoDir = new File( outputDir );
System.out.println( ".\\ Archiva Artifact Downloader \\._______________" );
Downloader downloader = new Downloader();
downloader.setArtifactKeys( artifactKeys );
downloader.setRepositoryDir( repoDir );
downloader.setConfig( config );
downloader.download();
}
catch ( MissingOptionException e )
{
System.err.println( "ERROR: " + e.getMessage() );
showHelp( options );
}
catch ( ParseException e )
{
showHelp( options );
e.printStackTrace( System.err );
}
catch ( Throwable t )
{
t.printStackTrace( System.err );
}
}