This topic contains a reference about the dependency management support
IBM® WebSphere® sMash uses a dependency management utility called Ivy to ensure that your module is using the right versions of the libraries you declare as dependencies. In Ivy, these libraries are called modules. A module represents an artifact, which is code packaged as either a JAR file or a ZIP file. You declare the modules your module needs to run in an XML file called an Ivy file. WebSphere sMash then uses Ivy to resolve your module's dependencies. Resolve means that Ivy searches a chain of repositories to find a module that matches the dependency you declared. Ivy can search the local repository that WebSphere sMash creates on your system, or it can search remote repositories such as the WebSphere sMash package repository. When a match is found, Ivy downloads the module's artifact into your local repository (if it isn't already there), and updates your module's classpath to include the dependency.
An Ivy repository is simply a collection of artifacts stored in a structured format that Ivy can understand. Repositories are typically accessed through file system or HTTP interfaces. Repositories can store different versions of modules, so you can declare which specific version you need.
When you first install WebSphere sMash, a local repository is created on your system to store artifacts. All downloaded artifacts are placed into your local repository. WebSphere sMash looks in your local repository for matching dependencies first. If a dependency can not be found locally, you have the option of looking in remote repositories.
The local repository is created in your <zerohome> directory by default. The location of the local repository can be changed by configuring the file <zerohome>/config/local.properties when using the Command Line Interface
WebSphere sMash can look in remote repositories for dependencies if they can't be found on the local system. Remote repositories are file servers with an HTTP interface. The remote repositories can either use an Ivy format or a Maven format. WebSphere sMash repositories use an Ivy format. Maven is a build utility that has similar dependency management capabilities to Ivy.
You can declare dependencies for your module by configuring your ivy.xml file, which is located in your module's config directory. Note: You should stop your application before changing its configuration. Failure to do so could lead to unexpected behavior in the running application.
Each dependency declaration is made up of three parts: an organization (org), a module name (name), and a revision matching pattern (rev). For WebSphere sMash dependencies, org is always zero. Module name is usually the same as the module name. Revision is a pattern that specifies the specific version of the artifact that your module needs, or it is a pattern such as [1.0.0.0, 2.0.0.0[. This particular pattern means match any version greater than or equal to 1.0.0.0 but less than 2.0.0.0. For more information on Ivy patterns, see the Ivy dependency documentation.
One of the features of dependency management is the ability for a package to declare their transitive dependencies. When the dependency is included, the transitive dependencies are automatically resolved. There are times, however, where there is the need to have finer control over the artifacts that are included. One such case is when a conflict between two dependencies occurs. Another could just be the desire to exclude a certain jar. Ivy offers two solutions, one that could be viewed as fine-grained and another more coarse-grained. The ivy report is a great source to determine why artifacts are included, but the report is only generated in the case where there are no conflicts.
The fine-grained solution allows excluding specific transitive dependencies. This solution allows picking and choosing which artifacts to exclude. The excludes solution is the preferred solution for a WebSphere sMash module.
<dependency name="commons-beanutils" org="commons-beanutils" rev="1.7.0"> <exclude module="commons-logging"/> </dependency>
The coarse-grained solution is to exclude all transitives. This solution does require explicit dependency declarations to include the required transitives dependencies, but this solution allows complete control of which artifacts are included.
<dependency name="commons-lang" org="commons-lang" rev="2.3" transitive="false" />
WebSphere sMash uses standard ZIP files for packaging. If you are going to package your module to share with others, you should update your ivy.xml file to include information about your package, such as author (ivyauthor), organization (organisation and org), version (revision), license, and description. From a WebSphere sMash perspective, the elements you should be sure to have correct are the organization, module, and revision. These fields are used for naming your package and dependency resolution using Ivy.
To create a WebSphere sMash package with the command line interface, change to your module's directory and type zero package. A file with with the naming pattern module-revision.zip will be created in your module's export directory.
If you want to make your package available for other module's on your system to use, you can publish it to your local repository using zero publish. Once a package has been published to the local repository, other modules can declare dependencies on it. To verify that your package has been published, you can use the zero search command to view the local repository.
The dependency management resolve may need to access remote repositories to download dependencies. Proxies are supported by defining the necessary properties.
The proxy can be configured through the following system properties:
The WebSphere sMash command line scripts contain a commented example to help setting the proxy properties. For example, in the zero shell script uncomment the following line and update the proxy values.
ZERO_OPTS="-Dhttp.proxyHost=192.168.1.100 -Dhttp.proxyPort=8089"
To include files from Ivy dependencies in PHP scripts, see the article on Libraries and Dependency Resolution in the PHP Support section.