org.jboss.dna.maven
Class MavenDependency

java.lang.Object
  extended by org.jboss.dna.maven.MavenDependency

public class MavenDependency
extends Object

The cornerstone of Maven is its dependency list. Most every project depends upon others to build and run correctly, and if all Maven does for you is manage this list for you, you have gained a lot. Maven downloads and links the dependencies for you on compilation and other goals that require them. As an added bonus, Maven brings in the dependencies of those dependencies (transitive dependencies), allowing your list to focus solely on the dependencies your project requires.


Nested Class Summary
static class MavenDependency.Scope
          The scope of the dependency - compile, runtime, test, system, and provided.
 
Field Summary
static boolean DEFAULT_OPTIONAL
           
static String DEFAULT_TYPE
           
 
Constructor Summary
MavenDependency(MavenId id)
           
MavenDependency(String coordinates)
           
MavenDependency(String groupId, String artifactId, String version)
           
MavenDependency(String groupId, String artifactId, String version, String classifier)
           
 
Method Summary
 boolean equals(Object obj)
          
 Set<MavenId> getExclusions()
          Exclusions explicitly tell Maven that you don't want to include the specified project that is a dependency of this dependency (in other words, its transitive dependency).
 MavenId getId()
          The identifier of the artifact for this dependency.
 MavenDependency.Scope getScope()
          The scope of the dependency - compile, runtime, test, system, and provided.
 String getSystemPath()
          FOR SYSTEM SCOPE ONLY.
 String getType()
          The type of dependency.
 int hashCode()
          
 boolean isOptional()
          Indicates the dependency is optional for use of this library.
 void setOptional(boolean optional)
           
 void setScope(MavenDependency.Scope scope)
           
 void setScope(String text)
           
 void setSystemPath(String systemPath)
           
 void setType(String type)
          Set the type of dependency.
 String toString()
          
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

DEFAULT_TYPE

public static final String DEFAULT_TYPE
See Also:
Constant Field Values

DEFAULT_OPTIONAL

public static final boolean DEFAULT_OPTIONAL
See Also:
Constant Field Values
Constructor Detail

MavenDependency

public MavenDependency(String coordinates)

MavenDependency

public MavenDependency(MavenId id)

MavenDependency

public MavenDependency(String groupId,
                       String artifactId,
                       String version)

MavenDependency

public MavenDependency(String groupId,
                       String artifactId,
                       String version,
                       String classifier)
Method Detail

getId

public MavenId getId()
The identifier of the artifact for this dependency.

Returns:
the identifier

getType

public String getType()
The type of dependency. This defaults to jar. While it usually represents the extension on the filename of the dependency, that is not always the case. A type can be mapped to a different extension and a classifier. The type often correspongs to the packaging used, though this is also not always the case. Some examples are jar, war, ejb-client and test-jar. New types can be defined by plugins that set extensions to true, so this is not a complete list.

Returns:
the dependency type

setType

public void setType(String type)
Set the type of dependency.

Parameters:
type - the new dependency type. If null, then the type will be set to the default dependency type.

getScope

public MavenDependency.Scope getScope()
The scope of the dependency - compile, runtime, test, system, and provided. Used to calculate the various classpaths used for compilation, testing, and so on. It also assists in determining which artifacts to include in a distribution of this project. For more information, see the dependency mechanism.

Returns:
the scope

setScope

public void setScope(MavenDependency.Scope scope)
Parameters:
scope - Sets scope to the specified value.

setScope

public void setScope(String text)

getSystemPath

public String getSystemPath()
FOR SYSTEM SCOPE ONLY. Note that use of this property is discouraged and may be replaced in later versions. This specifies the path on the filesystem for this dependency. Requires an absolute path for the value, not relative. Use a property that gives the machine specific absolute path, e.g. ${java.home}.

Returns:
systemPath

setSystemPath

public void setSystemPath(String systemPath)
Parameters:
systemPath - Sets systemPath to the specified value.

isOptional

public boolean isOptional()
Indicates the dependency is optional for use of this library. While the version of the dependency will be taken into account for dependency calculation if the library is used elsewhere, it will not be passed on transitively.

Returns:
true if this is an optional dependency, or false otherwise

setOptional

public void setOptional(boolean optional)
Parameters:
optional - Sets optional to the specified value.

getExclusions

public Set<MavenId> getExclusions()
Exclusions explicitly tell Maven that you don't want to include the specified project that is a dependency of this dependency (in other words, its transitive dependency). For example, the maven-embedder requires maven-core , and we do not wish to use it or its dependencies, then we would add it as an exclusion .

Returns:
the set of exclusions

hashCode

public int hashCode()

Overrides:
hashCode in class Object

equals

public boolean equals(Object obj)

Overrides:
equals in class Object

toString

public String toString()

Overrides:
toString in class Object


Copyright © 2008-2009 JBoss, a division of Red Hat. All Rights Reserved.