How to set project license header in a NetBeans Module? - netbeans

Using NetBeans 8.1, how can I set a project license header for a NetBeans module? Specifically, I would like every new Java file I create to be populated with my license header.
I know how to achieve this for a regular NetBeans Java project. I specify the text I would like under the License Headers section of the project properties.
However, when I try to set the license header of a NetBeans Module project, there is no License Headers section in the module's project properties.
I would like to set this license at a project level as opposed to at a NetBeans level, because I would like my whole team to get the new template for any files they create. (I know I can change this for the NetBeans overall by going to Tools -> Template Manager and customizing it there. However, then my other team members won't get the header.)
I saw a similar question, but this was for a Maven project instead of a NetBeans module project.

Solution for NetBeans 8.2. (Likely works in 8.1, as 8.2 produces the error message described by OP.)
Create a text file with your license template text:
<#if licenseFirst??>
${licenseFirst}
${licensePrefix}Copyright 2017 Whoever you are
<#if licenseLast??>
${licenseLast}
2. Add the template to NetBeans
In the IDE, do Tools->Templates and open the Licenses node. Here you see the list of global license header templates. Press Add... then browse to and select your template file from step 1.
A new entry will appear under Licenses named 'license-XXX.txt' where XXX is your license file name -- all of it, so if you named your file 'license.txt' the new entry will be named 'license-license.txt.txt'. (Don't panic, you can rename it.)
I called mine FooLicense.
Set the license in your project.
Add the line
project.license=FooLicense
to nbproject/project.properties
Now when you create a new source, if will include the the specified license header.
Bonus! The setting is inherited from the suite project.
Setting the license in the suite project properties will apply the setting to all modules in the suite.
Setting the license in module projects overrides the suite license setting.

In theory, you can manually set a custom license file for your module project by adding this property to nbproject/project.properties.
project.licensePath=./nbproject/licenseheader.txt
Then create the new license template and save it to nbproject/licenseheader.txt.
Unfortunately, this seems to be broken in NetBeans 8.1. When I create new files, I get this error message instead of the custom license text: "Error reading included file Templates/Classes/C:\some\path\module1\Templates\Classes\licenseheader.txt"
Using one of the built-in license templates does work. To use the MIT license for example, add this property instead to nbproject/project.properties.
project.license=mit

Related

Enabling Java User Function Library in Crystal Reports 2020 Designer

Is there a way to enable and use Java UFL in Crystal Reports 2020 Designer?
In the designer itself you can choose to use only Java User Function Libraries in File > Options > Formula Editor > "UFL Support" dropdown menu.
I was able to code my own functions in Eclipse, building a jar of the library, but the problem is;
Where do I specify the location and name of the library to the designer?
This topic User Function Libraries in formulas (and many others) refers to a "Java Reporting Component Developer's Guide" to make Java UFL work, but I have not found it anywhere!
I also tried to add the jar under C:\Program Files (x86)\SAP BusinessObjects\java\lib and in similar folders, but had no success.
Any help will be appreciated
Thanks,
Enrico
Tried to find documentation, tried to locate jar file of the library under the designer installation path

When debugging my Eclipse plugin, the repository version of the Java file is chosen over my local version

I'm in the early stages of creating a new Eclipse plug-in in Eclipse 2019-06. I created the plug-in using the "Hello World" wizard option and created a debug configuration that successfully launches a secondary workbench for testing. I can click on my new menu option and step into my new code.
I want to use a modified version of org.eclipse.jdt.junit.wizards.NewTestCaseWizardPageOne, so I added the package to my project and edited NewTestCaseWizardPageOne. However, when I try to debug, the debugger asks for a source location. It seems to want to load the file from the local repository (.p2/pool/plugins/org.eclipse.jdt.junit_3.11.400.v20190510-0840.jar), rather than my edited version. Why is that?
There must be some kind of classpath problem, but don't versions of files in the project have precedence over those in the dependent plugins? I've looked at a number of similar questions (1, 2) and other sources, but I haven't yet found the answer. Please help.
Following Alexander Federov's suggestion, I converted my plugin into a fragment. This was fairly easy to do following the advice from this StackOverflow page. The main changes were:
Renamed plugin.xml to fragment.xml and changed the top level xml
element from plugin to fragment.
Added a Fragment-Host entry to MANIFEST.MF
The key advantage that this provided is discussed in an Eclipse Wiki
page:
... a fragment appears much the
same as a normal plug-in. A fragment can specify libraries,
extensions, and other files. When it is loaded by the platform loader,
a fragment is logically, but not physically, merged into the host
plug-in. The end result is exactly the same as if the fragment's
manifest were copied into the plug-in manifest, and all the files in
the fragment directory appear as if they were located in the plug-in's
install directory. Thus, a runtime library supplied by a fragment
appears on the classpath of its host plug-in. In fact, a Java class in
a fragment can be in the same package as a class in the host and will
even have access to package-visible methods on the host's classes.
The last part having to do with access to package-visible methods was what I needed. Thanks, Alexander!

Bundle eclipse.ini with product in deployable feature?

I am exporting a deployable feature which bundles a product plugin. Within this product plugin, I have created a customized welcome page and a splashscreen. Now I want that after installation of the exported deployable feature, the eclipse.ini file will be changed in order to pass my own product plugin to the argument -product and -showsplash. Currently, users need to make these changes manually after installation of the feature. Is there a better way, for example to bundle the modified eclipse.ini with the product?
In your feature's build.properties file, you can have it include arbitrary files with a line like this:
root.win32.win32.x86=absolute:file:eclipse.ini
Information on what can be included in the build.properties file can be found here.
Eclipse ini is normally created during build or installation. The content can be given inside the ProductConfiguration Editor - Launching. You can specify your parameters there and they will be entered into your build generated p2 product. When the product is installed the parameter will be added to the eclipse.ini file.

Eclipse Juno: Unable to read model extension

After exporting the product, when i try to run the application i do not see any view in my application.i got the reason, this is because of error "Unable to read model extension"
Does your product work fine when launched from within the Eclipse IDE? Only the exported product generates the error? Then check if the exported product indeed includes all the required files. For example, does it include the plugin.xml, Application.e4xmi, ...?
When launched from within the IDE, all source code files are available to the running product. When exported, however, only files specifically listed in the build.properties file of each plugin will part of the exported product. If for example the model files (*.e4xmi) are not listed in the build.properties file, your exported product will not be able to load the model.

How can I modify the .buildpath file in my Eclipse plugin?

I have written a plugin that uses PDT (and thus DLTK) to create a customized project. I now to need to add libraries to the buildpath of my custom project.
I do have a plugin that contains these libraries and I've been struggling trying to figure out how to create / modify the .buildpath file. I was not successful trying to use BuildpathEntry, as it seemed to fail because the path I provided to .buildpath did not contain a device id.
I'm not sure where to go from here.
EDIT: I'm trying to add PHP libraries to the .buildpath file of my PDT project in my custom plugin, just to be clear ;)
You could do this with the addEntriesToBuildPath method of org.eclipse.php.internal.core.buildpath.BuildPathUtils.
Add org.eclipse.php.core and org.eclipse.dltk.core to the dependencies of your plugin.xml. (you have need installed PDT SDK)
Add the build path entry when create the project:
IScriptProject scriptProject = DLTKCore.create(project);
List<IBuildpathEntry> bentries = new ArrayList<IBuildpathEntry>();
IBuildpathEntry juliaServerEntry = DLTKCore.newProjectEntry(new Path("/otherproject"));
bentries.add(juliaServerEntry);
BuildPathUtils.addEntriesToBuildPath(scriptProject, bentries);