class JGitSourceReferencesProvider implements SourceReferencesProvider {

    String getRelativePath(File subDir, File parentDir) throws MojoExecutionException {
        URI subDirUri;
        URI relativeUri;
        try {
            // have to canonicalize before comparing on case-insensitive filesystems
            subDirUri = subDir.getCanonicalFile().toURI();
            relativeUri = parentDir.getCanonicalFile().toURI().relativize(subDirUri);
        } catch (IOException e) {
            throw new MojoExecutionException(e.getMessage(), e);
        }
        if (relativeUri.equals(subDirUri)) {
            throw new MojoExecutionException(subDir + " is not a subdir of " + parentDir);
        }
        String relative = relativeUri.getPath();
        // remove surrounding slashes
        if (relative.startsWith("/")) {
            relative = relative.substring(1);
        }
        if (relative.endsWith("/")) {
            relative = relative.substring(0, relative.length() - 1);
        }
        return relative;
    }

}