Skip to content

Instantly share code, notes, and snippets.

@ysb33r
Last active November 4, 2022 14:18
Show Gist options
  • Save ysb33r/5804364 to your computer and use it in GitHub Desktop.
Save ysb33r/5804364 to your computer and use it in GitHub Desktop.
The Groovy way to obtain a relative path given two paths.
def root= new File('/usr/share')
def full= new File('/usr/share/docs/rpm-4.4')
// Print the relative path of 'full' in relation to 'root'
// Notice that the full path is passed as a parameter to the root.
def relPath= new File( root.toURI().relativize( full.toURI() ).toString() )
@retraut
Copy link

retraut commented Jul 6, 2020

hudson.remoting.ProxyException: groovy.lang.MissingMethodException: No signature of method: java.lang.String.toPath() is applicable

@figroc
Copy link

figroc commented Jul 18, 2020

hudson.remoting.ProxyException: groovy.lang.MissingMethodException: No signature of method: java.lang.String.toPath() is applicable

It is File::toPath, not String::toPath.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment