------ Dependencies ------ Brett Porter Hervé Boutemy Paul Gier ------ 2009-05-07 ------ ~~ 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. ~~ NOTE: For help with the syntax of this file, see: ~~ http://maven.apache.org/doxia/references/apt-format.html Basic Example The following example declares three dependencies and adds them to the <<>> pathId. ----- ----- The pathId can be used in the Ant build file for example in the <<>> task. ----- ... ----- Using FileSets and the Version Mapper Another option you can use is <<>>, which will give you a fileset reference that can be used to copy files into a particular location. For example, to populate <<>> with your dependencies you could use the following: ----- ... ----- Note the <<>> attribute in this call. This ensures that your web application only includes your compile and runtime dependencies, excluding those that are only for testing or are expected to already be provided by the servlet container. You can also specify a <<>> parameter on each dependency. This changes the behavior of transitive dependencies and is useful for building different types of classpaths. To see how it affects the behaviour of the dependencies, see the {{{http://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html} Dependency Mechanism}} documentation on the Maven 2.0 site. Other options are: * <<>>, which will give you a fileset reference containing sources artifacts, <(since 2.0.6)> * <<>>, which will give you a fileset reference containing javadoc artifacts, <(since 2.0.9)> * {<<>>}, which can be used to drop version numbers in filenames <(since 2.0.7)> For example, to populate <<>> with your dependencies without the version in the filenames, <<>> with the corresponding sources and <<>> with the corresponding javadocs: ----- ... ----- <> In the above example you only need to specify <<>> if are using Maven Ant Tasks by {{{../installation.html#typedef} declaring a <<>>}}. It can be omitted if Maven Ant Tasks was {{{../installation.html#lib} installed in Ant's <<>> directory}}. Using Properties to Access Dependencies <(since 2.0.8)> For each dependency resolved using either inline declaration or a pom reference, the property <<>> is defined pointing to the corresponding file. For example, a resolved dependency on junit can be accessed in the following way: ----- ----- Filtering Dependencies by Scope There are two options available for filtering POM dependencies by scope: the <<>> attribute, and the <<>> attribute. One or the other of these attributes should be used but not both. The <<>> follows the Maven conventions for scoping behaviour. This means the attribute can be set to one of three possible scopes: compile, runtime, or test. These scopes will behave as follows. * compile - Includes scopes compile, system, and provided * runtime - Includes scopes compile and runtime * test - Includes scopes system, provided, compile, runtime, and test For example, using the scope <<>>, any dependencies defined with compile, runtime, or nothing (defaults to compile) in the scope field will be included in the resulting fileset. ----- ----- <(Since 2.0.10)> The <<>> attribute accepts a comma separated list of scopes to include in the filtering. Only dependencies with these specific scopes will be included in the resulting fileset. If no value is specified, all scopes are included. The following example includes only dependencies with a scope of either "provided" or "test". ----- ----- Filtering Dependencies by Type Dependencies can be filterd by type by using the <<>> attribute. This can be set to a comma separate list of the types to select. The following example will only include artifacts of the jar type. ----- ----- By default all artifact types will be included when building the list of dependencies.