# 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)
@@ -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)
@@ -77,6 +77,13 @@
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);
+ }
String license = priv.getProperty("project.license"); // NOI18N
if (license == null) {
license = props.getProperty("project.license"); // NOI18N
@@ -106,11 +113,17 @@
//not really important, just log.
Logger.getLogger(TemplateAttributesProviderImpl.class.getName()).log(Level.FINE, "", ex);
}
-
- if (values.isEmpty()) {
- return null;
+ if (!values.isEmpty() || licensePath != null) {
+ HashMap toRet = new HashMap();
+ if (!values.isEmpty()) {
+ toRet.put("project", values);
+ }
+ if (licensePath != null) {
+ toRet.put("licensePath", licensePath);
+ }
+ return toRet;
} else {
- return Collections.singletonMap("project", values); // NOI18N
+ return null;
}
}
}
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.
@@ -100,6 +102,31 @@
public Object eval(Reader reader, ScriptContext ctx)
throws ScriptException {
ctx.setAttribute("context", ctx, ScriptContext.ENGINE_SCOPE);
+ Bindings bindings = ctx.getBindings(ScriptContext.ENGINE_SCOPE);
+ Object lic = bindings.get("licensePath");
+ if (lic != null) {
+ String url = lic.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
+ lic = new URI("file", "", uri.getPath(), null).toString();
+ bindings.put("licensePath", lic);
+ } 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.
+ bindings.put("licensePath", "/" + url);
+ //appears to cover both the new and old default value of the include path
+ }
+
+ }
+
+
initFreeMarkerConfiguration(ctx);
String fileName = getFilename(ctx);
boolean outputAsString = isStringOutputMode(ctx);
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)
@@ -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,14 @@
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();
+ }
+ }
String license = project.getLookup().lookup(AuxiliaryProperties.class).get(Constants.HINT_LICENSE, true); //NOI18N
MavenProject mp = project.getLookup().lookup(NbMavenProject.class).getMavenProject();
if (license == null) {
@@ -142,8 +156,15 @@
}
}
- if (values.size() > 0) {
- return Collections.singletonMap("project", values); // NOI18N
+ if (!values.isEmpty() || licensePath != null) {
+ HashMap toRet = new HashMap();
+ if (!values.isEmpty()) {
+ toRet.put("project", values);
+ }
+ if (licensePath != null) {
+ toRet.put("licensePath", licensePath);
+ }
+ return toRet;
} else {
return 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: openide.loaders/src/org/openide/loaders/DataObject.java
--- openide.loaders/src/org/openide/loaders/DataObject.java Base (BASE)
+++ openide.loaders/src/org/openide/loaders/DataObject.java Locally Modified (Based On LOCAL)
@@ -1509,6 +1509,19 @@
if (!all.containsKey("dateTime")) { // NOI18N
all.put("dateTime", d); // NOI18N
}
+ if (!all.containsKey("licensePath")) {
+ String licenseName = "default";
+ Object prj = all.get("project");
+ if (prj != null && prj instanceof Map) {
+ Map prjMap = (Map)prj;
+ Object licenseNameO = prjMap.get("license");
+ if (licenseNameO != null) {
+ licenseName = licenseNameO.toString();
+ }
+ }
+ //if licensePath not filled, use this path relative to FileUtil.getConfigRoot()
+ all.put("licensePath", "Templates/Licenses/license-" + licenseName + ".txt");
+ }
return Collections.unmodifiableMap(all);
}