String inferClassifier()

in src/main/java/org/apache/sling/feature/maven/mojos/ApisJarMojo.java [1240:1261]


    String inferClassifier(String bundleName, String artifactId, String version) {
        if (bundleName == null || artifactId == null || version == null) return null;

        int idx = bundleName.lastIndexOf('/');
        if (idx >= 0) bundleName = bundleName.substring(idx + 1);

        int edx = bundleName.lastIndexOf('.');
        if (edx > 0) bundleName = bundleName.substring(0, edx);

        // bundleName is now the bare name without extension
        String synthesized = artifactId + "-" + version;
        if (synthesized.length() < bundleName.length() && bundleName.startsWith(synthesized)) {
            String suffix = bundleName.substring(synthesized.length());
            if (suffix.length() > 1 && suffix.startsWith("-")) {
                String classifier = suffix.substring(1);
                getLog().debug("Inferred classifier of '" + artifactId + ":" + version + "' to be '" + classifier
                        + "'");
                return classifier;
            }
        }
        return null;
    }