How to copy resources to bin folder - eclipse-rcp

I'm trying to create a Plug-in project that reads a text file from a folder called "resources" of the same project.
From what I understood is that I need to add this folder to the build.properties like this:
source.. = src/
output.. = bin/
bin.includes = META-INF/,\
.,\
resources/
However, after compiling my bin folder does not include the resources folder nor any of its files.
Is there any obvious mistake?

The final plug-in does not normally have a bin folder.
The bin.includes specifies which folders are copied in to the final plug-in. So your setting will give you a resources folder in the plug-in.
Use the FileLocator class to find resources in a plug-in.

Related

Add xml file to Eclipse Plugin

I have a file model.xml i want to add to my eclipse plugin to read at runtime.
I tried adding it to the manifest.mf binary build and source build and adding it to the build.properties bin.includes but when I look in the bin folder there are only .class files.
Surely plugins can contain resources and not just .class files right?
You just list the file in the bin.includes in the build.properties - you should be able to do that in plugin.xml/MANIFEST.MF/build.properties editor.
For example in one of my plugins the build.properties is:
output.. = bin/
bin.includes = META-INF/,\
.,\
OSGI-INF/,\
plugin.xml,\
fragment.e4xmi
source.. = src/
Which includes a plugin.xml and a fragment.e4xmi file.
Note: These are not copied to the bin directory in your project. When you test your plugin they will be accessed directly in the project. When you build/export your plug-in they will be included in the plugin jar.
You use the FileLocator API to access these files - that understands where to look.
For example, to access the fragment.e4xmi shown above:
Bundle bundle = FrameworkUtil.getBundle(getClass());
// or some other way to get the current bundle
URL url = FileLocator.find(bundle, new Path("fragment.e4xmi"));

How to properly compile source to output into a library and com/ directory?

I'm trying to create a plugin that compiles source into a jar as well as the com/ directory.
My build.properties contains:
bin.includes = META-INF/,\
plugin.properties,\
.
jars.compile.order = myDir/myJar.jar
source.myDir/myJar.jar = src/
output.myDir/myJar.jar = bin/
source.. = src/
And the manifest contains:
Bundle-ClassPath: myDir/myJar.jar, .
It seems to output as expected. But I'm not 100% sure this is right since I get a warning stating: The folders 'src/' share the same output folder but are targeted for different libraries in the build.properties.

Eclipse build.properties Warning: The plug-in's classpath library '.' does not have a corresponding source build entry

For the build.properties file in Eclipse I get the warning
The plug-in's classpath library '.' does not have a corresponding source build entry
The build.properties file has the following content:
bin.includes = .settings/,\
META-INF/,\
.,\
Processes/,\
Resources/,\
Schemas/,\
Service Descriptors/,\
.WebResources/,\
pom.xml,\
target/
What am I missing here?
The . entry in the bin.includes is the entry for the plugn's main source code. The build needs to know where to look for that source code. For a plugin using a src directory for the source you need
source.. = src/
in the build.properties to provide that information.
You might also need
output.. = bin/
to say where the output classes are located.

Implementing a directory structure in Grunt

I am working on a project using coffeescript and want to have a directory structure like:
project/
Gruntfile
common/
*.coffee
*.spec.coffee
*.scaffold.coffee
bin/
test/
server/
*.coffee
*.spec.coffee
*.scaffold.coffee
bin/
test/
client/
*.html
*.css
*.coffee
*.spec.coffee
*.scaffold.coffee
bin/
test/
Where coffee files get compiled to bin, spec.coffee and scaffold.coffee get compiled to test. There are directories containing static files that are not shown.
Is there an easy/standard way to do this?
this is a general question so the general answer is: yes, most grunt plugins have easy ways to configure each task, identify source files and where the output gets generated.
take a look at the documentation for grunt-contrib-coffee, shows lots of examples of how to config directories to process coffee files including options to flatten sub-directories, etc.
https://github.com/gruntjs/grunt-contrib-coffee

Copy sources files into target directory with SBT

I recently decided to use SBT to build an existing project.
In this project I have some .glsl files within the scala packages which I need to copy during the compilation phase.
The project is structured like this :
- myapp.opengl
- Shader.scala
- myapp.opengl.shaders
- vertex_shader.glsl
- fragment_shader.glsl
Is this file structure correct for SBT or do I need to put the .glsl files into an other directory. And do you know a clean way to copy these files into the target folder ?
I would prefer not putting these files into the resources directory since they are (non-compiled) sources files
Thanks
I would not recommend putting those files into src/main/scala as they do not belong there. If you want to keep them separate from your resource files, you can put them in a custom path, e.g. src/main/glsl and add the following lines to your project definition to have them copied into output directory:
val shaderSourcePath = "src"/"main"/"glsl"
// use shaderSourcePath as root path, so directory structure is
// correctly preserved (relative to the source path)
def shaderSources = (shaderSourcePath ##) ** "*.glsl"
override def mainResources = super.mainResources +++ shaderSources