This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

View | Details | Raw Unified | Return to bug 193981
Collapse All | Expand All

(-)java.api.common/manifest.mf (-1 / +1 lines)
Lines 1-4 Link Here
1
Manifest-Version: 1.0
1
Manifest-Version: 1.0
2
OpenIDE-Module: org.netbeans.modules.java.api.common/0
2
OpenIDE-Module: org.netbeans.modules.java.api.common/0
3
OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/java/api/common/resources/Bundle.properties
3
OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/java/api/common/resources/Bundle.properties
4
OpenIDE-Module-Specification-Version: 1.43
4
OpenIDE-Module-Specification-Version: 1.44
(-)java.api.common/nbproject/project.xml (-1 / +1 lines)
Lines 192-198 Link Here
192
                    <build-prerequisite/>
192
                    <build-prerequisite/>
193
                    <compile-dependency/>
193
                    <compile-dependency/>
194
                    <run-dependency>
194
                    <run-dependency>
195
                        <specification-version>6.9</specification-version>
195
                        <specification-version>7.47</specification-version>
196
                    </run-dependency>
196
                    </run-dependency>
197
                </dependency>
197
                </dependency>
198
                <dependency>
198
                <dependency>
(-)java.api.common/src/org/netbeans/modules/java/api/common/queries/TemplateAttributesProviderImpl.java (-4 / +17 lines)
Lines 77-82 Link Here
77
        Map<String, String> values = new HashMap<String, String>();
77
        Map<String, String> values = new HashMap<String, String>();
78
        EditableProperties priv  = helper.getProperties(AntProjectHelper.PRIVATE_PROPERTIES_PATH);
78
        EditableProperties priv  = helper.getProperties(AntProjectHelper.PRIVATE_PROPERTIES_PATH);
79
        EditableProperties props = helper.getProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH);
79
        EditableProperties props = helper.getProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH);
80
        String licensePath = priv.getProperty("project.licensePath");
81
        if (licensePath == null) {
82
            licensePath = props.getProperty("project.licensePath");
83
        }
84
        if (licensePath != null) {
85
            licensePath = helper.getStandardPropertyEvaluator().evaluate(licensePath);
86
        }
80
        String license = priv.getProperty("project.license"); // NOI18N
87
        String license = priv.getProperty("project.license"); // NOI18N
81
        if (license == null) {
88
        if (license == null) {
82
            license = props.getProperty("project.license"); // NOI18N
89
            license = props.getProperty("project.license"); // NOI18N
Lines 106-116 Link Here
106
            //not really important, just log.
113
            //not really important, just log.
107
            Logger.getLogger(TemplateAttributesProviderImpl.class.getName()).log(Level.FINE, "", ex);
114
            Logger.getLogger(TemplateAttributesProviderImpl.class.getName()).log(Level.FINE, "", ex);
108
        }
115
        }
109
116
        if (!values.isEmpty() || licensePath != null) {
110
        if (values.isEmpty()) {
117
            HashMap<String,Object> toRet = new HashMap<String,Object>();
111
            return null;
118
            if (!values.isEmpty()) {
119
                toRet.put("project", values);
120
            }
121
            if (licensePath != null) {
122
                toRet.put("licensePath", licensePath);
123
            }
124
            return toRet;
112
        } else {
125
        } else {
113
            return Collections.singletonMap("project", values); // NOI18N
126
            return null;
114
        }
127
        }
115
    }
128
    }
116
}
129
}
(-)libs.freemarker/nbproject/project.properties (-1 / +1 lines)
Lines 46-52 Link Here
46
javac.source=1.6
46
javac.source=1.6
47
release.external/freemarker-2.3.8.jar=modules/ext/freemarker-2.3.8.jar
47
release.external/freemarker-2.3.8.jar=modules/ext/freemarker-2.3.8.jar
48
module.jar.verifylinkageignores=freemarker.((ext.ant.FreemarkerXmlTask)|(template.DefaultObjectWrapper))
48
module.jar.verifylinkageignores=freemarker.((ext.ant.FreemarkerXmlTask)|(template.DefaultObjectWrapper))
49
spec.version.base=2.23.0
49
spec.version.base=2.24.0
50
50
51
test.config.stableBTD.includes=**/*Test.class
51
test.config.stableBTD.includes=**/*Test.class
52
test.config.stableBTD.excludes=\
52
test.config.stableBTD.excludes=\
(-)libs.freemarker/nbproject/project.xml (+4 lines)
Lines 96-101 Link Here
96
                        <test/>
96
                        <test/>
97
                    </test-dependency>
97
                    </test-dependency>
98
                    <test-dependency>
98
                    <test-dependency>
99
                        <code-name-base>org.netbeans.modules.masterfs</code-name-base>
100
                        <compile-dependency/>
101
                    </test-dependency>
102
                    <test-dependency>
99
                        <code-name-base>org.netbeans.modules.nbjunit</code-name-base>
103
                        <code-name-base>org.netbeans.modules.nbjunit</code-name-base>
100
                        <recursive/>
104
                        <recursive/>
101
                        <compile-dependency/>
105
                        <compile-dependency/>
(-)libs.freemarker/src/org/netbeans/libs/freemarker/FreemarkerEngine.java (+27 lines)
Lines 40-45 Link Here
40
import java.util.Properties;
40
import java.util.Properties;
41
import java.util.Set;
41
import java.util.Set;
42
import freemarker.template.*;
42
import freemarker.template.*;
43
import java.net.URI;
43
import java.util.Collections;
44
import java.util.Collections;
44
import java.util.Map;
45
import java.util.Map;
45
import java.util.WeakHashMap;
46
import java.util.WeakHashMap;
Lines 50-55 Link Here
50
import org.openide.filesystems.FileRenameEvent;
51
import org.openide.filesystems.FileRenameEvent;
51
import org.openide.filesystems.FileUtil;
52
import org.openide.filesystems.FileUtil;
52
import org.openide.util.Exceptions;
53
import org.openide.util.Exceptions;
54
import org.openide.util.Utilities;
53
55
54
/* Taken from A. Sundararajan and adopted by Jaroslav Tulach 
56
/* Taken from A. Sundararajan and adopted by Jaroslav Tulach 
55
 * for NetBeans needs.
57
 * for NetBeans needs.
Lines 100-105 Link Here
100
    public Object eval(Reader reader, ScriptContext ctx)
102
    public Object eval(Reader reader, ScriptContext ctx)
101
                       throws ScriptException { 
103
                       throws ScriptException { 
102
        ctx.setAttribute("context", ctx, ScriptContext.ENGINE_SCOPE);
104
        ctx.setAttribute("context", ctx, ScriptContext.ENGINE_SCOPE);
105
        Bindings bindings = ctx.getBindings(ScriptContext.ENGINE_SCOPE);
106
        Object lic = bindings.get("licensePath");
107
        if (lic != null) {
108
            String url = lic.toString();
109
            if (FileUtil.getConfigFile(url) == null) { //now we have filesystem based template for sure, convert to file:///path to have freemarker process it
110
                try {
111
                    URI uri = URI.create(url);
112
                    //freemarker.cache.TemplateCache.normalizeName appears to 
113
                    // check for :// to skip processing the path
114
                    lic = new URI("file", "", uri.getPath(), null).toString();
115
                    bindings.put("licensePath", lic);
116
                } catch (Exception malformedURLException) {
117
                }
118
            } else {
119
                // now we have to assume we are dealing with the teplate from system filesystem.
120
                // in order to get through the freemarker, the path needs to "absolute" in freemarker terms - http://freemarker.sourceforge.net/docs/ref_directive_include.html
121
                // relative would mean relative to the template and we cannot be sure what the path from template to license template is..
122
                // it used to be, ../Licenses/ or ../../Licenses but can be anything similar, just based on where the template resides.
123
                bindings.put("licensePath", "/" + url);
124
                //appears to cover both the new and old default value of the include path
125
            }
126
127
        }
128
        
129
        
103
        initFreeMarkerConfiguration(ctx);
130
        initFreeMarkerConfiguration(ctx);
104
        String fileName = getFilename(ctx);
131
        String fileName = getFilename(ctx);
105
        boolean outputAsString = isStringOutputMode(ctx);
132
        boolean outputAsString = isStringOutputMode(ctx);
(-)libs.freemarker/src/org/netbeans/libs/freemarker/RsrcLoader.java (+11 lines)
Lines 35-44 Link Here
35
import freemarker.template.TemplateExceptionHandler;
35
import freemarker.template.TemplateExceptionHandler;
36
import freemarker.template.TemplateModel;
36
import freemarker.template.TemplateModel;
37
import freemarker.template.TemplateModelException;
37
import freemarker.template.TemplateModelException;
38
import java.io.File;
38
import java.io.IOException;
39
import java.io.IOException;
39
import java.io.InputStreamReader;
40
import java.io.InputStreamReader;
40
import java.io.Reader;
41
import java.io.Reader;
41
import java.io.Writer;
42
import java.io.Writer;
43
import java.net.URI;
44
import java.net.URISyntaxException;
42
import java.nio.charset.Charset;
45
import java.nio.charset.Charset;
43
import java.util.Enumeration;
46
import java.util.Enumeration;
44
import java.util.LinkedHashSet;
47
import java.util.LinkedHashSet;
Lines 53-58 Link Here
53
import org.openide.filesystems.FileStateInvalidException;
56
import org.openide.filesystems.FileStateInvalidException;
54
import org.openide.filesystems.FileUtil;
57
import org.openide.filesystems.FileUtil;
55
import org.openide.util.Exceptions;
58
import org.openide.util.Exceptions;
59
import org.openide.util.Utilities;
56
60
57
/**
61
/**
58
 *  Velocity templates resource loader rewritten for Freemarker to
62
 *  Velocity templates resource loader rewritten for Freemarker to
Lines 92-97 Link Here
92
96
93
    private FileObject getFile(String name) {
97
    private FileObject getFile(String name) {
94
       FileObject tmp = (getFolder() == null) ? null : getFolder().getFileObject(name);
98
       FileObject tmp = (getFolder() == null) ? null : getFolder().getFileObject(name);
99
       if (tmp == null) {
100
           try {
101
               tmp = FileUtil.toFileObject(FileUtil.normalizeFile(Utilities.toFile(new URI(name))));
102
           } catch (URISyntaxException ex) {
103
           } catch (IllegalArgumentException iae) {
104
           }
105
       }
95
       return tmp;
106
       return tmp;
96
    } 
107
    } 
97
108
(-)libs.freemarker/test/unit/data/licenseheader.txt (+1 lines)
Line 0 Link Here
1
TEST LICENSE
(-)libs.freemarker/test/unit/src/org/netbeans/freemarker/templates/ScriptingCreateFromTemplateTest.java (+21 lines)
Lines 34-39 Link Here
34
34
35
package org.netbeans.freemarker.templates;
35
package org.netbeans.freemarker.templates;
36
36
37
import java.io.File;
37
import java.io.IOException;
38
import java.io.IOException;
38
import java.io.OutputStream;
39
import java.io.OutputStream;
39
import java.nio.charset.Charset;
40
import java.nio.charset.Charset;
Lines 42-47 Link Here
42
import java.util.Map;
43
import java.util.Map;
43
import javax.swing.text.DefaultEditorKit;
44
import javax.swing.text.DefaultEditorKit;
44
import javax.swing.text.Document;
45
import javax.swing.text.Document;
46
import static junit.framework.Assert.assertEquals;
45
import org.netbeans.api.editor.mimelookup.MimePath;
47
import org.netbeans.api.editor.mimelookup.MimePath;
46
import org.netbeans.api.queries.FileEncodingQuery;
48
import org.netbeans.api.queries.FileEncodingQuery;
47
import org.netbeans.junit.MockServices;
49
import org.netbeans.junit.MockServices;
Lines 57-62 Link Here
57
import org.netbeans.api.editor.mimelookup.test.MockMimeLookup;
59
import org.netbeans.api.editor.mimelookup.test.MockMimeLookup;
58
import org.openide.loaders.CreateFromTemplateHandler;
60
import org.openide.loaders.CreateFromTemplateHandler;
59
import org.openide.util.SharedClassObject;
61
import org.openide.util.SharedClassObject;
62
import org.openide.util.Utilities;
60
import org.openide.util.test.MockLookup;
63
import org.openide.util.test.MockLookup;
61
64
62
/**
65
/**
Lines 141-146 Link Here
141
             */
144
             */
142
    }
145
    }
143
    
146
    
147
    public void testExternalLicenseFile() throws Exception {
148
        File license = new File(getDataDir(), "licenseheader.txt");
149
        assertTrue(license.exists());
150
        FileObject root = FileUtil.createMemoryFileSystem().getRoot();
151
        FileObject template = FileUtil.createData(root, "simple.pl");
152
        OutputStream os = template.getOutputStream();
153
        os.write("#!/usr/bin/perl\n<#include \"${licensePath}\">".getBytes());
154
        os.close();
155
        System.out.println(template.asText());
156
        template.setAttribute("template", true);
157
        template.setAttribute("javax.script.ScriptEngine", "freemarker");
158
        Map<String,Object> parameters = new HashMap<String,Object>();
159
        parameters.put("licensePath", Utilities.toURI(license).toString());
160
        FileObject inst = DataObject.find(template).createFromTemplate(DataFolder.findFolder(root), "pl", parameters).getPrimaryFile();
161
        System.out.println(inst.asText());
162
        assertTrue(inst.asText().contains("TEST LICENSE"));
163
    }
164
    
144
    //fix for this test was rolled back because of issue #120865
165
    //fix for this test was rolled back because of issue #120865
145
    public void XtestCreateFromTemplateDocumentCreated() throws Exception {
166
    public void XtestCreateFromTemplateDocumentCreated() throws Exception {
146
        FileObject root = FileUtil.createMemoryFileSystem().getRoot();
167
        FileObject root = FileUtil.createMemoryFileSystem().getRoot();
(-)maven/manifest.mf (-1 / +1 lines)
Lines 1-6 Link Here
1
Manifest-Version: 1.0
1
Manifest-Version: 1.0
2
OpenIDE-Module: org.netbeans.modules.maven/2
2
OpenIDE-Module: org.netbeans.modules.maven/2
3
OpenIDE-Module-Specification-Version: 2.70
3
OpenIDE-Module-Specification-Version: 2.71
4
OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/maven/Bundle.properties
4
OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/maven/Bundle.properties
5
OpenIDE-Module-Layer: org/netbeans/modules/maven/layer.xml
5
OpenIDE-Module-Layer: org/netbeans/modules/maven/layer.xml
6
AutoUpdate-Show-In-Client: false
6
AutoUpdate-Show-In-Client: false
(-)maven/nbproject/project.xml (-1 / +1 lines)
Lines 349-355 Link Here
349
                    <build-prerequisite/>
349
                    <build-prerequisite/>
350
                    <compile-dependency/>
350
                    <compile-dependency/>
351
                    <run-dependency>
351
                    <run-dependency>
352
                        <specification-version>7.1</specification-version>
352
                        <specification-version>7.47</specification-version>
353
                    </run-dependency>
353
                    </run-dependency>
354
                </dependency>
354
                </dependency>
355
                <dependency>
355
                <dependency>
(-)maven/src/org/netbeans/modules/maven/TemplateAttrProvider.java (-2 / +23 lines)
Lines 42-47 Link Here
42
42
43
package org.netbeans.modules.maven;
43
package org.netbeans.modules.maven;
44
44
45
import java.io.File;
46
import java.net.MalformedURLException;
47
import java.net.URI;
48
import java.net.URISyntaxException;
45
import java.nio.charset.Charset;
49
import java.nio.charset.Charset;
46
import java.util.Arrays;
50
import java.util.Arrays;
47
import java.util.Collections;
51
import java.util.Collections;
Lines 67-72 Link Here
67
import org.openide.loaders.CreateFromTemplateAttributesProvider;
71
import org.openide.loaders.CreateFromTemplateAttributesProvider;
68
import org.openide.loaders.DataFolder;
72
import org.openide.loaders.DataFolder;
69
import org.openide.loaders.DataObject;
73
import org.openide.loaders.DataObject;
74
import org.openide.util.Exceptions;
75
import org.openide.util.Utilities;
70
76
71
/**
77
/**
72
 *
78
 *
Lines 83-88 Link Here
83
    
89
    
84
    public @Override Map<String,?> attributesFor(DataObject template, DataFolder target, String name) {
90
    public @Override Map<String,?> attributesFor(DataObject template, DataFolder target, String name) {
85
        Map<String,Object> values = new TreeMap<String,Object>();
91
        Map<String,Object> values = new TreeMap<String,Object>();
92
        String licensePath = project.getLookup().lookup(AuxiliaryProperties.class).get(Constants.HINT_LICENSE_PATH, true); //NOI18N
93
        if (licensePath != null) {
94
            File path = FileUtil.normalizeFile(new File(licensePath));
95
            if (path.exists() && path.isAbsolute()) { //is this necessary? should prevent failed license header inclusion
96
                URI uri = Utilities.toURI(path);
97
                licensePath = uri.toString();
98
            }
99
        }
86
        String license = project.getLookup().lookup(AuxiliaryProperties.class).get(Constants.HINT_LICENSE, true); //NOI18N
100
        String license = project.getLookup().lookup(AuxiliaryProperties.class).get(Constants.HINT_LICENSE, true); //NOI18N
87
        MavenProject mp = project.getLookup().lookup(NbMavenProject.class).getMavenProject();
101
        MavenProject mp = project.getLookup().lookup(NbMavenProject.class).getMavenProject();
88
        if (license == null) {
102
        if (license == null) {
Lines 142-149 Link Here
142
            }
156
            }
143
        }
157
        }
144
158
145
        if (values.size() > 0) {
159
        if (!values.isEmpty() || licensePath != null) {
146
            return Collections.singletonMap("project", values); // NOI18N
160
            HashMap<String,Object> toRet = new HashMap<String,Object>();
161
            if (!values.isEmpty()) {
162
                toRet.put("project", values);
163
            }
164
            if (licensePath != null) {
165
                toRet.put("licensePath", licensePath);
166
            }
167
            return toRet;
147
        } else {
168
        } else {
148
            return null;
169
            return null;
149
        }
170
        }
(-)maven/src/org/netbeans/modules/maven/api/Constants.java (+5 lines)
Lines 58-63 Link Here
58
    public static final String HINT_LICENSE = "netbeans.hint.license"; //NOI18N
58
    public static final String HINT_LICENSE = "netbeans.hint.license"; //NOI18N
59
59
60
    /**
60
    /**
61
     * Maven property that hints netbeans to use a given license template file in project space, rather than the IDE's user space
62
     */ 
63
    public static final String HINT_LICENSE_PATH = "netbeans.hint.licensePath"; //NOI18N
64
65
    /**
61
     * Maven property that designates the jdk platform to use in the IDE on classpath for project.
66
     * Maven property that designates the jdk platform to use in the IDE on classpath for project.
62
     * Equivalent to the "platform.active" property in Ant based projects.
67
     * Equivalent to the "platform.active" property in Ant based projects.
63
     * Workaround for issue http://www.netbeans.org/issues/show_bug.cgi?id=104974
68
     * Workaround for issue http://www.netbeans.org/issues/show_bug.cgi?id=104974
(-)openide.loaders/manifest.mf (-1 / +1 lines)
Lines 1-6 Link Here
1
Manifest-Version: 1.0
1
Manifest-Version: 1.0
2
OpenIDE-Module: org.openide.loaders
2
OpenIDE-Module: org.openide.loaders
3
OpenIDE-Module-Specification-Version: 7.46
3
OpenIDE-Module-Specification-Version: 7.47
4
OpenIDE-Module-Localizing-Bundle: org/openide/loaders/Bundle.properties
4
OpenIDE-Module-Localizing-Bundle: org/openide/loaders/Bundle.properties
5
OpenIDE-Module-Provides: org.netbeans.modules.templates.v1_0
5
OpenIDE-Module-Provides: org.netbeans.modules.templates.v1_0
6
OpenIDE-Module-Layer: org/netbeans/modules/openide/loaders/layer.xml
6
OpenIDE-Module-Layer: org/netbeans/modules/openide/loaders/layer.xml
(-)openide.loaders/src/org/openide/loaders/DataObject.java (+13 lines)
Lines 1509-1514 Link Here
1509
            if (!all.containsKey("dateTime")) { // NOI18N
1509
            if (!all.containsKey("dateTime")) { // NOI18N
1510
                all.put("dateTime", d); // NOI18N
1510
                all.put("dateTime", d); // NOI18N
1511
            }
1511
            }
1512
            if (!all.containsKey("licensePath")) {
1513
                String licenseName = "default";
1514
                Object prj = all.get("project");
1515
                if (prj != null && prj instanceof Map) {
1516
                    Map prjMap = (Map)prj;
1517
                    Object licenseNameO = prjMap.get("license");
1518
                    if (licenseNameO != null) {
1519
                        licenseName = licenseNameO.toString();
1520
                    }
1521
                } 
1522
                //if licensePath not filled, use this path relative to FileUtil.getConfigRoot()
1523
                all.put("licensePath", "Templates/Licenses/license-" + licenseName + ".txt");
1524
            }
1512
            
1525
            
1513
            return Collections.unmodifiableMap(all);
1526
            return Collections.unmodifiableMap(all);
1514
        }
1527
        }

Return to bug 193981