Added: ant/ivy/site/target/history/2.2.0/textual.html URL: http://svn.apache.org/viewvc/ant/ivy/site/target/history/2.2.0/textual.html?rev=1005260&view=auto ============================================================================== --- ant/ivy/site/target/history/2.2.0/textual.html (added) +++ ant/ivy/site/target/history/2.2.0/textual.html Wed Oct 6 21:25:29 2010 @@ -0,0 +1,196 @@ + + + + + + + + +Text Conventions | Apache Ivy + + + + + + + + + + +
+ + + + + + + + + + + + + +
+ +
+ +
+ + + + +
+ + +
+ + +
+ + + + + + + +
+
+ +

Text Conventions

+
Very often some concepts discussed in Ivy here, and especially those involving modules and dependencies, require to be discussed by text (e-mail, textual doc, console, ...), and so benefit from convention in this area.

The conventions have been adopted with Ivy 2.0 are the following: + + + + + + + + + + + + + + + + + + + + + + + + + + +
+what
+pattern
+example
+a module without revision
+[organisation]#[module]
+org.apache.ant#ant
+a module with revision
+[organisation]#[module];[revision]
+org.apache.ant#ant;1.7.0
+a module with (some) configurations
+[organisation]#[module][ [confs] ]
+org.apache.ant#ant[master,compile,build]
+a module with revision and (some) configurations
+[organisation]#[module];[revision][ [confs] ]
+org.apache.ant#ant;1.7.0[master,compile,build]
+a module's artifact
+[organisation]#[module]![artifact].[ext]([type])
+org.apache.ant#ant!ant.jar(source)
+a module's artifact with revision
+[organisation]#[module];[revision]![artifact].[ext]([type])
+org.apache.ant#ant;1.7.0!ant.jar(source)
+
+Another usual text representation used is to represent dependencies using a dash followed by greater than sign: ->

To group a set of set of modules, we recommend using curly braces { }

With these conventions, it's easy to give a concise and detailed overview of a set of modules and their dependencies.

For instance: +
+#A;2-> { #B;[1.0,1.5] #C;[2.0,2.5] }
#B;1.4->#D;1.5
#B;1.5->#D;2.0
#C;2.5->#D;[1.0,1.6] +
+In full words here is how it could be written: +
+module A revision 2 depends on module B with the version constraint [1.0,1.5], and on module C with the version constraint [2.0,2.5].
module B revision 1.4 depends on module D revision 1.5.
module B revision 1.5 depends on module D revision 2.0.
module C revision 2.5 depends on module D with the version constraint [1.0,1.6]. +
+ +As you can see, using text conventions is much more concise.

Another benefit is that these conventions are usually used in Ivy console output, and can also be used in some cases to be parsed into Ivy objects (we use it for test cases for instance). To make sure text parsing works fine, we recommend using only a limited range of characters for each attributes of your module identifiers.

Here is the recommended characters set for each attribute: +
    +
  • organisation
  • a-z A-Z 0-9 - / . _ + = +
  • module
  • a-z A-Z 0-9 - / . _ + = +
  • branch
  • a-z A-Z 0-9 - / . _ + = +
  • revision
  • a-z A-Z 0-9 - / . _ + = , [ ] { } ( ) : @ +
  • artifact
  • a-z A-Z 0-9 - / . _ + = +
  • extension
  • a-z A-Z 0-9 - / . _ + = +
  • type
  • a-z A-Z 0-9 - / . _ + = +
+ +
+
+ + + + + + + + + + + + +
+ + Added: ant/ivy/site/target/history/2.2.0/tutorial.html URL: http://svn.apache.org/viewvc/ant/ivy/site/target/history/2.2.0/tutorial.html?rev=1005260&view=auto ============================================================================== --- ant/ivy/site/target/history/2.2.0/tutorial.html (added) +++ ant/ivy/site/target/history/2.2.0/tutorial.html Wed Oct 6 21:25:29 2010 @@ -0,0 +1,150 @@ + + + + + + + + +Tutorials | Apache Ivy + + + + + + + + + + +
+ + + + + + + + + + + + + +
+ +
+ +
+ + + + +
+ + +
+ + +
+ + + + + + + +
+
+ +

Tutorials

+
The best way to learn is to practice! That's what the Ivy tutorials will help you to do, to discover some of the great Ivy features.

For the first tutorial you won't even have to install Ivy (assuming you have Ant and a JDK properly installed), and it shouldn't take more than 30 seconds.

First Tutorial
    +
  1. Make sure you have ant 1.6.0 or greater and a jdk properly installed
  2. +
  3. Copy this build file in an empty directory on your local filesystem (and make sure you name it build.xml)
  4. +
  5. Open a console in this directory and run "ant". That's it!
  6. +
+If you have any trouble, check the FAQ. It is most likely related to your internet connection (proxy anyone?).

OK, you've just seen how easy it is to take your first step with Ivy. Go ahead with the other tutorials, but before you do, make sure you have properly installed Ivy and downloaded the tutorials sources (included in all Ivy distributions, in the src/example directory).

The following tutorials are available: + + +
+
+ + + + + + + + + + + + +
+ + Added: ant/ivy/site/target/history/2.2.0/tutorial/build-repository.html URL: http://svn.apache.org/viewvc/ant/ivy/site/target/history/2.2.0/tutorial/build-repository.html?rev=1005260&view=auto ============================================================================== --- ant/ivy/site/target/history/2.2.0/tutorial/build-repository.html (added) +++ ant/ivy/site/target/history/2.2.0/tutorial/build-repository.html Wed Oct 6 21:25:29 2010 @@ -0,0 +1,133 @@ + + + + + + + + +Building a repository | Apache Ivy + + + + + + + + + + +
+ + + + + + + + + + + + + +
+ +
+ +
+ + + + +
+ + +
+ + +
+ + + + + + + +
+
+ +

Building a repository

+
The install Ant task lets you copy a module or a set of modules from one repository to another. This is very useful to build and maintain an enterprise or team repository. If you don't want to give access to the public maven 2 repository to the developers on your team (to keep control over which modules are in use in your company or your team for instance), it can sometimes become tiresome to answer the developers request to add new modules or new versions by hand.

Fortunately the install task is here to help: you can use specific settings for your repository maintenance build which will be used to maintain your target enterprise repository. These settings will point to another repository (for instance the maven 2 public repository) so that you will just have to ask Ivy to install the modules you want with a simple command line.

To demonstrate this, we will first use a basic ivy settings file to show how it works, and then we will use the advanced namespaces features to demonstrate how to deal with naming mismatches between the source and target repository.

The project used

+The project that we will use is pretty simple. It is composed of an Ant build file, and two ivy settings files.

Here are the public targets that we will use: +
+Z:\ivy-repository>ant -p
Buildfile: build.xml

Main targets:

clean-cache --> clean the cache
clean-repo --> clean the destination repository
maven2 --> install module from maven 2 repository
maven2-deps --> install module from maven 2 repository with dependencies
maven2-namespace --> install module from maven 2 using namespaces
maven2-namespace-deps --> install module with dependencies from maven2 repo using namespaces
Default target: basic +
+

+This project is accessible in the src/example/build-a-ivy-repository

Next steps:
Basic repository copy
Using namespaces


+
+
+ + + + + + + + + + + + +
+ + Added: ant/ivy/site/target/history/2.2.0/tutorial/build-repository/advanced.html URL: http://svn.apache.org/viewvc/ant/ivy/site/target/history/2.2.0/tutorial/build-repository/advanced.html?rev=1005260&view=auto ============================================================================== --- ant/ivy/site/target/history/2.2.0/tutorial/build-repository/advanced.html (added) +++ ant/ivy/site/target/history/2.2.0/tutorial/build-repository/advanced.html Wed Oct 6 21:25:29 2010 @@ -0,0 +1,209 @@ + + + + + + + + +Using namespaces | Apache Ivy + + + + + + + + + + +
+ + + + + + + + + + + + + +
+ +
+ +
+ + + + +
+ + +
+ + +
+ + + + + + + +
+
+ +

Using namespaces

+
Now that you have seen how simple it is to create your own repository from an existing one, you may wonder how you can handle more complex cases, like when the source and destination repositories don't follow the same naming conventions.


On the road to a professional repository

+In this section, you will learn how to build a professional repository. What is a professional repository? Our vision is to say that a good quality repository must follow clear rules about projects naming and must offer correct, useable, configurations and verified project descriptors. In order to achieve those goals, we think that you have to build your own repository.
We have seen in the previous example, that we could use some public repositories to begin to build our own repository. Nevertheless, the result is not always the expected one, especially concerning the naming rules used.

This problem is pretty normal when you have an existing repository, and want to benefit from large public repositories which do not follow the same naming conventions. It also shows up because many public repositories do not use a consistent naming scheme. For example, why don't all the apache c ommons modules use the org.apache.commons organization? Well.. for historical reasons. But if you setup your own repository, you may not want to suffer from the mistakes of history.

Fortunately, Ivy has a very powerful answer to this problem: namespaces.

Using namespaces

+If you look at the repository built with the previous tutorial, you will see exactly what we were talking about: all apache commons modules use their own name as their organization.

So let's see what Ivy can do using namespaces (we will dig into details later): +
+[ivy@apache:/ivy/build-a-ivy-repository]$ ant maven2-namespace
+Buildfile: /ivy/build-a-ivy-repository/build.xml
+
+load-ivy:
+
+init-ivy:
+
+maven2-namespace:
+[ivy:install] :: Ivy 2.2.0 - 20100923230623 :: http://ant.apache.org/ivy/ ::
+[ivy:install] :: loading settings :: file = /ivy/build-a-ivy-repository/settings/ivysettings-advanced.xml
+[ivy:install] DEPRECATED: 'defaultCache' is deprecated, use 'caches[@defaultCacheDir]' instead (file://ivy/build-a-ivy-repository/settings/ivysettings-advanced.xml)
+[ivy:install] :: installing apache#commons-lang;1.0 ::
+[ivy:install] :: resolving dependencies ::
+[ivy:install] 	found apache#commons-lang;1.0 in libraries
+[ivy:install] :: downloading artifacts to cache ::
+[ivy:install] downloading http://repo1.maven.org/maven2/commons-lang/commons-lang/1.0/commons-lang-1.0.jar ...
+[ivy:install] ....................................................................................................................... (62kB)
+[ivy:install] .. (0kB)
+[ivy:install] 	[SUCCESSFUL ] apache#commons-lang;1.0!commons-lang.jar (3151ms)
+[ivy:install] downloading http://repo1.maven.org/maven2/commons-lang/commons-lang/1.0/commons-lang-1.0-javadoc.jar ...
+[ivy:install] ..................................................................................................................................................................................................................................................................................................................................................................... (170kB)
+[ivy:install] .. (0kB)
+[ivy:install] 	[SUCCESSFUL ] apache#commons-lang;1.0!commons-lang.jar(javadoc) (3104ms)
+[ivy:install] :: installing in my-repository ::
+[ivy:install] 	published commons-lang to /ivy/build-a-ivy-repository/myrepository/advanced/apache/commons-lang/jars/commons-lang-1.0.jar
+[ivy:install] 	published commons-lang to /ivy/build-a-ivy-repository/myrepository/advanced/apache/commons-lang/javadocs/commons-lang-1.0.jar
+[ivy:install] 	published ivy to /ivy/build-a-ivy-repository/myrepository/advanced/apache/commons-lang/ivys/ivy-1.0.xml
+[ivy:install] :: install resolution report ::
+[ivy:install] :: resolution report :: resolve 0ms :: artifacts dl 6255ms
+	---------------------------------------------------------------------
+	|                  |            modules            ||   artifacts   |
+	|       conf       | number| search|dwnlded|evicted|| number|dwnlded|
+	---------------------------------------------------------------------
+	|      default     |   1   |   1   |   1   |   0   ||   2   |   2   |
+	---------------------------------------------------------------------
+
+BUILD SUCCESSFUL
+Total time: 10 seconds
+
+
+ +Now if we look at our repository, it seems to look fine. +
+$ find /ivy/build-a-ivy-repository/myrepository/advanced -type f -print
+/ivy/build-a-ivy-repository/myrepository/advanced/apache/commons-lang/ivys/ivy-1.0.xml
+/ivy/build-a-ivy-repository/myrepository/advanced/apache/commons-lang/ivys/ivy-1.0.xml.md5
+/ivy/build-a-ivy-repository/myrepository/advanced/apache/commons-lang/ivys/ivy-1.0.xml.sha1
+/ivy/build-a-ivy-repository/myrepository/advanced/apache/commons-lang/jars/commons-lang-1.0.jar
+/ivy/build-a-ivy-repository/myrepository/advanced/apache/commons-lang/jars/commons-lang-1.0.jar.md5
+/ivy/build-a-ivy-repository/myrepository/advanced/apache/commons-lang/jars/commons-lang-1.0.jar.sha1
+/ivy/build-a-ivy-repository/myrepository/advanced/apache/commons-lang/javadocs/commons-lang-1.0.jar
+/ivy/build-a-ivy-repository/myrepository/advanced/apache/commons-lang/javadocs/commons-lang-1.0.jar.md5
+/ivy/build-a-ivy-repository/myrepository/advanced/apache/commons-lang/javadocs/commons-lang-1.0.jar.sha1
+
+
+We can even have a look at the commons-lang ivy file in our repository: +
+<?xml version="1.0" encoding="UTF-8"?>
<ivy-module version="1.0">
<info organisation="apache"
module="commons-lang"
revision="1.0"
status="integration"
publication="20051124062021"
namespace="ibiblio-maven2"
/>

... +
+Alright, we see that the organisation is now 'apache'. But where did Ivy pick this up?

How does this work ?

+Actually, Ivy uses the same repository as before for the source repository, with only one difference: the namespace parameter: +
+<ibiblio name="libraries" 
root="${ibiblio-maven2-root}"
m2compatible="true"
namespace="maven2"
/> +
+ +A namespace is defined by a set of rules. These rules are based on regular expressions and tell Ivy how to convert data from the repository namespace to what is called the system namespace, i.e. the namespace in which Ivy runs most of the time (Note: the Ivy cache always uses the system namespace).

For the namespace we call maven2, we have declared several rules. Below is one of the rules:

rule handling the imported apache maven1 projects

+
<rule>	<!-- imported apache maven1 projects -->
<fromsystem>
<src org="apache" module=".+"/>

<dest org="$m0" module="$m0"/>
</fromsystem>
<tosystem>
<src org="commons-.+" module="commons-.+" />
<src org="ant.*" module="ant.*" />
...
<src org="xmlrpc" module="xmlrpc" />

<dest org="apache" module="$m0"/>
</tosystem>
</rule>
+
Note about regular expressions usage : +In order to distinguish matching regular expressions found in organization, module, and revision, the notation Ivy uses prefixes the matching regular expression with the letters 'o', 'm' and 'r'.
$o0 : the whole matching value in the organization attribute
$o1 : the first matching expression group that was marked in the organization attribute
...
The same applies for modules : $m0, $m1, ...
and for revisions : $r0, $r1, ... +
+To understand namespaces, +
    +
  • fromsystem : we define here that the projects defined in the system namespace under the organization called "apache" are transformed into the destination namespace into projects whose organization is named with the module name, whatever the revision is. For example, the project apache#commons-lang;1.0 in the system namespace will be translated into commons-lang#commons-lang;1.0 in the maven2 resolver namespace.
  • +
  • tosystem : we define here the reverse mapping, i.e. how to translate apache projects from maven 2 repo into apache projects in the system namespace. The rule used here tells Ivy that all projects matching commons-.+ (see it as java regular expression) for their organization name and module name are transformed into projects whose organisation is apache with the module name as it was found. The same kind of rule is defined for others apache projects like ant, etc.
  • +
+ +OK, you should now get the idea behind namespaces, so go ahead and look at the ivysettings-advanced.xml file in this example. You can test the installation of a module and its dependencies using namespaces.

Run +
ant maven2-namespace-deps
+and you will see the resulting repository is cleaner than the first one we built.

From our experience, investing in creating a namespace is worth the time it costs if you often need to add new modules or revisions of third party libraries in your own repository, where naming rules already exist or are rather strict. +
+
+ + + + + + + + + + + + +
+ +