[Arakhnę-Dev] [424] * Add installation of license files for Maven dependencies.

[ Thread Index | Date Index | More arakhne.org/dev Archives ]


Revision: 424
Author:   galland
Date:     2013-04-27 14:52:11 +0200 (Sat, 27 Apr 2013)
Log Message:
-----------
* Add installation of license files for Maven dependencies.

Modified Paths:
--------------
    trunk/license-installer/src/main/java/org/arakhne/maven/plugins/licenseinstaller/InstallLicenseMojo.java

Modified: trunk/license-installer/src/main/java/org/arakhne/maven/plugins/licenseinstaller/InstallLicenseMojo.java
===================================================================
--- trunk/license-installer/src/main/java/org/arakhne/maven/plugins/licenseinstaller/InstallLicenseMojo.java	2013-04-11 16:48:10 UTC (rev 423)
+++ trunk/license-installer/src/main/java/org/arakhne/maven/plugins/licenseinstaller/InstallLicenseMojo.java	2013-04-27 12:52:11 UTC (rev 424)
@@ -213,18 +213,38 @@
 		File licFile;
 
 		Map<String, License> includedLicenses = new HashMap<String,License>();
-		Pattern re = Pattern.compile("^([^:]+):(.+)$"); //$NON-NLS-1$
+		Pattern re1 = Pattern.compile("^([^:]+):(.+):(.+)$"); //$NON-NLS-1$
+		Pattern re2 = Pattern.compile("^([^:]+):(.+)$"); //$NON-NLS-1$
 		if (this.thirdPartyLicenses != null) {
 			for (String tpl : this.thirdPartyLicenses) {
-				Matcher matcher = re.matcher(tpl);
+				Matcher matcher = re1.matcher(tpl);
 				if (matcher.matches()) {
 					String l = matcher.group(1);
 					String f = matcher.group(2);
 					lic = License.parse(l, null);
 					if (lic != null) {
-						includedLicenses.put(f, lic);
+						StringBuilder sb = new StringBuilder();
+						sb.append(this.name);
+						sb.append("_"); //$NON-NLS-1$
+						String b = f.replaceAll("[/\\:]", "."); //$NON-NLS-1$ //$NON-NLS-2$
+						b = b.replaceAll("^\\.", ""); //$NON-NLS-1$ //$NON-NLS-2$
+						sb.append(b);
+						includedLicenses.put(sb.toString(), lic);
 					}
 				}
+				else {
+					matcher = re2.matcher(tpl);
+					if (matcher.matches()) {
+						String l = matcher.group(1);
+						String g = matcher.group(2);
+						String a = matcher.group(3);
+						lic = License.parse(l, null);
+						if (lic != null) {
+							String depName = "mvndep_"+g+"_"+a; //$NON-NLS-1$ //$NON-NLS-2$
+							includedLicenses.put(depName, lic);
+						}
+					}
+				}
 			}
 		}
 
@@ -265,17 +285,7 @@
 				lic = licenseMap.getValue();
 				resource = lic.getFullTextResource();
 				if (resource != null) {
-
-					StringBuilder sb = new StringBuilder();
-					sb.append(this.name);
-					sb.append("_"); //$NON-NLS-1$
-					
-					String b = licenseMap.getKey();
-					b = b.replaceAll("[/\\:]", "."); //$NON-NLS-1$ //$NON-NLS-2$
-					b = b.replaceAll("^\\.", ""); //$NON-NLS-1$ //$NON-NLS-2$
-					sb.append(b);
-
-					filename = LICENSE_FILENAME_PATTERN.replaceAll("%s", sb.toString()); //$NON-NLS-1$ 
+					filename = LICENSE_FILENAME_PATTERN.replaceAll("%s", licenseMap.getKey()); //$NON-NLS-1$ 
 					filename = filename.replaceAll("%l", lic.name()); //$NON-NLS-1$
 
 					info("Installing included source code license: ", //$NON-NLS-1$


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/