# This patch file was generated by NetBeans IDE
# Following Index: paths are relative to: /Users/mkleint/src/core-main
# This patch can be applied using context Tools: Patch action on respective folder.
# It uses platform neutral UTF-8 encoding and \n newlines.
# Above lines and this line are ignored by the patching process.
Index: java.api.common/manifest.mf
--- java.api.common/manifest.mf Base (BASE)
+++ java.api.common/manifest.mf Locally Modified (Based On LOCAL)
@@ -1,4 +1,4 @@
Manifest-Version: 1.0
OpenIDE-Module: org.netbeans.modules.java.api.common/0
OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/java/api/common/resources/Bundle.properties
-OpenIDE-Module-Specification-Version: 1.43
+OpenIDE-Module-Specification-Version: 1.44
Index: java.api.common/nbproject/project.xml
--- java.api.common/nbproject/project.xml Base (BASE)
+++ java.api.common/nbproject/project.xml Locally Modified (Based On LOCAL)
@@ -135,7 +135,7 @@
1
- 1.59
+ 1.69
@@ -192,7 +192,7 @@
- 6.9
+ 7.47
Index: java.api.common/src/org/netbeans/modules/java/api/common/queries/TemplateAttributesProviderImpl.java
--- java.api.common/src/org/netbeans/modules/java/api/common/queries/TemplateAttributesProviderImpl.java Base (BASE)
+++ java.api.common/src/org/netbeans/modules/java/api/common/queries/TemplateAttributesProviderImpl.java Locally Modified (Based On LOCAL)
@@ -39,6 +39,8 @@
*/
package org.netbeans.modules.java.api.common.queries;
+import java.io.File;
+import java.net.URI;
import java.nio.charset.Charset;
import java.util.Collections;
import java.util.HashMap;
@@ -52,9 +54,11 @@
import org.netbeans.spi.project.support.ant.AntProjectHelper;
import org.netbeans.spi.project.support.ant.EditableProperties;
import org.netbeans.spi.queries.FileEncodingQueryImplementation;
+import org.openide.filesystems.FileUtil;
import org.openide.loaders.CreateFromTemplateAttributesProvider;
import org.openide.loaders.DataFolder;
import org.openide.loaders.DataObject;
+import org.openide.util.Utilities;
/**
* Default implementation of {@link CreateFromTemplateAttributesProvider}.
@@ -77,6 +81,19 @@
Map values = new HashMap();
EditableProperties priv = helper.getProperties(AntProjectHelper.PRIVATE_PROPERTIES_PATH);
EditableProperties props = helper.getProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH);
+ String licensePath = priv.getProperty("project.licensePath");
+ if (licensePath == null) {
+ licensePath = props.getProperty("project.licensePath");
+ }
+ if (licensePath != null) {
+ licensePath = helper.getStandardPropertyEvaluator().evaluate(licensePath);
+ File path = FileUtil.normalizeFile(new File(licensePath));
+ if (path.exists() && path.isAbsolute()) { //is this necessary? should prevent failed license header inclusion
+ URI uri = Utilities.toURI(path);
+ licensePath = uri.toString();
+ values.put("licensePath", licensePath);
+ }
+ }
String license = priv.getProperty("project.license"); // NOI18N
if (license == null) {
license = props.getProperty("project.license"); // NOI18N
Index: libs.freemarker/nbproject/project.properties
--- libs.freemarker/nbproject/project.properties Base (BASE)
+++ libs.freemarker/nbproject/project.properties Locally Modified (Based On LOCAL)
@@ -46,7 +46,7 @@
javac.source=1.6
release.external/freemarker-2.3.8.jar=modules/ext/freemarker-2.3.8.jar
module.jar.verifylinkageignores=freemarker.((ext.ant.FreemarkerXmlTask)|(template.DefaultObjectWrapper))
-spec.version.base=2.23.0
+spec.version.base=2.24.0
test.config.stableBTD.includes=**/*Test.class
test.config.stableBTD.excludes=\
Index: libs.freemarker/nbproject/project.xml
--- libs.freemarker/nbproject/project.xml Base (BASE)
+++ libs.freemarker/nbproject/project.xml Locally Modified (Based On LOCAL)
@@ -96,6 +96,10 @@
+ org.netbeans.modules.masterfs
+
+
+
org.netbeans.modules.nbjunit
Index: libs.freemarker/src/org/netbeans/libs/freemarker/FreemarkerEngine.java
--- libs.freemarker/src/org/netbeans/libs/freemarker/FreemarkerEngine.java Base (BASE)
+++ libs.freemarker/src/org/netbeans/libs/freemarker/FreemarkerEngine.java Locally Modified (Based On LOCAL)
@@ -40,6 +40,7 @@
import java.util.Properties;
import java.util.Set;
import freemarker.template.*;
+import java.net.URI;
import java.util.Collections;
import java.util.Map;
import java.util.WeakHashMap;
@@ -50,6 +51,7 @@
import org.openide.filesystems.FileRenameEvent;
import org.openide.filesystems.FileUtil;
import org.openide.util.Exceptions;
+import org.openide.util.Utilities;
/* Taken from A. Sundararajan and adopted by Jaroslav Tulach
* for NetBeans needs.
Index: libs.freemarker/src/org/netbeans/libs/freemarker/RsrcLoader.java
--- libs.freemarker/src/org/netbeans/libs/freemarker/RsrcLoader.java Base (BASE)
+++ libs.freemarker/src/org/netbeans/libs/freemarker/RsrcLoader.java Locally Modified (Based On LOCAL)
@@ -35,10 +35,13 @@
import freemarker.template.TemplateExceptionHandler;
import freemarker.template.TemplateModel;
import freemarker.template.TemplateModelException;
+import java.io.File;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.Reader;
import java.io.Writer;
+import java.net.URI;
+import java.net.URISyntaxException;
import java.nio.charset.Charset;
import java.util.Enumeration;
import java.util.LinkedHashSet;
@@ -53,6 +56,7 @@
import org.openide.filesystems.FileStateInvalidException;
import org.openide.filesystems.FileUtil;
import org.openide.util.Exceptions;
+import org.openide.util.Utilities;
/**
* Velocity templates resource loader rewritten for Freemarker to
@@ -92,6 +96,13 @@
private FileObject getFile(String name) {
FileObject tmp = (getFolder() == null) ? null : getFolder().getFileObject(name);
+ if (tmp == null) {
+ try {
+ tmp = FileUtil.toFileObject(FileUtil.normalizeFile(Utilities.toFile(new URI(name))));
+ } catch (URISyntaxException ex) {
+ } catch (IllegalArgumentException iae) {
+ }
+ }
return tmp;
}
Index: libs.freemarker/test/unit/data/licenseheader.txt
--- libs.freemarker/test/unit/data/licenseheader.txt Base (BASE)
+++ libs.freemarker/test/unit/data/licenseheader.txt Locally New
@@ -0,0 +1 @@
+TEST LICENSE
Index: libs.freemarker/test/unit/src/org/netbeans/freemarker/templates/ScriptingCreateFromTemplateTest.java
--- libs.freemarker/test/unit/src/org/netbeans/freemarker/templates/ScriptingCreateFromTemplateTest.java Base (BASE)
+++ libs.freemarker/test/unit/src/org/netbeans/freemarker/templates/ScriptingCreateFromTemplateTest.java Locally Modified (Based On LOCAL)
@@ -34,6 +34,7 @@
package org.netbeans.freemarker.templates;
+import java.io.File;
import java.io.IOException;
import java.io.OutputStream;
import java.nio.charset.Charset;
@@ -42,6 +43,7 @@
import java.util.Map;
import javax.swing.text.DefaultEditorKit;
import javax.swing.text.Document;
+import static junit.framework.Assert.assertEquals;
import org.netbeans.api.editor.mimelookup.MimePath;
import org.netbeans.api.queries.FileEncodingQuery;
import org.netbeans.junit.MockServices;
@@ -57,6 +59,7 @@
import org.netbeans.api.editor.mimelookup.test.MockMimeLookup;
import org.openide.loaders.CreateFromTemplateHandler;
import org.openide.util.SharedClassObject;
+import org.openide.util.Utilities;
import org.openide.util.test.MockLookup;
/**
@@ -141,6 +144,24 @@
*/
}
+ public void testExternalLicenseFile() throws Exception {
+ File license = new File(getDataDir(), "licenseheader.txt");
+ assertTrue(license.exists());
+ FileObject root = FileUtil.createMemoryFileSystem().getRoot();
+ FileObject template = FileUtil.createData(root, "simple.pl");
+ OutputStream os = template.getOutputStream();
+ os.write("#!/usr/bin/perl\n<#include \"${licensePath}\">".getBytes());
+ os.close();
+ System.out.println(template.asText());
+ template.setAttribute("template", true);
+ template.setAttribute("javax.script.ScriptEngine", "freemarker");
+ Map parameters = new HashMap();
+ parameters.put("licensePath", Utilities.toURI(license).toString());
+ FileObject inst = DataObject.find(template).createFromTemplate(DataFolder.findFolder(root), "pl", parameters).getPrimaryFile();
+ System.out.println(inst.asText());
+ assertTrue(inst.asText().contains("TEST LICENSE"));
+ }
+
//fix for this test was rolled back because of issue #120865
public void XtestCreateFromTemplateDocumentCreated() throws Exception {
FileObject root = FileUtil.createMemoryFileSystem().getRoot();
Index: maven/manifest.mf
--- maven/manifest.mf Base (BASE)
+++ maven/manifest.mf Locally Modified (Based On LOCAL)
@@ -1,6 +1,6 @@
Manifest-Version: 1.0
OpenIDE-Module: org.netbeans.modules.maven/2
-OpenIDE-Module-Specification-Version: 2.70
+OpenIDE-Module-Specification-Version: 2.71
OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/maven/Bundle.properties
OpenIDE-Module-Layer: org/netbeans/modules/maven/layer.xml
AutoUpdate-Show-In-Client: false
Index: maven/nbproject/project.xml
--- maven/nbproject/project.xml Base (BASE)
+++ maven/nbproject/project.xml Locally Modified (Based On LOCAL)
@@ -258,7 +258,7 @@
1
- 1.67
+ 1.69
@@ -349,7 +349,7 @@
- 7.1
+ 7.47
Index: maven/src/org/netbeans/modules/maven/TemplateAttrProvider.java
--- maven/src/org/netbeans/modules/maven/TemplateAttrProvider.java Base (BASE)
+++ maven/src/org/netbeans/modules/maven/TemplateAttrProvider.java Locally Modified (Based On LOCAL)
@@ -42,6 +42,10 @@
package org.netbeans.modules.maven;
+import java.io.File;
+import java.net.MalformedURLException;
+import java.net.URI;
+import java.net.URISyntaxException;
import java.nio.charset.Charset;
import java.util.Arrays;
import java.util.Collections;
@@ -67,6 +71,8 @@
import org.openide.loaders.CreateFromTemplateAttributesProvider;
import org.openide.loaders.DataFolder;
import org.openide.loaders.DataObject;
+import org.openide.util.Exceptions;
+import org.openide.util.Utilities;
/**
*
@@ -83,6 +89,16 @@
public @Override Map attributesFor(DataObject template, DataFolder target, String name) {
Map values = new TreeMap();
+ String licensePath = project.getLookup().lookup(AuxiliaryProperties.class).get(Constants.HINT_LICENSE_PATH, true); //NOI18N
+ if (licensePath != null) {
+ File path = FileUtil.normalizeFile(new File(licensePath));
+ if (path.exists() && path.isAbsolute()) { //is this necessary? should prevent failed license header inclusion
+ URI uri = Utilities.toURI(path);
+ licensePath = uri.toString();
+ values.put("licensePath", licensePath);
+ }
+ }
+
String license = project.getLookup().lookup(AuxiliaryProperties.class).get(Constants.HINT_LICENSE, true); //NOI18N
MavenProject mp = project.getLookup().lookup(NbMavenProject.class).getMavenProject();
if (license == null) {
Index: maven/src/org/netbeans/modules/maven/api/Constants.java
--- maven/src/org/netbeans/modules/maven/api/Constants.java Base (BASE)
+++ maven/src/org/netbeans/modules/maven/api/Constants.java Locally Modified (Based On LOCAL)
@@ -58,6 +58,11 @@
public static final String HINT_LICENSE = "netbeans.hint.license"; //NOI18N
/**
+ * Maven property that hints netbeans to use a given license template file in project space, rather than the IDE's user space
+ */
+ public static final String HINT_LICENSE_PATH = "netbeans.hint.licensePath"; //NOI18N
+
+ /**
* Maven property that designates the jdk platform to use in the IDE on classpath for project.
* Equivalent to the "platform.active" property in Ant based projects.
* Workaround for issue http://www.netbeans.org/issues/show_bug.cgi?id=104974
Index: openide.loaders/manifest.mf
--- openide.loaders/manifest.mf Base (BASE)
+++ openide.loaders/manifest.mf Locally Modified (Based On LOCAL)
@@ -1,6 +1,6 @@
Manifest-Version: 1.0
OpenIDE-Module: org.openide.loaders
-OpenIDE-Module-Specification-Version: 7.46
+OpenIDE-Module-Specification-Version: 7.47
OpenIDE-Module-Localizing-Bundle: org/openide/loaders/Bundle.properties
OpenIDE-Module-Provides: org.netbeans.modules.templates.v1_0
OpenIDE-Module-Layer: org/netbeans/modules/openide/loaders/layer.xml
Index: projectuiapi/arch.xml
--- projectuiapi/arch.xml Base (BASE)
+++ projectuiapi/arch.xml Locally Modified (Based On LOCAL)
@@ -719,6 +719,8 @@
The encoding of the parent folder of the new file is used if the attribute was not found in any
project lookup.
+ contains String
path to the license header include file, by default as path to Templates/Licenses/license-${project.license}.txt
system filesystem location, but a local filesystem absolute path is also supported.
+
Index: projectuiapi/nbproject/project.properties
--- projectuiapi/nbproject/project.properties Base (BASE)
+++ projectuiapi/nbproject/project.properties Locally Modified (Based On LOCAL)
@@ -42,7 +42,7 @@
javac.compilerargs=-Xlint -Xlint:-serial
javac.source=1.6
-spec.version.base=1.68.0
+spec.version.base=1.69.0
is.autoload=true
javadoc.arch=${basedir}/arch.xml
javadoc.apichanges=${basedir}/apichanges.xml
Index: projectuiapi/src/org/netbeans/modules/project/uiapi/ProjectTemplateAttributesProvider.java
--- projectuiapi/src/org/netbeans/modules/project/uiapi/ProjectTemplateAttributesProvider.java Base (BASE)
+++ projectuiapi/src/org/netbeans/modules/project/uiapi/ProjectTemplateAttributesProvider.java Locally Modified (Based On LOCAL)
@@ -44,6 +44,7 @@
package org.netbeans.modules.project.uiapi;
+import java.net.URI;
import java.nio.charset.Charset;
import java.util.Collections;
import java.util.HashMap;
@@ -52,6 +53,7 @@
import org.netbeans.api.project.Project;
import org.netbeans.api.queries.FileEncodingQuery;
import org.openide.filesystems.FileObject;
+import org.openide.filesystems.FileUtil;
import org.openide.loaders.CreateFromTemplateAttributesProvider;
import org.openide.loaders.DataFolder;
import org.openide.loaders.DataObject;
@@ -68,6 +70,7 @@
private static final String ATTR_PROJECT = "project"; // NOI18N
private static final String ATTR_LICENSE = "license"; // NOI18N
+ private static final String ATTR_LICENSE_PATH = "licensePath"; // NOI18N
private static final String ATTR_ENCODING = "encoding"; // NOI18N
public Map attributesFor(
@@ -94,7 +97,7 @@
Object prjAttrObj = m != null? m.get(ATTR_PROJECT): null;
if (prjAttrObj instanceof Map) {
Map prjAttrs = NbCollections.checkedMapByFilter((Map) prjAttrObj, String.class, Object.class, false);
- if (prjAttrs.get(ATTR_LICENSE) == null || prjAttrs.get(ATTR_ENCODING) == null) {
+ if (prjAttrs.get(ATTR_LICENSE) == null || prjAttrs.get(ATTR_ENCODING) == null || prjAttrs.get(ATTR_LICENSE_PATH) == null) {
Map newPrjAttrs = new HashMap(prjAttrs);
m.put(ATTR_PROJECT, newPrjAttrs);
ensureProjectAttrs(newPrjAttrs, parent);
@@ -118,6 +121,26 @@
if (map.get(ATTR_LICENSE) == null) {
map.put(ATTR_LICENSE, "default"); // NOI18N
}
+ if (map.get(ATTR_LICENSE_PATH) == null) {
+ map.put(ATTR_LICENSE_PATH, "Templates/Licenses/license-" + map.get(ATTR_LICENSE).toString() + ".txt"); // NOI18N
+ }
+ String url = map.get(ATTR_LICENSE_PATH).toString();
+ if (FileUtil.getConfigFile(url) == null) { //now we have filesystem based template for sure, convert to file:///path to have freemarker process it
+ try {
+ URI uri = URI.create(url);
+ //freemarker.cache.TemplateCache.normalizeName appears to
+ // check for :// to skip processing the path
+ map.put(ATTR_LICENSE_PATH, new URI("file", "", uri.getPath(), null).toString());
+ } catch (Exception malformedURLException) {
+ }
+ } else {
+ // now we have to assume we are dealing with the teplate from system filesystem.
+ // in order to get through the freemarker, the path needs to "absolute" in freemarker terms - http://freemarker.sourceforge.net/docs/ref_directive_include.html
+ // relative would mean relative to the template and we cannot be sure what the path from template to license template is..
+ // it used to be, ../Licenses/ or ../../Licenses but can be anything similar, just based on where the template resides.
+ map.put(ATTR_LICENSE_PATH, "/" + url);
+ //appears to cover both the new and old default value of the include path
+ }
if (map.get(ATTR_ENCODING) == null) {
Charset charset = FileEncodingQuery.getEncoding(parent);
String encoding = charset != null ? charset.name() : "UTF-8"; // NOI18N