Feeds:
Posts
Comments

Archive for the ‘Tips’ Category

I use Maven Bundle plugin a lot since our projects are OSGi based. Basic idea I had of this plugin is that this plugin makes an OSGi bundle out of a normal jar (basically by augmenting the META-INF file) if we do declare exported and private package information correctly in it’s configuration section in the POM declaration. Normal procedure followed would be to copy the configuration from an existing POM and tweaking it according to the current project requirements. My knowledge about it was just about it until recently. It was when I bumped up on a strange issue one day I was forced to read more on the subject and fortunately solution was not that far away with the amount of comprehensive documentation and FAQ section found at plugin’s site [1].

So why am I making a blog out of this if all what you want to know is well documented somewhere else?

Well, mostly to document some points which do matter, in a concise point form as a future self reference rather than going through the lengthy documentation every time when my memory fails me. (Not a rare occurance I would say.. :)).

So here goes.. My points with bullets.. :).

  • <Export-Package> will copy the packages to the bundle and export them in the MANIFEST while <Private-Package> will copy the packages to the bundle even-though they will not be exported.
  •  If you want a class to be included in the bundle make sure the package that it lives in is present in either of these instructions or otherwise it will not get included in the bundle.
  •  If <Export-Package> and <Private-Package> overlaps <Export-Package> takes precedence.
  • Using negation “!” in <Export-Package> declaration will result in package being not included bundle and not exported as well.
  • If a negation following an non-negated package declaration overlaps with the non-negated package declaration, the negated package pattern will not take effect. Always put negations first in  <Export-Package> instruction to avoid these kind of issues.
  •  Plugin generates the Import-Package bundle manifest header based on the Java imports present in the classes of the bundle so generally it’s not needed to specify it explicitly.
  • If a referenced packages do not need to be available for at runtime for bundle to perform its intended task (e.g: only a test scoped class using the package which is only needed during test runs..) use negation inside not to import it.
  • If you need to import a package not referenced by any class in bundle use resolution:=optional directive after the package name as follows.

org.external.package;resolution:=optional

   The bundle would resolve even if the package is not present at runtime.

  • Use to import a dynamically loaded class (e.g: Using Class.forName()) given that it’s exported in originating bundle. Generally using “*” wild-card would do, since it will enable loading any dynamically loaded class in other bundles given that the package it lives in has been exported by those bundles.

So that’s about it for my notes. If you want a good tutorial have a look at [2] as well. By the way in case you are wondering about the issue I had, the second point sums it up pretty nice. :).

[1] http://felix.apache.org/site/apache-felix-maven-bundle-plugin-bnd.html

[2] http://wso2.org/library/tutorials/develop-osgi-bundles-using-maven-bundle-plugin

Read Full Post »

Working with svn externals

Viewing current svn externals recursively.

  • svn propget svn:externals -R

Add a svn external

Note that conf folder should not already present in the svn. Also note the current working directory notation ‘.’ at the end. This will create a conf folder which is an svn external in current directory.

Removing a svn external

  1. svn propedit svn:externals
  2. Remove the external property definition in pop up editor and save.
  3. Commit the change.

Read Full Post »

Some Common SVN Issues

Problem : svn: warning: Working copy ‘xxx’ locked

Solution : Run a svn cleanup. If that fails..
1. Get a svn diff of local modifications to a patch.
svn diff > patch.diff
2. Delete folder containing locked resource path from the file system. Do not use svn delete.
rm <folder-containing-locked-resource>
3. Run a svn update
svn up
4. Apply local modifications to working copy.
patch -p0 -i patch.diff

Problem : svn: warning: ‘xxx’ is already a working copy for a different URL after adding a svn:external

Solution : In this case you might have done a mistake in setting the external. An external property to download an already existing folder will  cause this error. If this is the case..
1. Remove the svn external
* svn propedit svn:externals
* Remove external definition in the editor and save it.
* Do a svn update
svn up
* Now commit
svn ci

2. Delete folder from svn and file system
svn delete
rm -rf <folder-having-svn-external>
3. Set new external. This time without the folder. For example.
svn propset svn:externals ‘conf http://sample.org/trunk&#8217; .
This time since there is no existing ‘conf ‘ folder it will not conflict with the external.

Read Full Post »

Read Full Post »

Passing parameters for BASH alias

I find it annoying to type routine long commands at shell, specially during my development work. But some of the commands requires custom parameters to be entered according to the software I am building. So I wanted to find a way to pass parameters to aliases that I will be defining. Here is what I found by searching through Google which worked for me.

m () { command $1; }

alias a= m

So at BASH when I enter

$ a test

“command test” will be executed.

Here is one such maven build command I have defined.

fb () { mvn clean install -Dproduct=$1; }

alias bp=fb

$ bp bam

will get executed as

$ mvn clean install -Dproduct=bam

Read Full Post »

Removing cached SVN credentials

This post describes how cached SVN credentials can be removed. Credentials are stored in SVN auth disk area. They have to be removed in order to remove cached SVN credentials.

$ ls ~/.subversion/auth/svn.simple/
5671adf2865e267db74f09ba6f872c28
3893ed123b39500bca8a0b382839198e
5c3c22968347b390f349ff340196ed39

These files hold the credentials for a certain domain. If you take a look inside a file the domain is listed under svn:realmstring key. Delete the corresponding cache file  to remove the credential for the relevant domain.

K 8
username
V 3
joe
K 8
password
V 4
blah
K 15
svn:realmstring
V 45
<https://svn.domain.com:443>
END

Read Full Post »

SVN Tree Conflicts

Have you ever encountered this during a SVN update?

Summary of conflicts:
  Tree conflicts: 1

If so what you have at your hand is a conflict which has occurred due to conflicting file structure changes like file moves and deletions. You can force the removal of unwanted file with this command,

svn remove --force file-to-be-removed

Then conflict can be resolved using,

svn resolve --accept=working file-to-be-removed

Read Full Post »

« Newer Posts - Older Posts »