private List getLicenses()

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


    private List<License> getLicenses(final ApisJarContext ctx, final ArtifactInfo info) {
        getLog().debug("Getting license for " + info.getId().toMvnId());
        List<License> result = info.getLicenses();
        if (result == null) {
            try {
                ArtifactId id = info.getId();
                do {
                    final Model model = getArtifactPom(ctx, id);
                    final List<License> ll = model.getLicenses();

                    if (ll != null && !ll.isEmpty()) {
                        getLog().debug("Found license for " + id.toMvnId());
                        result = ll;
                    } else {
                        if (model.getParent() != null) {
                            final ArtifactId newId = new ArtifactId(
                                    model.getParent().getGroupId(),
                                    model.getParent().getArtifactId(),
                                    model.getParent().getVersion(),
                                    null,
                                    "pom");
                            if (newId.equals(id)) {
                                break;
                            } else {
                                id = newId;
                            }
                        } else {
                            break;
                        }
                    }
                } while (result == null);
            } catch (MojoExecutionException m) {
                // nothing to do
            }
            if (result == null) {
                result = Collections.emptyList();
            }
            info.setLicenses(result);
        }
        getLog().debug("License for " + info.getId().toMvnId() + " = " + result);
        return result;
    }