1 /* 2 * #%L 3 * License Maven Plugin 4 * 5 * $Id: ThirdPartyTool.java 14409 2011-08-10 15:30:41Z tchemit $ 6 * $HeadURL: http://svn.codehaus.org/mojo/tags/license-maven-plugin-1.0/src/main/java/org/codehaus/mojo/license/ThirdPartyTool.java $ 7 * %% 8 * Copyright (C) 2011 CodeLutin, Codehaus, Tony Chemit 9 * %% 10 * This program is free software: you can redistribute it and/or modify 11 * it under the terms of the GNU Lesser General Public License as 12 * published by the Free Software Foundation, either version 3 of the 13 * License, or (at your option) any later version. 14 * 15 * This program is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU General Lesser Public License for more details. 19 * 20 * You should have received a copy of the GNU General Lesser Public 21 * License along with this program. If not, see 22 * <http://www.gnu.org/licenses/lgpl-3.0.html>. 23 * #L% 24 */ 25 package org.codehaus.mojo.license; 26 27 import java.io.File; 28 import java.io.IOException; 29 import java.util.Collection; 30 import java.util.List; 31 import java.util.SortedMap; 32 import java.util.SortedSet; 33 34 import org.apache.maven.artifact.repository.ArtifactRepository; 35 import org.apache.maven.model.License; 36 import org.apache.maven.project.MavenProject; 37 import org.codehaus.mojo.license.model.LicenseMap; 38 39 /** 40 * A tool to load third party files missing files. 41 * <p/> 42 * We should put here all the logic code written in some mojo and licenseMap... 43 * 44 * @author tchemit <chemit@codelutin.com> 45 * @since 1.0 46 */ 47 public interface ThirdPartyTool { 48 49 /** 50 * Plexus Role 51 */ 52 String ROLE = ThirdPartyTool.class.getName(); 53 54 /** 55 * @param encoding 56 * encoding used to read or write properties files 57 * @param projects 58 * all projects where to read third parties descriptors 59 * @param unsafeProjects 60 * all unsafe projects 61 * @param licenseMap 62 * license map where to store new licenses 63 * @param localRepository 64 * local repository 65 * @param remoteRepositories 66 * remote repositories 67 * @return the map of loaded missing from the remote missing third party files 68 * @throws ThirdPartyToolException 69 * if any 70 * @throws IOException 71 * if any 72 */ 73 SortedProperties loadThirdPartyDescriptorsForUnsafeMapping(String encoding, Collection<MavenProject> projects, 74 SortedSet<MavenProject> unsafeProjects, LicenseMap licenseMap, ArtifactRepository localRepository, 75 List<ArtifactRepository> remoteRepositories) throws ThirdPartyToolException, IOException; 76 77 /** 78 * For the given {@code project}, attach the given {@code file} as a third-party file. 79 * <p/> 80 * The file will be attached as with a classifier {@code third-parties} and a type {@code properties}. 81 * 82 * @param project 83 * the project on which to attch the third-party file 84 * @param file 85 * the third-party file to attach. 86 */ 87 void attachThirdPartyDescriptor(MavenProject project, File file); 88 89 /** 90 * Obtain the third party file from the repository. 91 * <p/> 92 * Will first search in the local repository, then into the remote repositories and will resolv it. 93 * 94 * @param project 95 * the project 96 * @param localRepository 97 * the local repository 98 * @param repositories 99 * the remote repositories 100 * @return the locale file resolved into the local repository 101 * @throws ThirdPartyToolException 102 * if any 103 */ 104 File resolvThirdPartyDescriptor(MavenProject project, ArtifactRepository localRepository, 105 List<ArtifactRepository> repositories) throws ThirdPartyToolException; 106 107 /** 108 * From the given {@code licenseMap}, obtain all the projects with no license. 109 * 110 * @param licenseMap 111 * the license map to query 112 * @param doLog 113 * a flag to add debug logs 114 * @return the set of projects with no license 115 */ 116 SortedSet<MavenProject> getProjectsWithNoLicense(LicenseMap licenseMap, boolean doLog); 117 118 SortedProperties loadUnsafeMapping(LicenseMap licenseMap, SortedMap<String, MavenProject> artifactCache, 119 String encoding, File missingFile) throws IOException; 120 121 /** 122 * Add a license (name and url are {@code licenseName}) to the given {@code licenseMap} for the given 123 * {@code project}. 124 * 125 * @param licenseMap 126 * the license map where to add the license 127 * @param project 128 * the project 129 * @param licenseName 130 * the name of the license 131 */ 132 void addLicense(LicenseMap licenseMap, MavenProject project, String licenseName); 133 134 /** 135 * Add a given {@code license} to the given {@code licenseMap} for the given {@code project}. 136 * 137 * @param licenseMap 138 * the license map where to add the license 139 * @param project 140 * the project 141 * @param license 142 * the license to add 143 */ 144 void addLicense(LicenseMap licenseMap, MavenProject project, License license); 145 146 /** 147 * Add a given {@code licenses} to the given {@code licenseMap} for the given {@code project}. 148 * 149 * @param licenseMap 150 * the license map where to add the licenses 151 * @param project 152 * the project 153 * @param licenses 154 * the licenses to add 155 */ 156 void addLicense(LicenseMap licenseMap, MavenProject project, List<?> licenses); 157 158 /** 159 * For a given {@code licenseMap}, merge all {@code licenses}. 160 * <p/> 161 * The first value of the {@code licenses} is the license to keep and all other values will be merged into the first 162 * one. 163 * 164 * @param licenseMap 165 * the license map to merge 166 * @param licenses 167 * all the licenses to merge (the first license will be the unique one to kkep) 168 */ 169 void mergeLicenses(LicenseMap licenseMap, String... licenses); 170 }