You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ivy-commits@incubator.apache.org by xa...@apache.org on 2007/06/05 12:34:40 UTC

svn commit: r544469 - in /incubator/ivy/core/trunk/src/java/org/apache/ivy: Ivy.java Ivy14.java Main.java

Author: xavier
Date: Tue Jun  5 05:34:39 2007
New Revision: 544469

URL: http://svn.apache.org/viewvc?view=rev&rev=544469
Log:
clean main classes to decrease number of checkstyle errors

Modified:
    incubator/ivy/core/trunk/src/java/org/apache/ivy/Ivy.java
    incubator/ivy/core/trunk/src/java/org/apache/ivy/Ivy14.java
    incubator/ivy/core/trunk/src/java/org/apache/ivy/Main.java

Modified: incubator/ivy/core/trunk/src/java/org/apache/ivy/Ivy.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/Ivy.java?view=diff&rev=544469&r1=544468&r2=544469
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/Ivy.java (original)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/Ivy.java Tue Jun  5 05:34:39 2007
@@ -18,7 +18,6 @@
 package org.apache.ivy;
 
 import java.io.File;
-import java.io.FileNotFoundException;
 import java.io.IOException;
 import java.net.URL;
 import java.text.ParseException;
@@ -62,18 +61,26 @@
 import org.apache.ivy.util.filter.Filter;
 
 /**
- * <a href="http://incubator.apache.org/ivy/">Ivy</a> is a free java based dependency manager. This
- * class is the main class of Ivy, which acts as a Facade to all services offered by Ivy:
+ * <a href="http://incubator.apache.org/ivy/">Ivy</a> is a free java based dependency manager.
+ * <p>
+ * This class is the main class of Ivy, which acts as a Facade to all services offered by Ivy:
  * <ul>
  * <li>resolve dependencies</li>
  * <li>retrieve artifacts to a local location</li>
  * <li>deliver and publish modules</li>
  * <li>repository search and listing</li>
  * </li>
- * Here is one typical usage: Ivy ivy = Ivy.newInstance(); ivy.configure(new
- * URL("ivysettings.xml")); ivy.resolve(new URL("ivy.xml"));
+ * Here is one typical usage:
+ * 
+ * <pre>
+ * Ivy ivy = Ivy.newInstance();
+ * ivy.configure(new URL(&quot;ivysettings.xml&quot;));
+ * ivy.resolve(new URL(&quot;ivy.xml&quot;));
+ * </pre>
  */
 public class Ivy {
+    private static final int KILO = 1024;
+
     public static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("yyyyMMddHHmmss");
 
     public static Ivy newInstance() {
@@ -92,39 +99,39 @@
     /**
      * True if the current processing has been requested to be interrupted, false otherwise
      */
-    private boolean _interrupted;
+    private boolean interrupted;
 
     /**
      * True if this instance of Ivy hass already been bound to its dependencies, false otherwise.
      * 
      * @see bind()
      */
-    private boolean _bound;
+    private boolean bound;
 
     /*
      * Following are dependencies of the Ivy instance on instances of engines and manager which
      * actually do the work The attributes can be set either manually using the corresponding
      * setters, or all at once with the default implementations using the bind method
      */
-    private IvySettings _settings;
+    private IvySettings settings;
 
-    private EventManager _eventManager;
+    private EventManager eventManager;
 
-    private SortEngine _sortEngine;
+    private SortEngine sortEngine;
 
-    private SearchEngine _searchEngine;
+    private SearchEngine searchEngine;
 
-    private CheckEngine _checkEngine;
+    private CheckEngine checkEngine;
 
-    private ResolveEngine _resolveEngine;
+    private ResolveEngine resolveEngine;
 
-    private RetrieveEngine _retrieveEngine;
+    private RetrieveEngine retrieveEngine;
 
-    private DeliverEngine _deliverEngine;
+    private DeliverEngine deliverEngine;
 
-    private PublishEngine _publishEngine;
+    private PublishEngine publishEngine;
 
-    private InstallEngine _installEngine;
+    private InstallEngine installEngine;
 
     /**
      * The default constructor of Ivy allows to create an instance of Ivy with none of its
@@ -144,43 +151,42 @@
      */
     public void bind() {
         IvyContext.getContext().setIvy(this);
-        if (_settings == null) {
-            _settings = new IvySettings();
+        if (settings == null) {
+            settings = new IvySettings();
         }
-        if (_eventManager == null) {
-            _eventManager = new EventManager();
+        if (eventManager == null) {
+            eventManager = new EventManager();
         }
-        if (_sortEngine == null) {
-            _sortEngine = new SortEngine(_settings);
+        if (sortEngine == null) {
+            sortEngine = new SortEngine(settings);
         }
-        if (_searchEngine == null) {
-            _searchEngine = new SearchEngine(_settings);
+        if (searchEngine == null) {
+            searchEngine = new SearchEngine(settings);
         }
-        if (_resolveEngine == null) {
-            _resolveEngine = new ResolveEngine(_settings, _eventManager, _sortEngine);
+        if (resolveEngine == null) {
+            resolveEngine = new ResolveEngine(settings, eventManager, sortEngine);
         }
-        if (_retrieveEngine == null) {
-            _retrieveEngine = new RetrieveEngine(_settings);
+        if (retrieveEngine == null) {
+            retrieveEngine = new RetrieveEngine(settings);
         }
-        if (_deliverEngine == null) {
-            _deliverEngine = new DeliverEngine(_settings);
+        if (deliverEngine == null) {
+            deliverEngine = new DeliverEngine(settings);
         }
-        if (_publishEngine == null) {
-            _publishEngine = new PublishEngine(_settings);
+        if (publishEngine == null) {
+            publishEngine = new PublishEngine(settings);
         }
-        if (_installEngine == null) {
-            _installEngine = new InstallEngine(_settings, _searchEngine, _resolveEngine,
-                    _publishEngine);
+        if (installEngine == null) {
+            installEngine = new InstallEngine(settings, searchEngine, resolveEngine, publishEngine);
         }
 
-        _eventManager.addTransferListener(new TransferListener() {
+        eventManager.addTransferListener(new TransferListener() {
             public void transferProgress(TransferEvent evt) {
                 switch (evt.getEventType()) {
                     case TransferEvent.TRANSFER_PROGRESS:
                         Message.progress();
                         break;
                     case TransferEvent.TRANSFER_COMPLETED:
-                        Message.endProgress(" (" + (evt.getTotalLength() / 1024) + "kB)");
+                        Message.endProgress(" (" + (evt.getTotalLength() / KILO) + "kB)");
                         break;
                     default:
                         break;
@@ -188,7 +194,7 @@
             }
         });
 
-        _bound = true;
+        bound = true;
     }
 
     // ///////////////////////////////////////////////////////////////////////
@@ -196,19 +202,19 @@
     // ///////////////////////////////////////////////////////////////////////
     public void configure(File settingsFile) throws ParseException, IOException {
         assertBound();
-        _settings.load(settingsFile);
+        settings.load(settingsFile);
         postConfigure();
     }
 
     public void configure(URL settingsURL) throws ParseException, IOException {
         assertBound();
-        _settings.load(settingsURL);
+        settings.load(settingsURL);
         postConfigure();
     }
 
     public void configureDefault() throws ParseException, IOException {
         assertBound();
-        _settings.loadDefault();
+        settings.loadDefault();
         postConfigure();
     }
 
@@ -217,7 +223,7 @@
      */
     public void configureDefault14() throws ParseException, IOException {
         assertBound();
-        _settings.loadDefault14();
+        settings.loadDefault14();
         postConfigure();
     }
 
@@ -225,7 +231,7 @@
     // CHECK
     // ///////////////////////////////////////////////////////////////////////
     public boolean check(URL ivyFile, String resolvername) {
-        return _checkEngine.check(ivyFile, resolvername);
+        return checkEngine.check(ivyFile, resolvername);
     }
 
     // ///////////////////////////////////////////////////////////////////////
@@ -233,26 +239,26 @@
     // ///////////////////////////////////////////////////////////////////////
 
     public ResolveReport resolve(File ivySource) throws ParseException, IOException {
-        return _resolveEngine.resolve(ivySource);
+        return resolveEngine.resolve(ivySource);
     }
 
     public ResolveReport resolve(URL ivySource) throws ParseException, IOException {
-        return _resolveEngine.resolve(ivySource);
+        return resolveEngine.resolve(ivySource);
     }
 
     public ResolveReport resolve(ModuleRevisionId mrid, ResolveOptions options, boolean changing)
             throws ParseException, IOException {
-        return _resolveEngine.resolve(mrid, options, changing);
+        return resolveEngine.resolve(mrid, options, changing);
     }
 
     public ResolveReport resolve(URL ivySource, ResolveOptions options) throws ParseException,
             IOException {
-        return _resolveEngine.resolve(ivySource, options);
+        return resolveEngine.resolve(ivySource, options);
     }
 
     public ResolveReport resolve(ModuleDescriptor md, ResolveOptions options)
-            throws ParseException, IOException, FileNotFoundException {
-        return _resolveEngine.resolve(md, options);
+            throws ParseException, IOException {
+        return resolveEngine.resolve(md, options);
     }
 
     // ///////////////////////////////////////////////////////////////////////
@@ -262,7 +268,7 @@
     public ResolveReport install(ModuleRevisionId mrid, String from, String to, boolean transitive,
             boolean validate, boolean overwrite, Filter artifactFilter, File cache,
             String matcherName) throws IOException {
-        return _installEngine.install(mrid, from, to, transitive, validate, overwrite,
+        return installEngine.install(mrid, from, to, transitive, validate, overwrite,
             artifactFilter, cache, matcherName);
     }
 
@@ -272,7 +278,7 @@
 
     public int retrieve(ModuleRevisionId mrid, String destFilePattern, RetrieveOptions options)
             throws IOException {
-        return _retrieveEngine.retrieve(mrid, destFilePattern, options);
+        return retrieveEngine.retrieve(mrid, destFilePattern, options);
     }
 
     // ///////////////////////////////////////////////////////////////////////
@@ -281,13 +287,12 @@
 
     public void deliver(ModuleRevisionId mrid, String revision, String destIvyPattern)
             throws IOException, ParseException {
-        _deliverEngine.deliver(mrid, revision, destIvyPattern, DeliverOptions
-                .newInstance(_settings));
+        deliverEngine.deliver(mrid, revision, destIvyPattern, DeliverOptions.newInstance(settings));
     }
 
     public void deliver(String revision, String destIvyPattern, DeliverOptions options)
             throws IOException, ParseException {
-        _deliverEngine.deliver(revision, destIvyPattern, options);
+        deliverEngine.deliver(revision, destIvyPattern, options);
     }
 
     /**
@@ -303,7 +308,7 @@
      */
     public void deliver(ModuleRevisionId mrid, String revision, String destIvyPattern,
             DeliverOptions options) throws IOException, ParseException {
-        _deliverEngine.deliver(mrid, revision, destIvyPattern, options);
+        deliverEngine.deliver(mrid, revision, destIvyPattern, options);
     }
 
     // ///////////////////////////////////////////////////////////////////////
@@ -312,7 +317,7 @@
 
     public Collection publish(ModuleRevisionId mrid, Collection srcArtifactPattern,
             String resolverName, PublishOptions options) throws IOException {
-        return _publishEngine.publish(mrid, srcArtifactPattern, resolverName, options);
+        return publishEngine.publish(mrid, srcArtifactPattern, resolverName, options);
     }
 
     // ///////////////////////////////////////////////////////////////////////
@@ -323,7 +328,7 @@
      * Sorts the collection of IvyNode from the less dependent to the more dependent
      */
     public List sortNodes(Collection nodes) {
-        return _sortEngine.sortNodes(nodes);
+        return sortEngine.sortNodes(nodes);
     }
 
     /**
@@ -336,12 +341,12 @@
      * @return a List of sorted ModuleDescriptors
      */
     public List sortModuleDescriptors(Collection moduleDescriptors) {
-        return _sortEngine.sortModuleDescriptors(moduleDescriptors);
+        return sortEngine.sortModuleDescriptors(moduleDescriptors);
     }
 
     public List sortModuleDescriptors(Collection moduleDescriptors,
             NonMatchingVersionReporter nonMatchingVersionReporter) {
-        return _sortEngine.sortModuleDescriptors(moduleDescriptors, nonMatchingVersionReporter);
+        return sortEngine.sortModuleDescriptors(moduleDescriptors, nonMatchingVersionReporter);
     }
 
     // ///////////////////////////////////////////////////////////////////////
@@ -351,44 +356,44 @@
     public ResolvedModuleRevision findModule(ModuleRevisionId mrid) {
         ResolveOptions options = new ResolveOptions();
         options.setValidate(false);
-        options.setCache(CacheManager.getInstance(_settings));
-        return _resolveEngine.findModule(mrid, options);
+        options.setCache(CacheManager.getInstance(settings));
+        return resolveEngine.findModule(mrid, options);
     }
 
     public ModuleEntry[] listModuleEntries(OrganisationEntry org) {
-        return _searchEngine.listModuleEntries(org);
+        return searchEngine.listModuleEntries(org);
     }
 
     public ModuleId[] listModules(ModuleId criteria, PatternMatcher matcher) {
-        return _searchEngine.listModules(criteria, matcher);
+        return searchEngine.listModules(criteria, matcher);
     }
 
     public ModuleRevisionId[] listModules(ModuleRevisionId criteria, PatternMatcher matcher) {
-        return _searchEngine.listModules(criteria, matcher);
+        return searchEngine.listModules(criteria, matcher);
     }
 
     public String[] listModules(String org) {
-        return _searchEngine.listModules(org);
+        return searchEngine.listModules(org);
     }
 
     public OrganisationEntry[] listOrganisationEntries() {
-        return _searchEngine.listOrganisationEntries();
+        return searchEngine.listOrganisationEntries();
     }
 
     public String[] listOrganisations() {
-        return _searchEngine.listOrganisations();
+        return searchEngine.listOrganisations();
     }
 
     public RevisionEntry[] listRevisionEntries(ModuleEntry module) {
-        return _searchEngine.listRevisionEntries(module);
+        return searchEngine.listRevisionEntries(module);
     }
 
     public String[] listRevisions(String org, String module) {
-        return _searchEngine.listRevisions(org, module);
+        return searchEngine.listRevisions(org, module);
     }
 
     public String[] listTokenValues(String token, Map otherTokenValues) {
-        return _searchEngine.listTokenValues(token, otherTokenValues);
+        return searchEngine.listTokenValues(token, otherTokenValues);
     }
 
     // ///////////////////////////////////////////////////////////////////////
@@ -416,25 +421,27 @@
             Message.verbose("interrupting operating thread...");
             operatingThread.interrupt();
             synchronized (this) {
-                _interrupted = true;
+                interrupted = true;
             }
             try {
                 Message.verbose("waiting clean interruption of operating thread");
-                operatingThread.join(_settings.getInterruptTimeout());
+                operatingThread.join(settings.getInterruptTimeout());
             } catch (InterruptedException e) {
+                // reset thread interrupt status
+                Thread.currentThread().interrupt();
             }
             if (operatingThread.isAlive()) {
                 Message.warn("waited clean interruption for too long: stopping operating thread");
                 operatingThread.stop();
             }
             synchronized (this) {
-                _interrupted = false;
+                interrupted = false;
             }
         }
     }
 
     public synchronized boolean isInterrupted() {
-        return _interrupted;
+        return interrupted;
     }
 
     /**
@@ -454,37 +461,37 @@
 
     public CacheManager getCacheManager(File cache) {
         // TODO : reuse instance
-        CacheManager cacheManager = new CacheManager(_settings, cache);
+        CacheManager cacheManager = new CacheManager(settings, cache);
         return cacheManager;
     }
 
     private void assertBound() {
-        if (!_bound) {
+        if (!bound) {
             bind();
         }
     }
 
     private void postConfigure() {
-        Collection triggers = _settings.getTriggers();
+        Collection triggers = settings.getTriggers();
         for (Iterator iter = triggers.iterator(); iter.hasNext();) {
             Trigger trigger = (Trigger) iter.next();
-            _eventManager.addIvyListener(trigger, trigger.getEventFilter());
+            eventManager.addIvyListener(trigger, trigger.getEventFilter());
         }
     }
 
     public String getVariable(String name) {
         assertBound();
-        return _settings.getVariable(name);
+        return settings.getVariable(name);
     }
 
     public String substitute(String str) {
         assertBound();
-        return _settings.substitute(str);
+        return settings.substitute(str);
     }
 
     public void setVariable(String varName, String value) {
         assertBound();
-        _settings.setVariable(varName, value);
+        settings.setVariable(varName, value);
     }
 
     // ///////////////////////////////////////////////////////////////////
@@ -492,83 +499,83 @@
     // ///////////////////////////////////////////////////////////////////
 
     public IvySettings getSettings() {
-        return _settings;
+        return settings;
     }
 
     public EventManager getEventManager() {
-        return _eventManager;
+        return eventManager;
     }
 
     public CheckEngine getCheckEngine() {
-        return _checkEngine;
+        return checkEngine;
     }
 
     public void setCheckEngine(CheckEngine checkEngine) {
-        _checkEngine = checkEngine;
+        this.checkEngine = checkEngine;
     }
 
     public DeliverEngine getDeliverEngine() {
-        return _deliverEngine;
+        return deliverEngine;
     }
 
     public void setDeliverEngine(DeliverEngine deliverEngine) {
-        _deliverEngine = deliverEngine;
+        this.deliverEngine = deliverEngine;
     }
 
     public InstallEngine getInstallEngine() {
-        return _installEngine;
+        return installEngine;
     }
 
     public void setInstallEngine(InstallEngine installEngine) {
-        _installEngine = installEngine;
+        this.installEngine = installEngine;
     }
 
     public PublishEngine getPublishEngine() {
-        return _publishEngine;
+        return publishEngine;
     }
 
     public void setPublishEngine(PublishEngine publishEngine) {
-        _publishEngine = publishEngine;
+        this.publishEngine = publishEngine;
     }
 
     public ResolveEngine getResolveEngine() {
-        return _resolveEngine;
+        return resolveEngine;
     }
 
     public void setResolveEngine(ResolveEngine resolveEngine) {
-        _resolveEngine = resolveEngine;
+        this.resolveEngine = resolveEngine;
     }
 
     public RetrieveEngine getRetrieveEngine() {
-        return _retrieveEngine;
+        return retrieveEngine;
     }
 
     public void setRetrieveEngine(RetrieveEngine retrieveEngine) {
-        _retrieveEngine = retrieveEngine;
+        this.retrieveEngine = retrieveEngine;
     }
 
     public SearchEngine getSearchEngine() {
-        return _searchEngine;
+        return searchEngine;
     }
 
     public void setSearchEngine(SearchEngine searchEngine) {
-        _searchEngine = searchEngine;
+        this.searchEngine = searchEngine;
     }
 
     public SortEngine getSortEngine() {
-        return _sortEngine;
+        return sortEngine;
     }
 
     public void setSortEngine(SortEngine sortEngine) {
-        _sortEngine = sortEngine;
+        this.sortEngine = sortEngine;
     }
 
     public void setEventManager(EventManager eventManager) {
-        _eventManager = eventManager;
+        this.eventManager = eventManager;
     }
 
     public void setSettings(IvySettings settings) {
-        _settings = settings;
+        this.settings = settings;
     }
 
 }

Modified: incubator/ivy/core/trunk/src/java/org/apache/ivy/Ivy14.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/Ivy14.java?view=diff&rev=544469&r1=544468&r2=544469
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/Ivy14.java (original)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/Ivy14.java Tue Jun  5 05:34:39 2007
@@ -18,7 +18,6 @@
 package org.apache.ivy;
 
 import java.io.File;
-import java.io.FileNotFoundException;
 import java.io.IOException;
 import java.net.URL;
 import java.text.ParseException;
@@ -51,93 +50,112 @@
 import org.apache.ivy.util.filter.FilterHelper;
 
 /**
- * This class can be used for easy migration from Ivy 1.4 API. Indeed, Ivy 2.0 API has changed
- * substantially, so it can take time to migrate existing code using Ivy 1.4 API to the new API.
- * Using this class it's really easy: replace your instance of Ivy by an instance of this class. For
- * instance, where you were doing: Ivy ivy = new Ivy(); do instead: Ivy14 ivy = new Ivy14(); And
- * that should be enough in most cases!
+ * This class can be used for easy migration from Ivy 1.4 API.
+ * <p>
+ * Indeed, Ivy 2.0 API has changed substantially, so it can take time to migrate existing code using
+ * Ivy 1.4 API to the new API. Using this class it's really easy: replace your instance of Ivy by an
+ * instance of this class.
+ * <p>
+ * For instance, where you were doing:
+ * 
+ * <pre>
+ * Ivy ivy = new Ivy();
+ * </pre>
+ * 
+ * do instead:
+ * 
+ * <pre>
+ * Ivy14 ivy = new Ivy14();
+ * </pre>
+ * 
+ * And that should be enough in most cases!
  */
 public class Ivy14 {
-    private Ivy _ivy;
+    //CheckStyle:ParameterNumberCheck OFF
+    // don't check parameter numbers, since this class is here for backward compatibility
+    
+    
+    private Ivy ivy;
 
     public Ivy14() {
         this(Ivy.newInstance());
     }
 
     public Ivy14(Ivy ivy) {
-        _ivy = ivy;
+        this.ivy = ivy;
     }
 
     public boolean check(URL ivyFile, String resolvername) {
-        return _ivy.check(ivyFile, resolvername);
+        return ivy.check(ivyFile, resolvername);
     }
 
     public void configure(File settingsFile) throws ParseException, IOException {
-        _ivy.configure(settingsFile);
+        ivy.configure(settingsFile);
     }
 
     public void configure(URL settingsURL) throws ParseException, IOException {
-        _ivy.configure(settingsURL);
+        ivy.configure(settingsURL);
     }
 
     public void configureDefault() throws ParseException, IOException {
-        _ivy.configureDefault();
+        ivy.configureDefault();
     }
 
     public void deliver(ModuleRevisionId mrid, String revision, File cache, String destIvyPattern,
             String status, Date pubdate, PublishingDependencyRevisionResolver pdrResolver,
             boolean validate, boolean resolveDynamicRevisions) throws IOException, ParseException {
-        _ivy.deliver(mrid, revision, destIvyPattern, new DeliverOptions(status, pubdate,
-                CacheManager.getInstance(_ivy.getSettings(), cache), pdrResolver, validate,
+        ivy.deliver(mrid, revision, destIvyPattern, new DeliverOptions(status, pubdate,
+                CacheManager.getInstance(ivy.getSettings(), cache), pdrResolver, validate,
                 resolveDynamicRevisions, null));
     }
 
     public void deliver(ModuleRevisionId mrid, String revision, File cache, String destIvyPattern,
             String status, Date pubdate, PublishingDependencyRevisionResolver pdrResolver,
             boolean validate) throws IOException, ParseException {
-        deliver(mrid, revision, cache, destIvyPattern, status, pubdate, pdrResolver, validate, true);
+        deliver(mrid, revision, cache, destIvyPattern, status, 
+            pubdate, pdrResolver, validate, true);
     }
 
     public Map determineArtifactsToCopy(ModuleId moduleId, String[] confs, File cache,
             String destFilePattern, String destIvyPattern, Filter artifactFilter)
             throws ParseException, IOException {
-        return _ivy.getRetrieveEngine().determineArtifactsToCopy(
+        return ivy.getRetrieveEngine().determineArtifactsToCopy(
             new ModuleRevisionId(moduleId, Ivy.getWorkingRevision()),
             destFilePattern,
             new RetrieveOptions().setConfs(confs).setCache(
-                CacheManager.getInstance(_ivy.getSettings(), cache)).setDestIvyPattern(
+                CacheManager.getInstance(ivy.getSettings(), cache)).setDestIvyPattern(
                 destIvyPattern).setArtifactFilter(artifactFilter));
     }
 
     public Map determineArtifactsToCopy(ModuleId moduleId, String[] confs, File cache,
             String destFilePattern, String destIvyPattern) throws ParseException, IOException {
-        return _ivy.getRetrieveEngine().determineArtifactsToCopy(
+        return ivy.getRetrieveEngine().determineArtifactsToCopy(
             new ModuleRevisionId(moduleId, Ivy.getWorkingRevision()),
             destFilePattern,
             new RetrieveOptions().setConfs(confs).setCache(
-                CacheManager.getInstance(_ivy.getSettings(), cache)).setDestIvyPattern(
+                CacheManager.getInstance(ivy.getSettings(), cache)).setDestIvyPattern(
                 destIvyPattern));
     }
 
     public ArtifactDownloadReport download(Artifact artifact, File cache, boolean useOrigin) {
-        return _ivy.getResolveEngine().download(artifact, _ivy.getCacheManager(cache), useOrigin);
+        return ivy.getResolveEngine().download(artifact, ivy.getCacheManager(cache), useOrigin);
     }
 
     public void downloadArtifacts(ResolveReport report, CacheManager cacheManager,
             boolean useOrigin, Filter artifactFilter) {
-        _ivy.getResolveEngine().downloadArtifacts(report, cacheManager, useOrigin, artifactFilter);
+        ivy.getResolveEngine().downloadArtifacts(report, cacheManager, useOrigin, artifactFilter);
     }
 
     public ResolvedModuleRevision findModule(ModuleRevisionId id) {
         ResolveOptions options = new ResolveOptions();
         options.setValidate(false);
-        options.setCache(CacheManager.getInstance(_ivy.getSettings()));
-        return _ivy.getResolveEngine().findModule(id, options);
+        options.setCache(CacheManager.getInstance(ivy.getSettings()));
+        return ivy.getResolveEngine().findModule(id, options);
     }
 
     public IvyNode[] getDependencies(ModuleDescriptor md, String[] confs, File cache, Date date,
             ResolveReport report, boolean validate, boolean transitive) {
-        return _ivy.getResolveEngine().getDependencies(
+        return ivy.getResolveEngine().getDependencies(
             md,
             newResolveOptions(confs, null, cache, date, validate, false, transitive, false, true,
                 true, FilterHelper.NO_FILTER), report);
@@ -145,7 +163,7 @@
 
     public IvyNode[] getDependencies(ModuleDescriptor md, String[] confs, File cache, Date date,
             ResolveReport report, boolean validate) {
-        return _ivy.getResolveEngine().getDependencies(
+        return ivy.getResolveEngine().getDependencies(
             md,
             newResolveOptions(confs, null, cache, date, validate, false, true, false, true, true,
                 FilterHelper.NO_FILTER), report);
@@ -153,75 +171,75 @@
 
     public IvyNode[] getDependencies(URL ivySource, String[] confs, File cache, Date date,
             boolean validate) throws ParseException, IOException {
-        return _ivy.getResolveEngine().getDependencies(
+        return ivy.getResolveEngine().getDependencies(
             ivySource,
             newResolveOptions(confs, null, cache, date, validate, false, true, false, true, true,
                 FilterHelper.NO_FILTER));
     }
 
     public String getVariable(String name) {
-        return _ivy.getVariable(name);
+        return ivy.getVariable(name);
     }
 
     public ResolveReport install(ModuleRevisionId mrid, String from, String to, boolean transitive,
             boolean validate, boolean overwrite, Filter artifactFilter, File cache,
             String matcherName) throws IOException {
-        return _ivy.install(mrid, from, to, transitive, validate, overwrite, artifactFilter, cache,
+        return ivy.install(mrid, from, to, transitive, validate, overwrite, artifactFilter, cache,
             matcherName);
     }
 
     public void interrupt() {
-        _ivy.interrupt();
+        ivy.interrupt();
     }
 
     public void interrupt(Thread operatingThread) {
-        _ivy.interrupt(operatingThread);
+        ivy.interrupt(operatingThread);
     }
 
     public boolean isInterrupted() {
-        return _ivy.isInterrupted();
+        return ivy.isInterrupted();
     }
 
     public ModuleEntry[] listModuleEntries(OrganisationEntry org) {
-        return _ivy.listModuleEntries(org);
+        return ivy.listModuleEntries(org);
     }
 
     public ModuleId[] listModules(ModuleId criteria, PatternMatcher matcher) {
-        return _ivy.listModules(criteria, matcher);
+        return ivy.listModules(criteria, matcher);
     }
 
     public ModuleRevisionId[] listModules(ModuleRevisionId criteria, PatternMatcher matcher) {
-        return _ivy.listModules(criteria, matcher);
+        return ivy.listModules(criteria, matcher);
     }
 
     public String[] listModules(String org) {
-        return _ivy.listModules(org);
+        return ivy.listModules(org);
     }
 
     public OrganisationEntry[] listOrganisationEntries() {
-        return _ivy.listOrganisationEntries();
+        return ivy.listOrganisationEntries();
     }
 
     public String[] listOrganisations() {
-        return _ivy.listOrganisations();
+        return ivy.listOrganisations();
     }
 
     public RevisionEntry[] listRevisionEntries(ModuleEntry module) {
-        return _ivy.listRevisionEntries(module);
+        return ivy.listRevisionEntries(module);
     }
 
     public String[] listRevisions(String org, String module) {
-        return _ivy.listRevisions(org, module);
+        return ivy.listRevisions(org, module);
     }
 
     public String[] listTokenValues(String token, Map otherTokenValues) {
-        return _ivy.listTokenValues(token, otherTokenValues);
+        return ivy.listTokenValues(token, otherTokenValues);
     }
 
     public Collection publish(ModuleDescriptor md, DependencyResolver resolver,
             Collection srcArtifactPattern, String srcIvyPattern, Artifact[] extraArtifacts,
             boolean overwrite, String conf) throws IOException {
-        return _ivy.getPublishEngine().publish(
+        return ivy.getPublishEngine().publish(
             md,
             srcArtifactPattern,
             resolver,
@@ -233,8 +251,8 @@
             Collection srcArtifactPattern, String resolverName, String srcIvyPattern,
             String status, Date pubdate, Artifact[] extraArtifacts, boolean validate,
             boolean overwrite, boolean update, String conf) throws IOException {
-        return _ivy.publish(mrid, srcArtifactPattern, resolverName, new PublishOptions().setCache(
-            _ivy.getCacheManager(cache == null ? _ivy.getSettings().getDefaultCache() : cache))
+        return ivy.publish(mrid, srcArtifactPattern, resolverName, new PublishOptions().setCache(
+            ivy.getCacheManager(cache == null ? ivy.getSettings().getDefaultCache() : cache))
                 .setStatus(status).setPubdate(pubdate).setPubrevision(pubrevision)
                 .setSrcIvyPattern(srcIvyPattern).setExtraArtifacts(extraArtifacts)
                 .setUpdate(update).setValidate(validate).setOverwrite(overwrite).setConfs(
@@ -244,9 +262,9 @@
     public Collection publish(ModuleRevisionId mrid, String pubrevision, File cache,
             String srcArtifactPattern, String resolverName, String srcIvyPattern, boolean validate,
             boolean overwrite) throws IOException {
-        return _ivy.publish(mrid, Collections.singleton(srcArtifactPattern), resolverName,
+        return ivy.publish(mrid, Collections.singleton(srcArtifactPattern), resolverName,
             new PublishOptions().setCache(
-                _ivy.getCacheManager(cache == null ? _ivy.getSettings().getDefaultCache() : cache))
+                ivy.getCacheManager(cache == null ? ivy.getSettings().getDefaultCache() : cache))
                     .setPubrevision(pubrevision).setSrcIvyPattern(srcIvyPattern).setValidate(
                         validate).setOverwrite(overwrite));
     }
@@ -254,9 +272,9 @@
     public Collection publish(ModuleRevisionId mrid, String pubrevision, File cache,
             String srcArtifactPattern, String resolverName, String srcIvyPattern, boolean validate)
             throws IOException {
-        return _ivy.publish(mrid, Collections.singleton(srcArtifactPattern), resolverName,
+        return ivy.publish(mrid, Collections.singleton(srcArtifactPattern), resolverName,
             new PublishOptions().setCache(
-                _ivy.getCacheManager(cache == null ? _ivy.getSettings().getDefaultCache() : cache))
+                ivy.getCacheManager(cache == null ? ivy.getSettings().getDefaultCache() : cache))
                     .setPubrevision(pubrevision).setSrcIvyPattern(srcIvyPattern).setValidate(
                         validate));
     }
@@ -265,9 +283,9 @@
             String srcArtifactPattern, String resolverName, String srcIvyPattern, String status,
             Date pubdate, Artifact[] extraArtifacts, boolean validate, boolean overwrite,
             boolean update, String conf) throws IOException {
-        return _ivy.publish(mrid, Collections.singleton(srcArtifactPattern), resolverName,
+        return ivy.publish(mrid, Collections.singleton(srcArtifactPattern), resolverName,
             new PublishOptions().setCache(
-                _ivy.getCacheManager(cache == null ? _ivy.getSettings().getDefaultCache() : cache))
+                ivy.getCacheManager(cache == null ? ivy.getSettings().getDefaultCache() : cache))
                     .setStatus(status).setPubdate(pubdate).setPubrevision(pubrevision)
                     .setSrcIvyPattern(srcIvyPattern).setExtraArtifacts(extraArtifacts).setUpdate(
                         update).setValidate(validate).setOverwrite(overwrite).setConfs(
@@ -275,14 +293,14 @@
     }
 
     public ResolveReport resolve(File ivySource) throws ParseException, IOException {
-        return _ivy.resolve(ivySource);
+        return ivy.resolve(ivySource);
     }
 
     public ResolveReport resolve(ModuleDescriptor md, String[] confs, File cache, Date date,
             boolean validate, boolean useCacheOnly, boolean transitive, boolean useOrigin,
             boolean download, boolean outputReport, Filter artifactFilter) throws ParseException,
-            IOException, FileNotFoundException {
-        return _ivy.resolve(md, newResolveOptions(confs, null, cache, date, validate, useCacheOnly,
+            IOException {
+        return ivy.resolve(md, newResolveOptions(confs, null, cache, date, validate, useCacheOnly,
             transitive, useOrigin, download, outputReport, artifactFilter));
     }
 
@@ -290,7 +308,7 @@
             Date date, boolean validate, boolean useCacheOnly, boolean transitive,
             boolean useOrigin, boolean download, boolean outputReport, Filter artifactFilter) {
         return new ResolveOptions().setConfs(confs).setRevision(revision).setCache(
-            _ivy.getCacheManager(cache == null ? _ivy.getSettings().getDefaultCache() : cache))
+            ivy.getCacheManager(cache == null ? ivy.getSettings().getDefaultCache() : cache))
                 .setValidate(validate).setUseCacheOnly(useCacheOnly).setTransitive(transitive)
                 .setUseOrigin(useOrigin).setDownload(download).setOutputReport(outputReport)
                 .setArtifactFilter(artifactFilter);
@@ -298,91 +316,90 @@
 
     public ResolveReport resolve(ModuleDescriptor md, String[] confs, File cache, Date date,
             boolean validate, boolean useCacheOnly, boolean transitive, boolean download,
-            boolean outputReport, Filter artifactFilter) throws ParseException, IOException,
-            FileNotFoundException {
-        return _ivy.resolve(md, newResolveOptions(confs, null, cache, date, validate, useCacheOnly,
+            boolean outputReport, Filter artifactFilter) throws ParseException, IOException {
+        return ivy.resolve(md, newResolveOptions(confs, null, cache, date, validate, useCacheOnly,
             transitive, false, download, outputReport, artifactFilter));
     }
 
     public ResolveReport resolve(ModuleDescriptor md, String[] confs, File cache, Date date,
             boolean validate, boolean useCacheOnly, boolean transitive, Filter artifactFilter)
-            throws ParseException, IOException, FileNotFoundException {
-        return _ivy.resolve(md, newResolveOptions(confs, null, cache, date, validate, useCacheOnly,
+            throws ParseException, IOException {
+        return ivy.resolve(md, newResolveOptions(confs, null, cache, date, validate, useCacheOnly,
             transitive, false, true, true, artifactFilter));
     }
 
     public ResolveReport resolve(ModuleDescriptor md, String[] confs, File cache, Date date,
             boolean validate, boolean useCacheOnly, Filter artifactFilter) throws ParseException,
-            IOException, FileNotFoundException {
-        return _ivy.resolve(md, newResolveOptions(confs, null, cache, date, validate, useCacheOnly,
+            IOException {
+        return ivy.resolve(md, newResolveOptions(confs, null, cache, date, validate, useCacheOnly,
             true, false, true, true, artifactFilter));
     }
 
     public ResolveReport resolve(ModuleRevisionId mrid, String[] confs, boolean transitive,
             boolean changing, File cache, Date date, boolean validate, boolean useCacheOnly,
             boolean useOrigin, Filter artifactFilter) throws ParseException, IOException {
-        return _ivy.resolve(mrid, newResolveOptions(confs, null, cache, date, validate,
+        return ivy.resolve(mrid, newResolveOptions(confs, null, cache, date, validate,
             useCacheOnly, transitive, useOrigin, true, true, artifactFilter), changing);
     }
 
     public ResolveReport resolve(ModuleRevisionId mrid, String[] confs, boolean transitive,
             boolean changing, File cache, Date date, boolean validate, boolean useCacheOnly,
             Filter artifactFilter) throws ParseException, IOException {
-        return _ivy.resolve(mrid, newResolveOptions(confs, null, cache, date, validate,
+        return ivy.resolve(mrid, newResolveOptions(confs, null, cache, date, validate,
             useCacheOnly, transitive, false, true, true, artifactFilter), changing);
     }
 
     public ResolveReport resolve(ModuleRevisionId mrid, String[] confs) throws ParseException,
             IOException {
-        return _ivy.resolve(mrid, newResolveOptions(confs, null, _ivy.getSettings()
-                .getDefaultCache(), null, true, false, true, false, true, true,
+        return ivy.resolve(mrid, newResolveOptions(confs, null,
+            ivy.getSettings().getDefaultCache(), null, true, false, true, false, true, true,
             FilterHelper.NO_FILTER), false);
     }
 
     public ResolveReport resolve(URL ivySource, String revision, String[] confs, File cache,
             Date date, boolean validate, boolean useCacheOnly, boolean transitive,
             boolean useOrigin, Filter artifactFilter) throws ParseException, IOException {
-        return _ivy.resolve(ivySource, newResolveOptions(confs, revision, cache, date, validate,
+        return ivy.resolve(ivySource, newResolveOptions(confs, revision, cache, date, validate,
             useCacheOnly, transitive, useOrigin, true, true, artifactFilter));
     }
 
     public ResolveReport resolve(URL ivySource, String revision, String[] confs, File cache,
             Date date, boolean validate, boolean useCacheOnly, boolean transitive,
             Filter artifactFilter) throws ParseException, IOException {
-        return _ivy.resolve(ivySource, newResolveOptions(confs, revision, cache, date, validate,
+        return ivy.resolve(ivySource, newResolveOptions(confs, revision, cache, date, validate,
             useCacheOnly, transitive, false, true, true, artifactFilter));
     }
 
     public ResolveReport resolve(URL ivySource, String revision, String[] confs, File cache,
             Date date, boolean validate, boolean useCacheOnly, Filter artifactFilter)
             throws ParseException, IOException {
-        return _ivy.resolve(ivySource, newResolveOptions(confs, revision, cache, date, validate,
+        return ivy.resolve(ivySource, newResolveOptions(confs, revision, cache, date, validate,
             useCacheOnly, true, false, true, true, artifactFilter));
     }
 
     public ResolveReport resolve(URL ivySource, String revision, String[] confs, File cache,
             Date date, boolean validate, boolean useCacheOnly) throws ParseException, IOException {
-        return _ivy.resolve(ivySource, newResolveOptions(confs, revision, cache, date, validate,
+        return ivy.resolve(ivySource, newResolveOptions(confs, revision, cache, date, validate,
             useCacheOnly, true, false, true, true, FilterHelper.NO_FILTER));
     }
 
     public ResolveReport resolve(URL ivySource, String revision, String[] confs, File cache,
             Date date, boolean validate) throws ParseException, IOException {
-        return _ivy.resolve(ivySource, newResolveOptions(confs, revision, cache, date, validate,
+        return ivy.resolve(ivySource, newResolveOptions(confs, revision, cache, date, validate,
             false, true, false, true, true, FilterHelper.NO_FILTER));
     }
 
     public ResolveReport resolve(URL ivySource) throws ParseException, IOException {
-        return _ivy.resolve(ivySource);
+        return ivy.resolve(ivySource);
     }
 
     public int retrieve(ModuleId moduleId, String[] confs, File cache, String destFilePattern,
             String destIvyPattern, Filter artifactFilter, boolean sync, boolean useOrigin,
             boolean makeSymlinks) {
         try {
-            return _ivy.retrieve(new ModuleRevisionId(moduleId, Ivy.getWorkingRevision()),
+            return ivy.retrieve(new ModuleRevisionId(moduleId, Ivy.getWorkingRevision()),
                 destFilePattern, new RetrieveOptions().setConfs(confs).setCache(
-                    CacheManager.getInstance(_ivy.getSettings(), cache)).setDestIvyPattern(
+                    CacheManager.getInstance(ivy.getSettings(), cache)).setDestIvyPattern(
                     destIvyPattern).setArtifactFilter(artifactFilter).setSync(sync).setUseOrigin(
                     useOrigin).setMakeSymlinks(makeSymlinks));
         } catch (IOException e) {
@@ -393,9 +410,9 @@
     public int retrieve(ModuleId moduleId, String[] confs, File cache, String destFilePattern,
             String destIvyPattern, Filter artifactFilter, boolean sync, boolean useOrigin) {
         try {
-            return _ivy.retrieve(new ModuleRevisionId(moduleId, Ivy.getWorkingRevision()),
+            return ivy.retrieve(new ModuleRevisionId(moduleId, Ivy.getWorkingRevision()),
                 destFilePattern, new RetrieveOptions().setConfs(confs).setCache(
-                    CacheManager.getInstance(_ivy.getSettings(), cache)).setDestIvyPattern(
+                    CacheManager.getInstance(ivy.getSettings(), cache)).setDestIvyPattern(
                     destIvyPattern).setArtifactFilter(artifactFilter).setSync(sync).setUseOrigin(
                     useOrigin));
         } catch (IOException e) {
@@ -406,9 +423,9 @@
     public int retrieve(ModuleId moduleId, String[] confs, File cache, String destFilePattern,
             String destIvyPattern, Filter artifactFilter) {
         try {
-            return _ivy.retrieve(new ModuleRevisionId(moduleId, Ivy.getWorkingRevision()),
+            return ivy.retrieve(new ModuleRevisionId(moduleId, Ivy.getWorkingRevision()),
                 destFilePattern, new RetrieveOptions().setConfs(confs).setCache(
-                    CacheManager.getInstance(_ivy.getSettings(), cache)).setDestIvyPattern(
+                    CacheManager.getInstance(ivy.getSettings(), cache)).setDestIvyPattern(
                     destIvyPattern).setArtifactFilter(artifactFilter));
         } catch (IOException e) {
             throw new RuntimeException(e);
@@ -418,9 +435,9 @@
     public int retrieve(ModuleId moduleId, String[] confs, File cache, String destFilePattern,
             String destIvyPattern) {
         try {
-            return _ivy.retrieve(new ModuleRevisionId(moduleId, Ivy.getWorkingRevision()),
+            return ivy.retrieve(new ModuleRevisionId(moduleId, Ivy.getWorkingRevision()),
                 destFilePattern, new RetrieveOptions().setConfs(confs).setCache(
-                    CacheManager.getInstance(_ivy.getSettings(), cache)).setDestIvyPattern(
+                    CacheManager.getInstance(ivy.getSettings(), cache)).setDestIvyPattern(
                     destIvyPattern));
         } catch (IOException e) {
             throw new RuntimeException(e);
@@ -429,28 +446,28 @@
 
     public int retrieve(ModuleId moduleId, String[] confs, File cache, String destFilePattern) {
         try {
-            return _ivy.retrieve(new ModuleRevisionId(moduleId, Ivy.getWorkingRevision()),
+            return ivy.retrieve(new ModuleRevisionId(moduleId, Ivy.getWorkingRevision()),
                 destFilePattern, new RetrieveOptions().setConfs(confs).setCache(
-                    CacheManager.getInstance(_ivy.getSettings(), cache)));
+                    CacheManager.getInstance(ivy.getSettings(), cache)));
         } catch (IOException e) {
             throw new RuntimeException(e);
         }
     }
 
     public void setVariable(String varName, String value) {
-        _ivy.setVariable(varName, value);
+        ivy.setVariable(varName, value);
     }
 
     public List sortModuleDescriptors(Collection moduleDescriptors) {
-        return _ivy.sortModuleDescriptors(moduleDescriptors);
+        return ivy.sortModuleDescriptors(moduleDescriptors);
     }
 
     public List sortNodes(Collection nodes) {
-        return _ivy.sortNodes(nodes);
+        return ivy.sortNodes(nodes);
     }
 
     public String substitute(String str) {
-        return _ivy.substitute(str);
+        return ivy.substitute(str);
     }
 
     private String[] splitConfs(String conf) {
@@ -464,4 +481,5 @@
         return confs;
     }
 
+    //CheckStyle:ParameterNumberCheck ON
 }

Modified: incubator/ivy/core/trunk/src/java/org/apache/ivy/Main.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/Main.java?view=diff&rev=544469&r1=544468&r2=544469
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/Main.java (original)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/Main.java Tue Jun  5 05:34:39 2007
@@ -19,6 +19,7 @@
 
 import java.io.File;
 import java.io.FileOutputStream;
+import java.io.IOException;
 import java.io.PrintWriter;
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
@@ -62,17 +63,13 @@
 import org.apache.ivy.util.url.URLHandlerRegistry;
 
 /**
- * class used to launch ivy as a standalone tool arguments are : -settings <settingsfile> :
- * indicates the path to the ivy settings file ivysettings.xml is assumed if not given -cache
- * <cachedir> : indicates the path to the cache directory cache is assumed if not given -ivy
- * <ivyfile> : indicates the path to the ivy file to use ivy.xml is assumed if not given -retrieve
- * <retrievepattern> : when used, retrieve is also done using the given retrievepattern -revision
- * <revision> : the revision with which the module should be published, required to publish -status
- * <status> : the status with which the module should be published, release is assumed if not given
- * -publish <publishpattern> : the pattern used to publish the resolved ivy file, ivy-[revision].xml
- * is assumed if not given
+ * Class used to launch ivy as a standalone tool.
+ * <p>
+ * Valid arguments can be obtained with the -? argument. 
  */
-public class Main {
+public final class Main {
+    private static final int DEPENDENCY_ARG_COUNT = 3;
+
     private static Options getOptions() {
         Option settings = OptionBuilder.withArgName("settingsfile").hasArg().withDescription(
             "use given file for settings").create("settings");
@@ -86,7 +83,8 @@
                 .withArgName("organisation module revision")
                 .hasArgs()
                 .withDescription(
-                    "use this instead of ivy file to do the rest of the work with this as a dependency.")
+                    "use this instead of ivy file to do the rest "
+                    + "of the work with this as a dependency.")
                 .create("dependency");
         Option confs = OptionBuilder.withArgName("configurations").hasArgs().withDescription(
             "resolve given configurations").create("confs");
@@ -96,7 +94,9 @@
                 .withArgName("cachepathfile")
                 .hasArg()
                 .withDescription(
-                    "outputs a classpath consisting of all dependencies in cache (including transitive ones) of the given ivy file to the given cachepathfile")
+                    "outputs a classpath consisting of all dependencies in cache "
+                    + "(including transitive ones) "
+                    + "of the given ivy file to the given cachepathfile")
                 .create("cachepath");
         Option revision = OptionBuilder.withArgName("revision").hasArg().withDescription(
             "use given revision to publish the module").create("revision");
@@ -169,48 +169,12 @@
                 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));
-            }
+            initMessage(line);
 
             boolean validate = line.hasOption("novalidate") ? false : true;
 
             Ivy ivy = Ivy.newInstance();
-            IvySettings settings = ivy.getSettings();
-            settings.addAllVariables(System.getProperties());
-            if (line.hasOption("m2compatible")) {
-                settings.setVariable("ivy.default.configuration.m2compatible", "true");
-            }
-
-            configureURLHandler(line.getOptionValue("realm", null), line.getOptionValue("host",
-                null), line.getOptionValue("username", null), line.getOptionValue("passwd", null));
-
-            String settingsPath = line.getOptionValue("settings", "");
-            if ("".equals(settingsPath)) {
-                settingsPath = line.getOptionValue("conf", "");
-                if (!"".equals(settingsPath)) {
-                    Message.deprecated("-conf is deprecated, use -settings instead");
-                }
-            }
-            if ("".equals(settingsPath)) {
-                ivy.configureDefault();
-            } else {
-                File conffile = new File(settingsPath);
-                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);
-            }
+            IvySettings settings = initSettings(line, options, ivy);
 
             File cache = new File(settings.substitute(line.getOptionValue("cache", settings
                     .getDefaultCache().getAbsolutePath())));
@@ -231,9 +195,10 @@
             File ivyfile;
             if (line.hasOption("dependency")) {
                 String[] dep = line.getOptionValues("dependency");
-                if (dep.length != 3) {
+                if (dep.length != DEPENDENCY_ARG_COUNT) {
                     error(options,
-                        "dependency should be expressed with exactly 3 arguments: organisation module revision");
+                        "dependency should be expressed with exactly 3 arguments: "
+                        + "organisation module revision");
                 }
                 ivyfile = File.createTempFile("ivy", ".xml");
                 ivyfile.deleteOnExit();
@@ -323,6 +288,52 @@
         }
     }
 
+    private static IvySettings initSettings(CommandLine line, Options options, Ivy ivy) 
+            throws java.text.ParseException, IOException {
+        IvySettings settings = ivy.getSettings();
+        settings.addAllVariables(System.getProperties());
+        if (line.hasOption("m2compatible")) {
+            settings.setVariable("ivy.default.configuration.m2compatible", "true");
+        }
+
+        configureURLHandler(line.getOptionValue("realm", null), line.getOptionValue("host",
+            null), line.getOptionValue("username", null), line.getOptionValue("passwd", null));
+
+        String settingsPath = line.getOptionValue("settings", "");
+        if ("".equals(settingsPath)) {
+            settingsPath = line.getOptionValue("conf", "");
+            if (!"".equals(settingsPath)) {
+                Message.deprecated("-conf is deprecated, use -settings instead");
+            }
+        }
+        if ("".equals(settingsPath)) {
+            ivy.configureDefault();
+        } else {
+            File conffile = new File(settingsPath);
+            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);
+        }
+        return settings;
+    }
+
+    private static void initMessage(CommandLine line) {
+        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));
+        }
+    }
+
     private static void outputCachePath(Ivy ivy, File cache, ModuleDescriptor md, String[] confs,
             String outFile) {
         try {
@@ -353,7 +364,8 @@
             System.out.println("cachepath output to " + outFile);
 
         } catch (Exception ex) {
-            throw new RuntimeException("impossible to build ivy cache path: " + ex.getMessage(), ex);
+            throw new RuntimeException(
+                "impossible to build ivy cache path: " + ex.getMessage(), ex);
         }
     }
 
@@ -379,7 +391,8 @@
                 urls.add(cacheMgr.getArchiveFileInCache(artifact).toURL());
             }
         } catch (Exception ex) {
-            throw new RuntimeException("impossible to build ivy cache path: " + ex.getMessage(), ex);
+            throw new RuntimeException(
+                "impossible to build ivy cache path: " + ex.getMessage(), ex);
         }
 
         URLClassLoader classLoader = new URLClassLoader((URL[]) urls.toArray(new URL[urls.size()]),
@@ -401,7 +414,8 @@
         } catch (IllegalAccessException e) {
             throw new RuntimeException("No permissions to invoke main method: " + mainclass, e);
         } catch (InvocationTargetException e) {
-            throw new RuntimeException("Unexpected exception invoking main method: " + mainclass, e);
+            throw new RuntimeException(
+                "Unexpected exception invoking main method: " + mainclass, e);
         }
     }
 
@@ -428,4 +442,6 @@
         formatter.printHelp("ivy", options);
     }
 
+    private Main() {
+    }
 }