Search in sources :

Example 1 with LicensedProjects

use of org.apache.hyracks.maven.license.project.LicensedProjects in project asterixdb by apache.

the class GenerateFileMojo method resolveLicenseContent.

private void resolveLicenseContent() throws IOException {
    Set<LicenseSpec> licenseSpecs = new HashSet<>();
    for (LicensedProjects licensedProjects : licenseMap.values()) {
        licenseSpecs.add(licensedProjects.getLicense());
    }
    licenseSpecs.addAll(urlToLicenseMap.values());
    for (LicenseSpec license : licenseSpecs) {
        resolveLicenseContent(license, true);
    }
}
Also used : LicensedProjects(org.apache.hyracks.maven.license.project.LicensedProjects) HashSet(java.util.HashSet)

Example 2 with LicensedProjects

use of org.apache.hyracks.maven.license.project.LicensedProjects in project asterixdb by apache.

the class SourcePointerResolver method collectSourcePointers.

private void collectSourcePointers() throws ProjectBuildingException, IOException {
    try (StubArtifactRepository stubRepo = new StubArtifactRepository()) {
        DefaultRepositoryRequest rr = new DefaultRepositoryRequest();
        rr.setLocalRepository(stubRepo);
        ArtifactRepository central = getCentralRepository();
        rr.setRemoteRepositories(Collections.singletonList(central));
        ArtifactResolutionRequest request = new ArtifactResolutionRequest(rr);
        for (LicensedProjects lp : mojo.getLicenseMap().values()) {
            if (lp.getLicense().getDisplayName() != null && lp.getLicense().getDisplayName().toLowerCase().contains("cddl")) {
                ensureCDDLSourcesPointer(lp.getProjects(), central, request);
            }
        }
    }
}
Also used : LicensedProjects(org.apache.hyracks.maven.license.project.LicensedProjects) ArtifactResolutionRequest(org.apache.maven.artifact.resolver.ArtifactResolutionRequest) ArtifactRepository(org.apache.maven.artifact.repository.ArtifactRepository) DefaultRepositoryRequest(org.apache.maven.artifact.repository.DefaultRepositoryRequest)

Example 3 with LicensedProjects

use of org.apache.hyracks.maven.license.project.LicensedProjects in project asterixdb by apache.

the class LicenseMojo method addProject.

protected void addProject(Project project, LicenseSpec spec, boolean additive) {
    String licenseUrl = spec.getUrl();
    LicenseSpec license = urlToLicenseMap.get(licenseUrl);
    if (license == null) {
        license = spec;
        urlToLicenseMap.put(licenseUrl, license);
        for (String alias : license.getAliasUrls()) {
            if (!urlToLicenseMap.containsKey(alias)) {
                urlToLicenseMap.put(alias, license);
            }
        }
    } else if (license.getDisplayName() == null && spec.getDisplayName() != null) {
        getLog().info("Propagating license name from " + project.gav() + ": " + spec.getDisplayName());
        license.setDisplayName(spec.getDisplayName());
    }
    licenseUrl = license.getUrl();
    LicensedProjects entry = licenseMap.get(licenseUrl);
    if (entry == null) {
        entry = new LicensedProjects(license);
        licenseMap.put(licenseUrl, entry);
    }
    if (additive || entry.getProjects().contains(project)) {
        entry.addProject(project);
    }
}
Also used : LicensedProjects(org.apache.hyracks.maven.license.project.LicensedProjects)

Example 4 with LicensedProjects

use of org.apache.hyracks.maven.license.project.LicensedProjects in project asterixdb by apache.

the class GenerateFileMojo method rebuildLicenseContentProjectMap.

private void rebuildLicenseContentProjectMap() throws IOException {
    int counter = 0;
    Map<String, LicensedProjects> licenseMap2 = new TreeMap<>(WHITESPACE_NORMALIZED_COMPARATOR);
    for (LicensedProjects lps : licenseMap.values()) {
        for (Project p : lps.getProjects()) {
            String licenseText = p.getLicenseText();
            if (licenseText == null) {
                getLog().warn("Using license other than from within artifact: " + p.gav());
                licenseText = resolveLicenseContent(lps.getLicense(), false);
            }
            LicenseSpec spec = lps.getLicense();
            if (spec.getDisplayName() == null) {
                LicenseSpec canonicalLicense = urlToLicenseMap.get(spec.getUrl());
                if (canonicalLicense != null) {
                    spec.setDisplayName(canonicalLicense.getDisplayName());
                }
            }
            if (!licenseMap2.containsKey(licenseText)) {
                if (!licenseText.equals(lps.getLicense().getContent())) {
                    spec = new LicenseSpec(new ArrayList<>(), licenseText, null, spec.getDisplayName(), spec.getMetric(), spec.getUrl() + (counter++));
                }
                licenseMap2.put(licenseText, new LicensedProjects(spec));
            }
            final LicensedProjects lp2 = licenseMap2.get(licenseText);
            if (lp2.getLicense().getDisplayName() == null) {
                lp2.getLicense().setDisplayName(lps.getLicense().getDisplayName());
            }
            lp2.addProject(p);
        }
    }
    licenseMap = licenseMap2;
}
Also used : LicensedProjects(org.apache.hyracks.maven.license.project.LicensedProjects) Project(org.apache.hyracks.maven.license.project.Project) ArrayList(java.util.ArrayList) TreeMap(java.util.TreeMap)

Example 5 with LicensedProjects

use of org.apache.hyracks.maven.license.project.LicensedProjects in project asterixdb by apache.

the class GenerateFileMojo method combineCommonGavs.

private void combineCommonGavs() {
    for (LicensedProjects licensedProjects : licenseMap.values()) {
        Map<String, Project> projectMap = new HashMap<>();
        for (Iterator<Project> iter = licensedProjects.getProjects().iterator(); iter.hasNext(); ) {
            Project project = iter.next();
            if (projectMap.containsKey(project.gav())) {
                Project first = projectMap.get(project.gav());
                first.setLocation(first.getLocation() + "," + project.getLocation());
                iter.remove();
            } else {
                projectMap.put(project.gav(), project);
            }
        }
    }
}
Also used : LicensedProjects(org.apache.hyracks.maven.license.project.LicensedProjects) Project(org.apache.hyracks.maven.license.project.Project) HashMap(java.util.HashMap)

Aggregations

LicensedProjects (org.apache.hyracks.maven.license.project.LicensedProjects)7 Project (org.apache.hyracks.maven.license.project.Project)3 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)2 SequenceWriter (com.fasterxml.jackson.databind.SequenceWriter)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 TreeMap (java.util.TreeMap)1 ArtifactRepository (org.apache.maven.artifact.repository.ArtifactRepository)1 DefaultRepositoryRequest (org.apache.maven.artifact.repository.DefaultRepositoryRequest)1 ArtifactResolutionRequest (org.apache.maven.artifact.resolver.ArtifactResolutionRequest)1