String (@Nullable String extraArtifactClassifier, @Nullable String customExtension) { String path = getPath(); if (extraArtifactClassifier == null && customExtension == null && Objects.equals(myVersion, myBaseVersion)) { return path; } int slashPos = path.lastIndexOf('/'); if (slashPos != -1) { StringBuilder res = new StringBuilder(); res.append(path, 0, slashPos + 1); res.append(myArtifactId); res.append('-'); res.append(myVersion); String fullClassifier = getFullClassifier(extraArtifactClassifier); if (fullClassifier != null) { res.append('-').append(fullClassifier); } res.append('.'); res.append(customExtension == null ? myExtension : customExtension); return res.toString(); } // unknown path format: try to add a classified at the end of the filename int dotPos = path.lastIndexOf('.'); if (dotPos != -1) {// sometimes path doesn't contain '.'; but i can't find any reason why. return path.substring(0, dotPos) + '-' + extraArtifactClassifier + (customExtension == null ? myExtension : customExtension); } return path; }