001 /** 002 * Copyright 2010-2012 The Kuali Foundation 003 * 004 * Licensed under the Educational Community License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.opensource.org/licenses/ecl2.php 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016 package org.codehaus.mojo.license; 017 018 import java.io.File; 019 import java.io.IOException; 020 import java.util.Collection; 021 import java.util.List; 022 import java.util.SortedMap; 023 import java.util.SortedSet; 024 025 import org.apache.maven.artifact.repository.ArtifactRepository; 026 import org.apache.maven.model.License; 027 import org.apache.maven.project.MavenProject; 028 import org.codehaus.mojo.license.model.LicenseMap; 029 030 /** 031 * A tool to load third party files missing files. 032 * <p/> 033 * We should put here all the logic code written in some mojo and licenseMap... 034 * 035 * @author tchemit <chemit@codelutin.com> 036 * @since 1.0 037 */ 038 public interface ThirdPartyTool { 039 040 /** 041 * Plexus Role 042 */ 043 String ROLE = ThirdPartyTool.class.getName(); 044 045 /** 046 * @param encoding 047 * encoding used to read or write properties files 048 * @param projects 049 * all projects where to read third parties descriptors 050 * @param unsafeProjects 051 * all unsafe projects 052 * @param licenseMap 053 * license map where to store new licenses 054 * @param localRepository 055 * local repository 056 * @param remoteRepositories 057 * remote repositories 058 * @return the map of loaded missing from the remote missing third party files 059 * @throws ThirdPartyToolException 060 * if any 061 * @throws IOException 062 * if any 063 */ 064 SortedProperties loadThirdPartyDescriptorsForUnsafeMapping(String encoding, Collection<MavenProject> projects, 065 SortedSet<MavenProject> unsafeProjects, LicenseMap licenseMap, ArtifactRepository localRepository, 066 List<ArtifactRepository> remoteRepositories) throws ThirdPartyToolException, IOException; 067 068 /** 069 * For the given {@code project}, attach the given {@code file} as a third-party file. 070 * <p/> 071 * The file will be attached as with a classifier {@code third-parties} and a type {@code properties}. 072 * 073 * @param project 074 * the project on which to attch the third-party file 075 * @param file 076 * the third-party file to attach. 077 */ 078 void attachThirdPartyDescriptor(MavenProject project, File file); 079 080 /** 081 * Obtain the third party file from the repository. 082 * <p/> 083 * Will first search in the local repository, then into the remote repositories and will resolv it. 084 * 085 * @param project 086 * the project 087 * @param localRepository 088 * the local repository 089 * @param repositories 090 * the remote repositories 091 * @return the locale file resolved into the local repository 092 * @throws ThirdPartyToolException 093 * if any 094 */ 095 File resolvThirdPartyDescriptor(MavenProject project, ArtifactRepository localRepository, 096 List<ArtifactRepository> repositories) throws ThirdPartyToolException; 097 098 /** 099 * From the given {@code licenseMap}, obtain all the projects with no license. 100 * 101 * @param licenseMap 102 * the license map to query 103 * @param doLog 104 * a flag to add debug logs 105 * @return the set of projects with no license 106 */ 107 SortedSet<MavenProject> getProjectsWithNoLicense(LicenseMap licenseMap, boolean doLog); 108 109 SortedProperties loadUnsafeMapping(LicenseMap licenseMap, SortedMap<String, MavenProject> artifactCache, 110 String encoding, File missingFile) throws IOException; 111 112 /** 113 * Add a license (name and url are {@code licenseName}) to the given {@code licenseMap} for the given 114 * {@code project}. 115 * 116 * @param licenseMap 117 * the license map where to add the license 118 * @param project 119 * the project 120 * @param licenseName 121 * the name of the license 122 */ 123 void addLicense(LicenseMap licenseMap, MavenProject project, String licenseName); 124 125 /** 126 * Add a given {@code license} to the given {@code licenseMap} for the given {@code project}. 127 * 128 * @param licenseMap 129 * the license map where to add the license 130 * @param project 131 * the project 132 * @param license 133 * the license to add 134 */ 135 void addLicense(LicenseMap licenseMap, MavenProject project, License license); 136 137 /** 138 * Add a given {@code licenses} to the given {@code licenseMap} for the given {@code project}. 139 * 140 * @param licenseMap 141 * the license map where to add the licenses 142 * @param project 143 * the project 144 * @param licenses 145 * the licenses to add 146 */ 147 void addLicense(LicenseMap licenseMap, MavenProject project, List<?> licenses); 148 149 /** 150 * For a given {@code licenseMap}, merge all {@code licenses}. 151 * <p/> 152 * The first value of the {@code licenses} is the license to keep and all other values will be merged into the first 153 * one. 154 * 155 * @param licenseMap 156 * the license map to merge 157 * @param licenses 158 * all the licenses to merge (the first license will be the unique one to kkep) 159 */ 160 void mergeLicenses(LicenseMap licenseMap, String... licenses); 161 }