Author: chemit Date: 2008-11-21 15:37:49 +0000 (Fri, 21 Nov 2008) New Revision: 1244 Modified: maven-license-switcher-plugin/trunk/changelog maven-license-switcher-plugin/trunk/src/main/java/org/codelutin/license/plugin/ThirdPartyMojo.java Log: fix bug when no name is defined in license Modified: maven-license-switcher-plugin/trunk/changelog =================================================================== --- maven-license-switcher-plugin/trunk/changelog 2008-11-20 14:03:08 UTC (rev 1243) +++ maven-license-switcher-plugin/trunk/changelog 2008-11-21 15:37:49 UTC (rev 1244) @@ -1,6 +1,7 @@ ver-0-5 chemit 200811?? + * 20081121 [chemit] fix bug when no name is defined in license * 20081118 [chemit] use lutinpluginproject 3.1 - + ver-0-4 chemit 20081013 * 20081013 [chemit] Improve third-party goal : onyl keep included dependencies Modified: maven-license-switcher-plugin/trunk/src/main/java/org/codelutin/license/plugin/ThirdPartyMojo.java =================================================================== --- maven-license-switcher-plugin/trunk/src/main/java/org/codelutin/license/plugin/ThirdPartyMojo.java 2008-11-20 14:03:08 UTC (rev 1243) +++ maven-license-switcher-plugin/trunk/src/main/java/org/codelutin/license/plugin/ThirdPartyMojo.java 2008-11-21 15:37:49 UTC (rev 1244) @@ -135,7 +135,7 @@ // must generate if file does not exist doGenerate = doGenerate || !thirdPartyFile.exists(); - if ("pom".equals(project.getPackaging()) || "site".equals(project.getPackaging())) { + if ("pom".equals(project.getPackaging()) || "site".equals(project.getPackaging())) { // nothing to be done for this type of packaging doGenerate = false; getLog().info("skip third-party goal for packaging " + project.getPackaging()); @@ -232,8 +232,17 @@ licenseMap.put(unknownLicenseMessage, artifactName); } else { - for (Object license : licenses) { - licenseMap.put(((License) license).getName(), artifactName); + for (Object o : licenses) { + if (o == null) { + getLog().warn("could not acquire the license for " + artifactName); + continue; + } + License license = (License) o; + String licenseKey = license.getName(); + if (license.getName() == null) { + licenseKey = license.getUrl(); + } + licenseMap.put(licenseKey, artifactName); } } }