validate).getModuleDescriptor();
validate); ModuleDescriptor md = report.getModuleDescriptor();
    public static void main(String[] args) throws Exception {        Options options = getOptions();                CommandLineParser parser = new GnuParser();        try {            // parse the command line arguments            CommandLine line = parser.parse( options, args );                        if (line.hasOption("?")) {                usage(options);                return;            }                        if (line.hasOption("debug")) {                Message.init(new DefaultMessageImpl(Message.MSG_DEBUG));            } else if (line.hasOption("verbose")) {                Message.init(new DefaultMessageImpl(Message.MSG_VERBOSE));            } else if (line.hasOption("warn")) {                Message.init(new DefaultMessageImpl(Message.MSG_WARN));            } else if (line.hasOption("error")) {                Message.init(new DefaultMessageImpl(Message.MSG_ERR));            } else {                Message.init(new DefaultMessageImpl(Message.MSG_INFO));            }                        boolean validate = line.hasOption("novalidate")?false:true;                        Ivy ivy = new Ivy();            ivy.addAllVariables(System.getProperties());            configureURLHandler(                    line.getOptionValue("realm", null),                     line.getOptionValue("host", null),                     line.getOptionValue("username", null),                     line.getOptionValue("passwd", null));                        String confPath = line.getOptionValue("conf", "");            if ("".equals(confPath)) {                ivy.configure(Ivy.class.getResource("ivyconf.xml"));            } else {                File conffile = new File(confPath);                if (!conffile.exists()) {                    error(options, "ivy configuration file not found: "+conffile);                } else if (conffile.isDirectory()) {                    error(options, "ivy configuration file is not a file: "+conffile);                }                ivy.configure(conffile);            }                        File cache = new File(ivy.substitute(line.getOptionValue("cache", ivy.getDefaultCache().getAbsolutePath())));            if (!cache.exists()) {                cache.mkdirs();            } else if (!cache.isDirectory()) {                error(options, cache+" is not a directory");            }                        String[] confs;            if (line.hasOption("confs")) {                confs = line.getOptionValues("confs");            } else {                confs = new String[] {"*"};            }            File ivyfile;            if (line.hasOption("dependency")) {                String[] dep = line.getOptionValues("dependency");                if (dep.length != 3) {                    error(options, "dependency should be expressed with exactly 3 arguments: organisation module revision");                }                ivyfile = File.createTempFile("ivy", ".xml");                ivyfile.deleteOnExit();                DefaultModuleDescriptor md = DefaultModuleDescriptor.newDefaultInstance(ModuleRevisionId.newInstance(dep[0], "standalone", "working"));                DefaultDependencyDescriptor dd = new DefaultDependencyDescriptor(md, ModuleRevisionId.newInstance(dep[0], dep[1], dep[2]), false, false, true);                for (int i = 0; i < confs.length; i++) {                    dd.addDependencyConfiguration("default", confs[i]);                }                md.addDependency(dd);                XmlModuleDescriptorWriter.write(md, ivyfile);                confs = new String[] {"default"};            } else {                ivyfile = new File(ivy.substitute(line.getOptionValue("ivy", "ivy.xml")));                if (!ivyfile.exists()) {                    error(options, "ivy file not found: "+ivyfile);                } else if (ivyfile.isDirectory()) {                    error(options, "ivy file is not a file: "+ivyfile);                }            }            Date date = new Date();                        ModuleDescriptor md = ivy.resolve(                    ivyfile.toURL(),                    null,                    confs,                     cache,                     date,                    validate).getModuleDescriptor();            if (confs.length == 1 && "*".equals(confs[0])) {                confs = md.getConfigurationsNames();            }            if (line.hasOption("retrieve")) {                String retrievePattern = ivy.substitute(line.getOptionValue("retrieve"));                if (retrievePattern.indexOf("[") == -1) {                    retrievePattern = retrievePattern + "/lib/[conf]/[artifact].[ext]";                }                ivy.retrieve(md.getModuleRevisionId().getModuleId(), confs, cache, retrievePattern);            }            if (line.hasOption("cachepath")) {                outputCachePath(ivy, cache, md, confs, line.getOptionValue("cachepath", "ivycachepath.txt"));            }            if (line.hasOption("revision")) {                ivy.deliver(                    md.getResolvedModuleRevisionId(),                    ivy.substitute(line.getOptionValue("revision")),                    cache,                     ivy.substitute(line.getOptionValue("deliverto", "ivy-[revision].xml")),                    ivy.substitute(line.getOptionValue("status", "release")),                    date,                    new DefaultPublishingDRResolver(),                    validate);                if (line.hasOption("publish")) {                    ivy.publish(                            md.getResolvedModuleRevisionId(),                             ivy.substitute(line.getOptionValue("revision")),                             cache,                             ivy.substitute(line.getOptionValue("publishpattern", "distrib/[type]s/[artifact]-[revision].[ext]")),                             line.getOptionValue("publish"),                             ivy.substitute(line.getOptionValue("deliverto", "ivy-[revision].xml")),                             validate);                                    }            }        } catch( ParseException exp ) {            // oops, something went wrong            System.err.println( "Parsing failed.  Reason: " + exp.getMessage() );                        usage(options);        }            }