public final class JkModuleDependency extends java.lang.Object implements JkFileDependency.JkTransitivityDependency
The version or version range identify which versions are likely to be compatible with the project to build.
For example, both org.hibernate:hibernate-core:3.0.+
and
org.hibernate:hibernate-core:3.0.1
are a legal descriptions for module dependency.
Modifier and Type | Class and Description |
---|---|
static class |
JkModuleDependency.JkArtifactSpecification
When declaring a module dependency, we implicitly request for the main artifact of this module.
|
Modifier and Type | Field and Description |
---|---|
static java.util.Comparator<JkModuleDependency> |
GROUP_NAME_COMPARATOR
Comparator for
JkModuleDependency sorting dependency by their group then by their name. |
Modifier and Type | Method and Description |
---|---|
JkModuleDependency |
andClassifier(java.lang.String classifier) |
JkModuleDependency |
andClassifierAndType(java.lang.String classifier,
java.lang.String type)
Returns a JkModuleDependency identical to this one but adding the specified
classifier and type
JkModuleDependency.JkArtifactSpecification . |
JkModuleDependency |
andExclusion(java.lang.Iterable<JkDependencyExclusion> depExcludes)
Returns a JkModuleDependency identical to this one but adding the
specified exclusion.
|
JkModuleDependency |
andExclusion(JkDependencyExclusion... depExcludes)
Returns a JkModuleDependency identical to this one but adding the
specified exclusion.
|
JkModuleDependency |
andExclusion(java.lang.String groupAndName)
Returns a JkModuleDependency identical to this one but adding the
specified exclusion.
|
boolean |
equals(java.lang.Object o) |
java.util.Set<JkModuleDependency.JkArtifactSpecification> |
getArtifactSpecifications()
Returns the
JkModuleDependency.JkArtifactSpecification s for this module dependency. |
java.util.List<JkDependencyExclusion> |
getExclusions()
Returns modules to exclude to the transitive chain.
|
java.nio.file.Path |
getIdeProjectDir()
In the IDE, a dependency can be provided by a project exporting it.
|
JkModuleId |
getModuleId()
Returns the getModuleId of this dependency.
|
JkTransitivity |
getTransitivity()
Returns
true if this dependency should be resolved transitively (returning the dependencies
of this dependency recursively). |
JkVersion |
getVersion()
Returns the version of the module this dependencies is constrained to.
|
int |
hashCode() |
boolean |
hasUnspecifiedVersion()
Returns
true if the version of the module for this dependency is not specified. |
static boolean |
isModuleDependencyDescription(java.lang.String candidate)
Returns
true if the specified candidate matches to a module description. |
boolean |
matches(JkDependency other)
Returns
true if the specified dependency matches with this one. |
static JkModuleDependency |
of(JkModuleId moduleId,
JkVersion version)
Creates a
JkModuleDependency to the specified getModuleId and
JkVersionrange . |
static JkModuleDependency |
of(JkModuleId moduleId,
java.lang.String versionRange)
Creates a
JkModuleDependency to its getModuleId and
JkVersionrange . |
static JkModuleDependency |
of(JkVersionedModule versionedModule)
Creates a
JkModuleDependency to the specified versioned module. |
static JkModuleDependency |
of(java.lang.String description)
Description can be :
group:name
group:name:version
group:name:classifiers...:version
group:name:classifiers:type:version
classifiers may be a single classifier or a a list of as linux,mac.
|
static JkModuleDependency |
of(java.lang.String group,
java.lang.String name,
java.lang.String version)
Creates a
JkModuleDependency to its group, name and version
range. |
java.lang.String |
toString() |
JkVersionedModule |
toVersionedModule() |
JkModuleDependency |
withClassifiers(java.lang.String classifier) |
JkModuleDependency |
withClassifiersAndType(java.lang.String classifiers,
java.lang.String type)
Returns a JkModuleDependency identical to this one but with the specified
classifiers and type as the only
JkModuleDependency.JkArtifactSpecification for this dependency |
JkModuleDependency |
withIdeProjectDir(java.nio.file.Path path)
Returns a dependency identical to this one but with the specified project base dir.
|
JkModuleDependency |
withTransitivity(JkTransitivity transitivity)
Returns a
JkModuleDependency identical to this one but with the specified 'transitive' property. |
JkModuleDependency |
withVersion(JkVersion version)
Returns a JkModuleDependency identical to this one but with the specified
static version.
|
JkModuleDependency |
withVersion(java.lang.String version) |
public static final java.util.Comparator<JkModuleDependency> GROUP_NAME_COMPARATOR
JkModuleDependency
sorting dependency by their group then by their name.public static JkModuleDependency of(JkModuleId moduleId, JkVersion version)
JkModuleDependency
to the specified getModuleId and
JkVersionrange
.public static JkModuleDependency of(JkVersionedModule versionedModule)
JkModuleDependency
to the specified versioned module.public static JkModuleDependency of(JkModuleId moduleId, java.lang.String versionRange)
JkModuleDependency
to its getModuleId and
JkVersionrange
.public static JkModuleDependency of(java.lang.String group, java.lang.String name, java.lang.String version)
JkModuleDependency
to its group, name and version
range. The version range can be any string accepted by
JkVersion.of(String)
.public static JkModuleDependency of(java.lang.String description)
public static boolean isModuleDependencyDescription(java.lang.String candidate)
true
if the specified candidate matches to a module description.of(String)
public JkTransitivity getTransitivity()
true
if this dependency should be resolved transitively (returning the dependencies
of this dependency recursively).getTransitivity
in interface JkFileDependency.JkTransitivityDependency
public JkModuleId getModuleId()
public JkVersion getVersion()
public JkModuleDependency withTransitivity(JkTransitivity transitivity)
JkModuleDependency
identical to this one but with the specified 'transitive' property.public boolean hasUnspecifiedVersion()
true
if the version of the module for this dependency is not specified.public JkModuleDependency withVersion(JkVersion version)
null
then returned version is this one.public JkModuleDependency withVersion(java.lang.String version)
public JkModuleDependency withClassifiers(java.lang.String classifier)
withClassifiersAndType(String, String)
public JkModuleDependency withClassifiersAndType(java.lang.String classifiers, java.lang.String type)
JkModuleDependency.JkArtifactSpecification
for this dependencyclassifiers
- classifiers separated with ','. Example 'linux,max' stands for
linux and mac classifier. ',mac' stands for the default classifier +
mac classifierpublic JkModuleDependency andClassifier(java.lang.String classifier)
andClassifierAndType(String, String)
public JkModuleDependency andClassifierAndType(java.lang.String classifier, java.lang.String type)
JkModuleDependency.JkArtifactSpecification
.public java.util.Set<JkModuleDependency.JkArtifactSpecification> getArtifactSpecifications()
JkModuleDependency.JkArtifactSpecification
s for this module dependency. It can e empty if no
artifact specification as een set. In this case, only the main artifact is taken in account.public JkModuleDependency andExclusion(JkDependencyExclusion... depExcludes)
public JkModuleDependency andExclusion(java.lang.String groupAndName)
public JkModuleDependency andExclusion(java.lang.Iterable<JkDependencyExclusion> depExcludes)
public java.util.List<JkDependencyExclusion> getExclusions()
public java.lang.String toString()
toString
in class java.lang.Object
public java.nio.file.Path getIdeProjectDir()
JkDependency
null
when the dependencies is not coming from another project.getIdeProjectDir
in interface JkDependency
public JkModuleDependency withIdeProjectDir(java.nio.file.Path path)
JkDependency
withIdeProjectDir
in interface JkDependency
JkDependency.getIdeProjectDir()
public JkVersionedModule toVersionedModule()
public boolean matches(JkDependency other)
JkDependency
true
if the specified dependency matches with this one. Matching means that two matching dependencies can not be declared in a same dependency set as it will be considered as a duplicate or result in a conflict.
For example "com.google:guava:21.0" is matching with "com.google:guava:23.0" even if they are not equals.
matches
in interface JkDependency
public boolean equals(java.lang.Object o)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object