Interface DependencyFactory

All Known Subinterfaces:
BuildFactory, PluginFactory
All Known Implementing Classes:
ModelFactory, ModelTest, ModelTest2

public interface DependencyFactory
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Interface
    Description
    static class 
     
  • Method Summary

    Modifier and Type
    Method
    Description
    default org.apache.maven.model.Dependency
    compile(String definition)
     
    default org.apache.maven.model.Dependency
    dependency(String definition)
     
    default org.apache.maven.model.Dependency
    dependency(String definition, String scope)
     
    default org.apache.maven.model.Dependency
    dependency(NamedValue... keyValuePairs)
    Factory method to create dependency.
    default org.apache.maven.model.Exclusion
    exclusion(NamedValue... keyValuePairs)
     
    default NamedValue
    exclusions(org.apache.maven.model.Exclusion... exclusions)
     
    default org.apache.maven.model.Dependency
    provided(String definition)
     
    default org.apache.maven.model.Repository
    repository(String id, String name, String url)
     
    default org.apache.maven.model.Repository
    repository(String id, String name, String url, String layout, org.apache.maven.model.RepositoryPolicy releases, org.apache.maven.model.RepositoryPolicy snapshots)
     
    default org.apache.maven.model.Repository
    repository(NamedValue... keyValuePairs)
    Factory method to create repository.
    default org.apache.maven.model.RepositoryPolicy
    repositoryPolicy(boolean enabled, String updatePolicy, String checksumPolicy)
     
    default org.apache.maven.model.Dependency
    runtime(String definition)
     
    default org.apache.maven.model.Dependency
    test(String definition)
     
  • Method Details

    • dependency

      default org.apache.maven.model.Dependency dependency(NamedValue... keyValuePairs)
      Factory method to create dependency.
      Each key-value pair is a construct
      key -> "value"
      Where 'key' is the name of the property to set and "value" is it's string value.
      All possible keys are:
      • groupId - The project group that produced the dependency, e.g. org.apache.maven.
      • artifactId - The unique id for an artifact produced by the project group, e.g. maven-artifact.
      • version - The version of the dependency, e.g. 3.2.1.
      • type - The type of dependency. 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 corresponds to the packaging used, though this is also not always the case. Some examples are jar, war, ejb-client and test-jar: see default artifact handlers for a list. New types can be defined by plugins that set extensions to true, so this is not a complete list. Default value is "jar"
      • classifier - The classifier of the dependency. It is appended to the filename after the version. This allows:
        • referring to attached artifact, for example sources and javadoc: see default artifact handlers for a list,
        • distinguishing two artifacts that belong to the same POM but were built differently. For example, jdk14 and jdk15.
      • scope - 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. The default scope is compile.
      • systemPath - 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}.
      • optional - 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. Note: While the type of this field is String for technical reasons, the semantic type is actually Boolean. Default value is false.
      • exclusions - see exmplanation below

      In addition to key-value pairs described above you can also you special method to define exclusions:

      • exclusions - List of dependency exclusions. Each individual exclusion can have two properties - groupId and artifactId(optional since you can exclude entire group).
         
         exclusions(
         	exclusion(groupId -> "grpToExclude", artifactId -> "artifactToExclue"),
         	exclusion(groupId -> "otherGrpToExclude", artifactId -> "otherArtifactToExclue")
         )
         
         
      Parameters:
      keyValuePairs - - array of key -> "value" pairs. Example: dependency(groupId -> "junit", artifactId -> "junit", version -> "3.8.1", scope -> "test")
      Returns:
      defined Dependency
    • dependency

      default org.apache.maven.model.Dependency dependency(String definition)
    • compile

      default org.apache.maven.model.Dependency compile(String definition)
    • provided

      default org.apache.maven.model.Dependency provided(String definition)
    • runtime

      default org.apache.maven.model.Dependency runtime(String definition)
    • test

      default org.apache.maven.model.Dependency test(String definition)
    • dependency

      default org.apache.maven.model.Dependency dependency(String definition, String scope)
    • repository

      default org.apache.maven.model.Repository repository(String id, String name, String url)
    • repository

      default org.apache.maven.model.Repository repository(NamedValue... keyValuePairs)
      Factory method to create repository. Used for both - "repositories" and "pluginRepositories"
      Each key-value pair is a construct
      key -> "value"
      Where 'key' is the name of the property to set and "value" is it's string value.
      All possible keys are:
      • id - A unique identifier for a repository. This is used to match the repository to configuration in the settings.xml file, for example. Furthermore, the identifier is used during POM inheritance and profile injection to detect repositories that should be merged.
      • name - Human readable name of the repository.
      • url - The url of the repository, in the form protocol://hostname/path
      • layout - The type of layout this repository uses for locating and storing artifacts - can be legacy or default
      Parameters:
      keyValuePairs - - array of key -> "value" pairs. Example: repository(id -> "my-repo", url -> "http://myserver/repo")
      Returns:
      defined Repository
    • repository

      default org.apache.maven.model.Repository repository(String id, String name, String url, String layout, org.apache.maven.model.RepositoryPolicy releases, org.apache.maven.model.RepositoryPolicy snapshots)
    • repositoryPolicy

      default org.apache.maven.model.RepositoryPolicy repositoryPolicy(boolean enabled, String updatePolicy, String checksumPolicy)
    • exclusions

      default NamedValue exclusions(org.apache.maven.model.Exclusion... exclusions)
    • exclusion

      default org.apache.maven.model.Exclusion exclusion(NamedValue... keyValuePairs)