org.jerkar.api.depmanagement
Class JkDependencies

java.lang.Object
  extended by org.jerkar.api.depmanagement.JkDependencies
All Implemented Interfaces:
java.io.Serializable, java.lang.Iterable<JkScopedDependency>

public class JkDependencies
extends java.lang.Object
implements java.lang.Iterable<JkScopedDependency>, java.io.Serializable

A set of JkScopedDependency generally standing for the entire dependencies of a project/module.

See Also:
Serialized Form

Nested Class Summary
static class JkDependencies.Builder
          Builder for JkDependencies
 
Method Summary
 JkDependencies and(java.lang.Iterable<java.io.File> files, JkScope... scopes)
          Returns a clone of this object plus JkScopedDependencys on the specified file.
 JkDependencies and(java.lang.Iterable<JkScopedDependency> others)
          Returns a clone of this object plus the specified JkScopedDependencys.
 JkDependencies and(JkScopedDependency... others)
          Returns a clone of this object plus the specified JkScopedDependencys.
 JkDependencies and(JkScope scope, java.io.File... files)
          Returns a clone of this object plus JkScopedDependencys on the specified file.
 JkDependencies and(JkScope scope, java.lang.String versionedModuleId)
          Returns a clone of this object plus JkScopedDependencys on the specified external module.
 JkDependencies and(java.lang.String groupAndName, java.lang.String version, JkScope... scopes)
          Returns a clone of this object plus the specified JkScopedDependencys.
 JkDependencies andScopeless(java.lang.Iterable<? extends JkDependency> others)
          Returns a clone of this object plus the specified JkScopedDependencys.
 JkDependencies assertNoUnspecifiedVersion()
          Throws a IllegalStateException if one of the module dependencies has an unspecified version.
static JkDependencies.Builder builder()
          Creates a Builder for JkDependencies
 boolean containsModules()
          Returns true if this object contains dependencies whose are JkModuleDependency.
 java.util.Set<JkScope> declaredScopes()
          Returns the set of scopes involved in these dependencies.
 java.util.Set<JkDependency> dependenciesDeclaredWith(JkScope scope)
          Returns the set of JkDependency involved for the specified JkScope.
 java.util.Set<JkDepExclude> excludes()
          Returns the dependencies to be excluded to the transitive chain when using this dependency.
 JkPath fileSystemDepsOnly(JkScope... scopes)
          Returns all files declared as JkFileSystemDependency for any of the specified scopes.
 JkScopedDependency get(JkModuleId moduleId)
          Returns the JkScopedDependency declared for the specified JkModuleId.
 boolean hasDynamicAndResovableVersions()
          Returns true if this object contains dependency on external module whose rely on dynamic version that are resolvable (Maven Snapshot versions are dynamic but not resolvable).
 boolean hasDynamicVersions()
          Returns true if this object contains dependency on external module whose rely on dynamic version.
 java.util.Set<JkScope> involvedScopes()
          Returns all scopes that are involved in these dependencies.
 boolean isEmpty()
          Returns true if this object contains no dependency.
 java.util.Iterator<JkScopedDependency> iterator()
           
 JkPath localFileDependencies(JkScope... scopes)
          Returns all files declared as JkDependency.JkFileDependency for any of the specified scopes.
 JkDependencies modulesOnly()
          Returns all dependencies declared as JkModuleDependency.
static JkDependencies of(java.lang.Iterable<? extends JkDependency> dependencies, JkScope... scopes)
          Creates a JkDependencies from the specified scopes and dependencies.
static JkDependencies of(JkModuleId moduleId, JkScope... scopes)
          Creates a JkDependencies on the specified module with unspecified version (expected to be resolved with a version provider).
static JkDependencies of(JkScopedDependency... scopedDependencies)
          Creates a JkDependencies from the specified scoped dependencies.
static JkDependencies of(JkScope scope, JkDependency... dependencies)
          Creates a JkDependencies from the specified scope and dependencies.
 JkDependencies onlyModules()
          Returns a set of dependencies that contains all and only module dependencies declared in this object.
 JkDependencies resolvedWith(java.lang.Iterable<JkVersionedModule> resolvedModules)
          Creates a clone of these dependencies replacing the dynamic versions by the static ones specified in the JkVersionedModules passed as argument.
 JkDependencies resolvedWith(JkVersionProvider provider)
           
 JkDependencies resolvedWithArtifacts(java.lang.Iterable<JkModuleDepFile> artifacts)
          Convenient method to resolve using JkModuleDepFiles instead of JkVersionedModule.
 JkDependencies resolvedWithOld(JkVersionProvider provider)
           
 java.lang.String toJavaCode(int indentCount)
          Returns the java codes that declare these dependencies.
 java.lang.String toString()
           
 JkDependencies withDefaultScope(JkScope... scopes)
          Returns a clone of this dependencies but replacing the unscoped dependencies with the scoped ones.
 JkDependencies withDefaultScopeMapping(JkScopeMapping scopeMapping)
          Returns a clone of this dependencies but replacing the unscoped dependencies with the scoped ones.
 JkDependencies withExclusions(JkDependencyExclusions exclusions)
          Create a JkDependencies identical to this one but adding exclusion clause
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

of

public static JkDependencies of(JkScopedDependency... scopedDependencies)
Creates a JkDependencies from the specified scoped dependencies.


of

public static JkDependencies of(JkModuleId moduleId,
                                JkScope... scopes)
Creates a JkDependencies on the specified module with unspecified version (expected to be resolved with a version provider).


of

public static JkDependencies of(JkScope scope,
                                JkDependency... dependencies)
Creates a JkDependencies from the specified scope and dependencies.


of

public static JkDependencies of(java.lang.Iterable<? extends JkDependency> dependencies,
                                JkScope... scopes)
Creates a JkDependencies from the specified scopes and dependencies.


isEmpty

public boolean isEmpty()
Returns true if this object contains no dependency.


withDefaultScope

public JkDependencies withDefaultScope(JkScope... scopes)
Returns a clone of this dependencies but replacing the unscoped dependencies with the scoped ones.


withDefaultScopeMapping

public JkDependencies withDefaultScopeMapping(JkScopeMapping scopeMapping)
Returns a clone of this dependencies but replacing the unscoped dependencies with the scoped ones.


and

public JkDependencies and(java.lang.Iterable<JkScopedDependency> others)
Returns a clone of this object plus the specified JkScopedDependencys.


andScopeless

public JkDependencies andScopeless(java.lang.Iterable<? extends JkDependency> others)
Returns a clone of this object plus the specified JkScopedDependencys.


and

public JkDependencies and(JkScopedDependency... others)
Returns a clone of this object plus the specified JkScopedDependencys.


and

public JkDependencies and(java.lang.String groupAndName,
                          java.lang.String version,
                          JkScope... scopes)
Returns a clone of this object plus the specified JkScopedDependencys.


and

public JkDependencies and(JkScope scope,
                          java.io.File... files)
Returns a clone of this object plus JkScopedDependencys on the specified file.


and

public JkDependencies and(java.lang.Iterable<java.io.File> files,
                          JkScope... scopes)
Returns a clone of this object plus JkScopedDependencys on the specified file.


and

public JkDependencies and(JkScope scope,
                          java.lang.String versionedModuleId)
Returns a clone of this object plus JkScopedDependencys on the specified external module.

Parameters:
versionedModuleId - something like "org.apache:commons:1.4"

containsModules

public boolean containsModules()
Returns true if this object contains dependencies whose are JkModuleDependency.


iterator

public java.util.Iterator<JkScopedDependency> iterator()
Specified by:
iterator in interface java.lang.Iterable<JkScopedDependency>

excludes

public java.util.Set<JkDepExclude> excludes()
Returns the dependencies to be excluded to the transitive chain when using this dependency.

Returns:

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

dependenciesDeclaredWith

public java.util.Set<JkDependency> dependenciesDeclaredWith(JkScope scope)
Returns the set of JkDependency involved for the specified JkScope.


get

public JkScopedDependency get(JkModuleId moduleId)
Returns the JkScopedDependency declared for the specified JkModuleId. Returns null if no dependency on this module exists in this object.


declaredScopes

public java.util.Set<JkScope> declaredScopes()
Returns the set of scopes involved in these dependencies.


involvedScopes

public java.util.Set<JkScope> involvedScopes()
Returns all scopes that are involved in these dependencies. That means if one of these scoped dependencies is declared with scope 'FOO' and scope 'BAR' extends scope 'FOO', then 'FOO' and 'BAR' is part of involved scopes.


hasDynamicVersions

public boolean hasDynamicVersions()
Returns true if this object contains dependency on external module whose rely on dynamic version. It can be either dynamic version as "1.3.+", "[1.0, 2.0[" ,... or snapshot version as defined in Maven (as "1.0-SNAPSHOT).


hasDynamicAndResovableVersions

public boolean hasDynamicAndResovableVersions()
Returns true if this object contains dependency on external module whose rely on dynamic version that are resolvable (Maven Snapshot versions are dynamic but not resolvable). It only stands for dynamic versions as "1.3.+", "[1.0, 2.0[" ,... If so, when resolving, dynamic versions are replaced by fixed resolved ones.


resolvedWithArtifacts

public JkDependencies resolvedWithArtifacts(java.lang.Iterable<JkModuleDepFile> artifacts)
Convenient method to resolve using JkModuleDepFiles instead of JkVersionedModule.

See Also:
resolvedWith(Iterable)

onlyModules

public JkDependencies onlyModules()
Returns a set of dependencies that contains all and only module dependencies declared in this object.


resolvedWith

public JkDependencies resolvedWith(java.lang.Iterable<JkVersionedModule> resolvedModules)
Creates a clone of these dependencies replacing the dynamic versions by the static ones specified in the JkVersionedModules passed as argument.


resolvedWithOld

public JkDependencies resolvedWithOld(JkVersionProvider provider)
See Also:
resolvedWith(Iterable)

resolvedWith

public JkDependencies resolvedWith(JkVersionProvider provider)
See Also:
resolvedWith(Iterable)

withExclusions

public JkDependencies withExclusions(JkDependencyExclusions exclusions)
Create a JkDependencies identical to this one but adding exclusion clause

Parameters:
exclusions -
Returns:

localFileDependencies

public JkPath localFileDependencies(JkScope... scopes)
Returns all files declared as JkDependency.JkFileDependency for any of the specified scopes.


fileSystemDepsOnly

public JkPath fileSystemDepsOnly(JkScope... scopes)
Returns all files declared as JkFileSystemDependency for any of the specified scopes. If no scopes are specified then it returns all file system dependencies.


builder

public static JkDependencies.Builder builder()
Creates a Builder for JkDependencies


assertNoUnspecifiedVersion

public JkDependencies assertNoUnspecifiedVersion()
Throws a IllegalStateException if one of the module dependencies has an unspecified version.


toJavaCode

public java.lang.String toJavaCode(int indentCount)
Returns the java codes that declare these dependencies.


modulesOnly

public JkDependencies modulesOnly()
Returns all dependencies declared as JkModuleDependency.