Package org.gradle.util
Class Path
java.lang.Object
org.gradle.util.Path
- All Implemented Interfaces:
- Comparable<Path>
Represents a path in Gradle.
- 
Field SummaryFields
- 
Method SummaryModifier and TypeMethodDescriptionabsolutePath(String path) Resolves the given name relative to this path.absolutePath(Path path) Iterate over all ancestors of this path, starting with the root path (if absolute) or the first segment (if relative) and not including this path.Appends the supplied path to this path, returning the new path.Creates a child of this path with the given name.intbooleangetName()Returns the base name of this path, or null if this path is the root path.Returns the parent of this path, or null if this path has no parent.getPath()inthashCode()booleanstatic PathrelativePath(String path) Calculates a path relative to this path.relativePath(Path path) removeFirstSegments(int n) segment(int index) intsegments()returns an immutable list of the segments of this pathtakeFirstSegments(int n) Returns aPathcontaining only the firstnsegments of thisPath.toString()static voidvalidatePath(String path) throws if no path is specified
- 
Field Details- 
ROOT
- 
SEPARATOR- See Also:
 
 
- 
- 
Method Details- 
path
- 
validatePaththrows if no path is specified- Since:
- 8.5
 
- 
toString
- 
appendAppends the supplied path to this path, returning the new path. The resulting path with be absolute or relative based on the path being appended _to_. It makes no difference if the _appended_ path is absolute or relative.path(':a:b').append(path(':c:d')) == path(':a:b:c:d') path(':a:b').append(path('c:d')) == path(':a:b:c:d') path('a:b').append(path(':c:d')) == path('a:b:c:d') path('a:b').append(path('c:d')) == path('a:b:c:d')
- 
getPath
- 
segmentsreturns an immutable list of the segments of this path- Since:
- 8.5
 
- 
equals
- 
hashCodepublic int hashCode()
- 
compareTo- Specified by:
- compareToin interface- Comparable<Path>
 
- 
getParentReturns the parent of this path, or null if this path has no parent.- Returns:
- The parent of this path.
 
- 
getNameReturns the base name of this path, or null if this path is the root path.- Returns:
- The base name,
 
- 
childCreates a child of this path with the given name.
- 
absolutePathResolves the given name relative to this path. If an absolute path is provided, it is returned.
- 
absolutePath
- 
isAbsolutepublic boolean isAbsolute()
- 
relativePathCalculates a path relative to this path. If the given path is not a child of this path, it is returned unmodified.
- 
relativePath
- 
segmentCountpublic int segmentCount()
- 
removeFirstSegments
- 
segment
- 
takeFirstSegmentsReturns aPathcontaining only the firstnsegments of thisPath. The returnedPathwill be absolute if thisPathis absolute.- Parameters:
- n- number of segments to take from this Path, must be greater than or equal to 1
- Since:
- 8.4
 
- 
ancestorsIterate over all ancestors of this path, starting with the root path (if absolute) or the first segment (if relative) and not including this path.For example, the path :a:b:chas the ancestors:,:a, and:a:b. The patha:b:chas the ancestorsa, anda:b.- Since:
- 8.13
 
 
-