Adding data files to SBT project - scala

I would like to add a data file or a configuration file along with my application (such as sample.conf). This file should be available to user so that he/she can edit the sample configuration to further customize the application.
How can I add such files to my project such that
This file becomes part of distributable, and
How can I link it in my source documentation, so that its purpose can be doucmented, and
This is file is goes into a special directory (such as conf)
Or is there any such predefined task available.

SBT Native Packager provides support for doing what you want, though you'll have to dig through the docs a bit. The universal packager is probably the best approach for you.
http://www.scala-sbt.org/sbt-native-packager/

I think what you're looking for is the typesafehub/config https://github.com/typesafehub/config project. It uses the HOCON format (Human Optimized Config Object Notation).

Related

Read an ".sbt like" file for highly customizable configurations in Scala

I'd like to write a simple app to crawl/scrape some web content. The more I delve into the analysis, the more I realize that the instructions I need to give to the app in order to navigate through the site and get the content I wish it to extract, may be very peculiar depending on the target website structure.
The idea was to write some configuration files to define how the app should browse and scrape each specific site, but defining such behaviour could be challenging, unless you write in the configuration file some actual Scala code.
So, the idea is to write some code able to get a scraper object instance reading a file written in the .sbt format and inject some code in it.
First of all, I need to know where to start to achieve such task: what library should I use?
Could it be easier to write some sbt tasks and use sbt as the core of the app instead of writing one from scratch? What should be the limitations in this approach?
I apologize for being so general, but I don't have the slightest idea from where to start. I'd like you to head me to the right direction and post some docs to read.
Consider the app is meant to be a CLI tool, no graphical interface needed, then.

Importing source files and folders into IAR Workbench

I have a cup of source files in a certain folder structure in my file system. I want to use this structure for a project in the IAR Workbench. Thinking of Eclipse, that could be so easy! But in the IAR Workbench, the folders will become to "Groups", which are only kind of virtual folders. The Workbench doesn't care about folders.
Is there some easy and fast way to import them?
Up to now I have to add the groups manually each and then add the files to the groups, and that's really annoying!
Is there maybe a tool to generate a proper project file (*.ewp) out of a file/folder structure path?
This would help me a lot!
You should have a look at IAR Project/Add Project Connection command.
Although IAR doesn't seem to have any public documentation on the xml syntax, or at least I couldn't find any, you can find Infineon DAVE (Config.xml) and Freescale PE (ProjectInfo.xml) files if you search around. These can be used as examples to figure out the syntax on how to write your own xml files in one of these interfaces, to allow you to specify where all your c, h, assembly and library files are from where ever they may be in your file system. They also allow you to define preprocessor includes for compiler/assembler, and DAVE allows you to define a path variable, which is also very useful.
See: https://mcuoneclipse.com/2013/11/01/iar-arm-v6-7-comes-with-improved-processor-expert-support/
I have modified a DAVE Config.xml file and found it EXTREMELY useful for managing and migrating even just a handful of project files. For example to upgrade to a new release with all files having a new directory root, you just change a single line in the xml file (defining the new root), and all source files, compiler includes etc are all updated to the new level. No more manually editing the preprocessor includes or replacing all the files in the project. And no more fiddling around with ../../ file system hierarchy navigation stuff, you just specify directly (or indirectly via a path to) where the files are, no more relative from where your project happens to be. VERY NICE.
IAR should consider opening this up (documenting) for general users, as it is very useful for project management and migration. While at it they should also consider generalizing the xml syntax a little bit and allow for definition of IAR group heading names, specifying linker file name, and definitely allowing multiple xml files to be included (connected) (so that subprojects can be easily added or removed without effecting the other subproject definition files) and a few basic things like that.
If they where to do a bang up job on this, they might consider allowing most/all aspects of IAR project configuration that might be required by the subproject, to be defined in these xml files, and then entire (sub)projects could just be plopped down anywhere and be up an running extremely quickly (OK, just let me dream a bit :)
For anyone who happens upon this you may want to check out https://github.com/IARSystems/project-migration-tools. They have a tool for pulling in file trees here.

Auto upload files in included path using Netbeans

I have a NetBeans javascript project with several included paths for plugins. I do not want to include the plugins in my core repository, so I have created separate, external folders for each and am including them via an include path. Because I test across many devices, I need my changes to upload on save and this works fine for the main code base, however, I would like to be able to edit a plugin via the include path and see those changes auto uploaded as well. Is this possible?
As of right now, the only alternative I see is to create separate projects for each plugin, which I am willing to do if this is the only option. The single project workflow is very preferable to me and I might be willing to switch IDE's if this is possible in another environment.
I would be happy to elaborate if my intentions are unclear.
I don't think it's possible. What about creating one single "umbrella" project for all plugins and simply manage it the same way you do the main project?
Personal note: What you have is basically several projects and the uploading is focused always on single project. So what you want is like "I want to treat them as projects but not to at the same time" :) Btw, how do you edit a plugin? I guess open it as a project in NetBeans or use some text editor. So again you basically treat it as a project.

Enterprise library Validation block

I have a web application project. I want to add Configuration Source and keep Validation block, Caching and Logging config files separate. But as soon as I go to the UI of enterprise Lib and add a configuration Source, it combines everything in a single file. Is there a way to separate all these ?.
Yes you can separate the configuration files. This article gives some directions.

Loading external .bundles on iPhone

I would like to add resource files to a .bundle and push them to my application and it seems to work fine in the simulator but fails to build when I change to the device.
/Users/sosborn/Projects/MyPro/build/Debug-iphoneos/FooBar.bundle:
object file format invalid or
unsuitable
I don't want to load any code or anything, just plain text and jpegs and it would be nice to be able to package them as dependencies.
iPhones and iPod touchs do not have support for loading external modules (neither bundles nor dylibs). If you need to share object code between projects, you can use static libraries
Instead of trying to load it like an NSBundle, just reference the resources therein by path.
You could pretty easily create your own class that did something similar to the non-code stuff in NSBundle to help out, as there really isn't much logic in there.
I found a better solution to my problem. It actually doesn't require the use of bundles at all. I just created an aggregate target instead of a bundle target. Then I added a copy step and a script step. The copy step contains all of the resources I had in the bundle target and the script step actually zips up the files. Then when I download the content into my application I can just unzip it and use it just as if it were a bundle since I'm just storing resource dependencies.
Thanks for your help.