////
   Licensed to the Apache Software Foundation (ASF) under one
   or more contributor license agreements.  See the NOTICE file
   distributed with this work for additional information
   regarding copyright ownership.  The ASF licenses this file
   to you under the Apache License, Version 2.0 (the
   "License"); you may not use this file except in compliance
   with the License.  You may obtain a copy of the License at

     http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing,
   software distributed under the License is distributed on an
   "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
   KIND, either express or implied.  See the License for the
   specific language governing permissions and limitations
   under the License.
////

= Using standalone

Ivy can be used as a standalone program very easily. All you need is a Java 7+ runtime environment (JRE)!

Then here is how to call it:

[source,shell]
----
java -jar ivy.jar -?
----

It will display usage text as follows:

[source]
----
usage: ivy
==== settings options
 -settings <settingsfile>     use given file for settings
 -properties <propertiesfile> use given file for properties not specified in set
                              tings
 -cache <cachedir>            use given directory for cache
 -novalidate                  do not validate ivy files against xsd
 -m2compatible                use Maven 2 compatibility

==== resolve options
 -ivy <ivyfile>               use given file as ivy file
 -refresh                     refresh dynamic resolved revisions
 -dependency <organisation> <module> <revision>
                              use this instead of ivy file to do the rest of the
                               work with this as a dependency.
 -confs <configurations>      resolve given configurations
 -types <types>               accepted artifact types
 -mode <resolvemode>          the resolve mode to use
 -notransitive                do not resolve dependencies transitively

==== retrieve options
 -retrieve <retrievepattern>  use given pattern as retrieve pattern
 -ivypattern <pattern>        use given pattern to copy the ivy files
 -sync                        use sync mode for retrieve
 -symlink                     create symbolic links
 -overwriteMode <overwriteMode> use given overwrite mode for retrieve

==== cache path options
 -cachepath <cachepathfile>   outputs a classpath consisting of all dependencies
                               in cache (including transitive ones) of the given
                               ivy file to the given cachepathfile

==== deliver options
 -deliverto <ivypattern>      use given pattern as resolved ivy file pattern

==== publish options
 -publish <resolvername>      use given resolver to publish to
 -publishpattern <artpattern> use given pattern to find artifacts to publish
 -revision <revision>         use given revision to publish the module
 -status <status>             use given status to publish the module
 -overwrite                   overwrite files in the repository if they exist

==== makepom options
 -makepom <pomfilepath>       create a POM file for the module

==== http auth options
 -realm <realm>               use given realm for HTTP AUTH
 -host <host>                 use given host for HTTP AUTH
 -username <username>         use given username for HTTP AUTH
 -passwd <passwd>             use given password for HTTP AUTH

==== launcher options
 -main <main>                 the FQCN of the main class to launch
 -args <args>                 the arguments to give to the launched process
 -cp <cp>                     extra classpath to use when launching process

==== message options
 -debug                       set message level to debug
 -verbose                     set message level to verbose
 -warn                        set message level to warn
 -error                       set message level to error

==== help options
 -?                           display this help
 -deprecated                  show deprecated options
 -version                     displays version information
----

(*__since 1.3__*) System properties are included as Ivy variables, so you can easily define an Ivy variable like this:

[source,shell]
----
java -Dmyivyvar=myvalue org.apache.ivy.Main [parameters]
----

(*__since 2.5__*) Additional properties defined in a separate `.properties` file (rather than Ivy settings) can be loaded using `-properties` option like this:

[source,shell]
----
java -jar ivy.jar -properties version.properties -main org.apache.tools.ant.Main
----

NOTE: Prior to 2.5, Ivy `-main` created a classloader that used Ivy classloader as a parent. This is no longer the case; if your usage depended on Ivy classes being available, Ivy must be declared as a dependency of the component that you want to launch.

(*__since 2.5__*) Ivy can convert `ivy.xml` files to `pom.xml` files using `-makepom` option.

== Examples

[source,shell]
----
java -jar ivy.jar
----

calls Ivy with default configuration using ivy.xml in the current dir

'''

[source,shell]
----
java -jar ivy.jar -settings path/to/myivysettings.xml -ivy path/to/myivy.xml
----

calls Ivy with given Ivy settings file using given Ivy file

'''

(*__since 1.3__*)

[source,shell]
----
java -jar ivy.jar -settings path/to/myivysettings.xml -dependency apache commons-lang 2.0
----

calls Ivy with given Ivy settings file and resolve apache `commons-lang 2.0`.

This is equivalent to:

[source,shell]
----
java -jar ivy.jar -settings path/to/myivysettings.xml -ivy ivy.xml
----

with `ivy.xml` like this:

[source,xml]
----
<ivy-module version="1.0">
  <info organisation="org"
       module="standalone"
       revision="working"/>
  <dependencies>
    <dependency org="apache" name="commons-lang" rev="2.0" conf="default->*"/>
  </dependencies>
</ivy-module>
----

'''

(*__since 1.3__*)

[source,shell]
----
java -jar ivy.jar -settings path/to/myivysettings.xml -ivy path/to/myivy.xml -cachepath mycachefile.txt
----

calls Ivy with given Ivy settings file and resolves the dependencies found in the given Ivy file, and then outputs the classpath of resolved artifacts in cache in a file. This file can then be used to define a classpath corresponding to all the resolved dependencies for any Java program.

'''

(*__since 1.4__*)

[source,shell]
----
java -jar ivy.jar -settings path/to/myivysettings.xml -dependency bar foo 2.0 -main org.bar.foo.FooMain
----

calls Ivy with given Ivy settings file and resolves the dependency `bar` `foo` `2.0`, and then runs `org.foo.FooMain` class with the resolved artifacts as classpath.
