# HG changeset patch # Parent b34b440a8079ccb7621932e47cc88d8a0760ef64 # User Jesse Glick # Date 1396367083 14400 Bug #243453: honor canonical OSI license URLs as well as older URLs. diff --git a/maven.grammar/src/org/netbeans/modules/maven/codegen/NewLicensePanel.java b/maven.grammar/src/org/netbeans/modules/maven/codegen/NewLicensePanel.java --- a/maven.grammar/src/org/netbeans/modules/maven/codegen/NewLicensePanel.java +++ b/maven.grammar/src/org/netbeans/modules/maven/codegen/NewLicensePanel.java @@ -200,7 +200,7 @@ dn = dn.substring("license-".length()); } } - Tuple tup = new Tuple(url, dn); + Tuple tup = new Tuple(url.replaceFirst(" .+", ""), dn); dlm.addElement(tup); } } diff --git a/maven/src/org/netbeans/modules/maven/TemplateAttrProvider.java b/maven/src/org/netbeans/modules/maven/TemplateAttrProvider.java --- a/maven/src/org/netbeans/modules/maven/TemplateAttrProvider.java +++ b/maven/src/org/netbeans/modules/maven/TemplateAttrProvider.java @@ -48,7 +48,6 @@ import java.util.Arrays; import java.util.Collections; import java.util.HashMap; -import java.util.List; import java.util.Map; import java.util.TreeMap; import java.util.logging.Level; @@ -188,17 +187,19 @@ public static String findLicenseByMavenProjectContent(MavenProject mp) { // try to match the project's license URL and the mavenLicenseURL attribute of license template - String toRet = null; - List lst = mp.getLicenses(); - if (!lst.isEmpty()) { - String url = lst.get(0).getUrl(); - FileObject licenses = FileUtil.getConfigFile("Templates/Licenses"); //NOI18N - if (url != null && licenses != null) { - for (FileObject fo : licenses.getChildren()) { + FileObject licensesFO = FileUtil.getConfigFile("Templates/Licenses"); //NOI18N + if (licensesFO == null) { + return null; + } + FileObject[] licenseFiles = licensesFO.getChildren(); + for (License license : mp.getLicenses()) { + String url = license.getUrl(); + if (url != null) { + for (FileObject fo : licenseFiles) { String str = (String)fo.getAttribute("mavenLicenseURL"); //NOI18N - if (str != null && str.equalsIgnoreCase(url)) { + if (str != null && Arrays.asList(str.split(" ")).contains(url)) { if (fo.getName().startsWith("license-")) { // NOI18N - toRet = fo.getName().substring("license-".length()); //NOI18N + return fo.getName().substring("license-".length()); //NOI18N } else { Logger.getLogger(TemplateAttrProvider.class.getName()).log(Level.WARNING, "Bad license file name {0} (expected to start with ''license-'' prefix)", fo.getName()); } @@ -207,6 +208,6 @@ } } } - return toRet; + return null; } } diff --git a/projectui/src/org/netbeans/modules/project/ui/resources/layer.xml b/projectui/src/org/netbeans/modules/project/ui/resources/layer.xml --- a/projectui/src/org/netbeans/modules/project/ui/resources/layer.xml +++ b/projectui/src/org/netbeans/modules/project/ui/resources/layer.xml @@ -201,36 +201,36 @@ - + - + - + - + - + - + - + diff --git a/templates/src/org/netbeans/modules/templates/ui/TemplatesPanel.java b/templates/src/org/netbeans/modules/templates/ui/TemplatesPanel.java --- a/templates/src/org/netbeans/modules/templates/ui/TemplatesPanel.java +++ b/templates/src/org/netbeans/modules/templates/ui/TemplatesPanel.java @@ -975,8 +975,8 @@ "TemplatesPanel_TemplateNode_DisplayName_Desc=Display name of this template. Shown in File|New wizard as well as in Tools|Templates.", "TemplatesPanel_TemplateNode_FileName=File Name", "TemplatesPanel_TemplateNode_FileName_Desc=File name of file represented by this template.", - "TemplatesPanel_TemplateNode_License=License URL", - "TemplatesPanel_TemplateNode_License_Desc=Authoritative web location of this license.", + "TemplatesPanel_TemplateNode_License=License URL(s)", + "TemplatesPanel_TemplateNode_License_Desc=Authoritative web location of this license (may include several separated by spaces).", "TemplatesPanel_TemplateNode_ScriptEngine=Script Engine", "TemplatesPanel_TemplateNode_ScriptEngine_Desc=Script engine use for processing this template.", "TemplatesPanel_TemplateNode_TemplateCategories=Template Categories",