How to create an osgi fragment with Bnd? - eclipse

Today I had a deeper look inside the bndTools for Eclipse. I had a good start, but I ask myself if it is possible to create osgi fragments with bndTools or bnd. From the bnd project description it tells me that the Fragment-Host header is ignored by bnd, but have not found out what this means.
Does someone know if creating a osgi fragment is possible with bnd, and if so how to do that?
Regards Markus

A fragment bundle is special in only two ways:
it cannot be started, so it should not contain a Bundle-Activator header, and
it needs to contain a Fragment-Host header with the symbolic name of the host you want to attach to.
Other than that, it's a bundle like any other, so bnd does not need to handle this in any special way. bnd by default 'ignores' all headers it doesn't recognize, in which case it copies them verbatim to the resulting bundle's manifest.
In Bndtools, you can add custom headers (i.e., those not directly supported by Bndtools) in the Source tab.

bnd does exactly what it says. It ignores any Fragment-Host lines that you add and transparently copies them to the output bundle as opposed to processing those lines. Just add the Fragment-Host lines you need.

Related

Can we overlay the file to our custom path

Can we overlay the file to our custom path or we have to overlay the file to exact folder structure location as in libs?
For example, I want to overlay the constants.js (/libs/cq/ui/widgets/source/constants.js) file, in this adobe recommended Copy this file to /apps/cq/ui/widgets/source/constants.js for overlaying, but in my project that folder structure is not there, so I have copied to the custom path in apps folder and tested the changes and overlaying is working fine.
The file needs to have the same path as the one in libs except for replacing 'libs' with 'apps'. It does not work with custom paths*. If the project does not already have the structure, you can always create it. Don't forget to update the META-INF/Vault/filter.xml file to register the new path with projects package definition.
*Technically you can change the configs to add new searchpaths. But do remember that you might have to share the AEM instance with different tenants and sticking to the usual conventions goes a long way in having a predictable setup. I honestly don't see a reason to do this, it is already an acceptable practice to overlay under '/apps'. The filters on package provide enough flexibility to get along with other tenants while modifying similar areas.
I think you want to create the overlay in your custom project under /apps. If my assumption is correct, then you can certainly do it.
Taking your example in consideration, /libs/cq/ui/widgets/source/constants.js can be overlayed to /apps/<your-project>/cq/ui/widgets/source/constants.js by adding an entry in the Apache Sling Resource Resolver Factory configuration.
See this answer for the detailed steps. I hope this helps.

Attaching javadoc to libraries

as an example, I'd like to attach the javadoc to org.eclipse.swt
As I've read in similar threads, I went to the build path, expanded the swt library node and tried to enter the url as the javadoc location:
http://help.eclipse.org/indigo/advanced/content.jsp?topic=/org.eclipse.platform.doc.isv/reference/api/index.html
Trying to validate it however tells me that typical root files like package-list or index.html couldn't be found. Obviously pretty weird since the url ends with index.html. Am I doing something wrong?
You can only specify the URL for the javadocs if it has a package-list file. Otherwise you will have to use downloaded javadocs/src for the jar. Then you can do specify the location for those javadocs archives in the same window you tried. You can attached sources if you want to see the source instead of decompiled library classes.
Similar post
Do not include the index.html part at the end. You want a URL to which you can append "package-list" and actually get the right content.

including a header from a project into a static library

I have a subproject (static library) inside my project.
As this static library may be used by a bunch of app, I have this config.h file on my project that contains the app configuration. The static library must read it.
The problem is that adding
#import "config.h"
on the static library fails, because the file cannot be found.
I could add an absolute path to my project root on the search headers, but I want to make this not hard coded because this static library will be used by other projects. Another problem is that I cannot use relative links like ../.., for example, because the static library is on another volume.
Including $(SRCROOT) on the search paths of the static library will give me the root for that library not for the project using it, that is what I want.
How do I solve that?
Just pay attention to my question. I am inside a static library that is used by a project. Config.h is out there in the project. I want to import that config.h on my static library.
If there is an easy way to do that, please tell me.
I have uploaded a sample project to here and here, so you can see my pain.
thanks
One way, somewhat of a hack, is to add a Run Script to each App's Build Phase, as the first item, and have it copy Config.h to some known place - /tmp/Config.h, and your included library will look for it there. Since the file is copied on every build, it will always be proper.
EDIT1: So not pretty, but you can add a Run Build Script to just under the Dependencies in the library. Just add one and leave the checkbox set to show environmental variables. You can see this one set:
FILE_LIST=/Volumes/Data/Users/dhoerl/Library/Developer/Xcode/DerivedData/MyProject-fdzaatzqtmrnzubseakedvxmsgul/Build/Intermediates/MyStaticLibrary.build/Debug-iphoneos/MyStaticLibrary.build/Objects/LinkFileList
What you can see is that several of these have as the prefix the current project folder:
/Volumes/Data/Users/dhoerl/Library/Developer/Xcode/DerivedData/MyProject-
You can write some script there to get the prefix, then append the local Config.h file path, and now you have a fully qualified path to the Config.h header, which you can then copy to a known location in the library. I'm going to post on the xcode forum as there may be a better solution - there use to be in Xcode 3. I'll update this if I get anything substantive back.
EDIT2: Try This:
1) Click on the library, click on Build Phases, add a Run Script Build phase by tapping bottom right '+' button
2) Drag it so its the second item in the list (below Target Dependencies)
3) Change the Shell to "/bin/ksh"
4) Paste this in, after editing it to have the proper files/paths:
# Get the Project Name (assumes upper/lower/numbers only in name)
PROJ=$(echo $BUILD_DIR | sed -En -e 's/(\/.*\/)([A-Za-z0-9]+)-([a-z]+\/Build\/Products)/\2/p')
# Use this variable to construct a full path
FULL_PATH="/Volumes/Data/Users/dhoerl/Downloads/nightmare/"$PROJ"/"$PROJ"/HelloWorldLayer.h"
echo FULL_PATH equals $FULL_PATH
# Make Sure MyStaticLibrary is correct
echo PROJ_DIR equals "$PROJECT_DIR/MyStaticLibrary"
cp -f "$FULL_PATH" "$PROJECT_DIR/MyStaticLibrary"
5) This assumes that you put the library anywhere you want, but each App project has to havethe same parent folder (not much of a restriction - what I did in the past).
PS: When I do this kind of thing, I usually don't include an actual file of the app, but create a header for a class that is not instantiated in the library. Lets call this Foo. So in your library, you have Foo.h, and it has lots of methods that return info - the number of widgets, the location of some special folder, plists, arrays, dictionaries, whatever. The idea is the library knows how to get whatever it needs through this interface (class singleton, or just a class with class methods. YMMV.
PSS: anyone else reading this, it pays to create demo projects.
I'd go a different route. Make this config.h file part of the static library using compiler symbols in it to switch features. Then in your projects define those symbols depending on what features you need.

Eclipse Indigo JSP validator not fully supporting JSP based tags in a jar file

If I package my JSP based tag in a jar file Indigo seems to correctly pick up and validate the URI and tag name.
However it doesn't seem to properly recognize any attributes on the tag. The parser gives me a warning and indicates "undefined attribute name".
However if I take the exact same tag and place it inside the same project (in a differently named tag dir) it is properly parsed by the validator -- indicating that the attribute is required.
In both cases the tags deploy and run properly in the container.
Obviously, this works, but the validator support is a nice feature of WTP that I'd hate to lose for a reusable taglib.
I don't think you can add any extra metadata into the TLD file for a JSP based tag.
Any suggestions?
I suppose as a last resort I could write these in Java.
Sounds like it's possibly http://bugs.eclipse.org/353629 . Does SR1 help?

Gsoap undefined references

I'm trying to use and web service with gsoap. I've already generated all *.h and *.cpp using wsdl2h and soapcpp2, included all libraries, at least I think so, but when I build the project it gives me the message of undefined references to a lot of methods. The thing is all methods are declared in soapH.h (the prototype) and in soapC.cpp (the implementation).
Any help will be appreciated.
It seems that you included some generated header files in your build, which should not. (e.g. the .h file generated from wsdl) There are descriptions in the comment section in each generated files, and you'd better read them to get familiar how to use them.
Also, if you use openssl, the library should also be included during linking process(-lssl)
Solved, All I need was the original header file, I was getting one from the wsdl.
In case anyone encounteres this problem: you do not have to include all the .cpp files in your makefile - some of them are included by the other. What you need also depends on whether you are building a client or a server.
Consult the documentation here to see which files are needed and for what.