You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by mc...@apache.org on 2011/10/11 19:01:19 UTC
svn commit: r1181889 -
/felix/trunk/bundleplugin/src/main/java/org/apache/felix/obrplugin/ObrIndex.java
Author: mcculls
Date: Tue Oct 11 17:01:19 2011
New Revision: 1181889
URL: http://svn.apache.org/viewvc?rev=1181889&view=rev
Log:
FELIX-3092: add relative path (%rp) parameter to the index goal
Modified:
felix/trunk/bundleplugin/src/main/java/org/apache/felix/obrplugin/ObrIndex.java
Modified: felix/trunk/bundleplugin/src/main/java/org/apache/felix/obrplugin/ObrIndex.java
URL: http://svn.apache.org/viewvc/felix/trunk/bundleplugin/src/main/java/org/apache/felix/obrplugin/ObrIndex.java?rev=1181889&r1=1181888&r2=1181889&view=diff
==============================================================================
--- felix/trunk/bundleplugin/src/main/java/org/apache/felix/obrplugin/ObrIndex.java (original)
+++ felix/trunk/bundleplugin/src/main/java/org/apache/felix/obrplugin/ObrIndex.java Tue Oct 11 17:01:19 2011
@@ -209,25 +209,36 @@ public final class ObrIndex extends Abst
}
else if ( urlTemplate != null )
{
- String dir = path.getParentFile().toURI().toURL().toString();
- if ( dir.endsWith( "/" ) )
- dir = dir.substring( 0, dir.length() - 1 );
+ URI parentDir = path.getParentFile().toURI();
- if ( dir.startsWith( root.toString() ) )
- dir = dir.substring( root.toString().length() );
+ String absoluteDir = trim( root.toString(), parentDir.toURL().toString() );
+ String relativeDir = trim( root.toString(), root.relativize( parentDir ).toString() );
String url = urlTemplate.replaceAll( "%v", "" + resource.getVersion() );
url = url.replaceAll( "%s", resource.getSymbolicName() );
url = url.replaceAll( "%f", path.getName() );
- url = url.replaceAll( "%p", dir );
+ url = url.replaceAll( "%p", absoluteDir );
+ url = url.replaceAll( "%rp", relativeDir );
finalUri = url;
}
resource.put( Resource.URI, finalUri, Property.URI );
}
- private final FileFilter filter = new FileFilter()
+
+ private String trim( String prefix, String path )
{
+ if ( path.endsWith( "/" ) )
+ path = path.substring( 0, path.length() - 1 );
+
+ if ( path.startsWith( prefix ) )
+ path = path.substring( prefix.length() );
+
+ return path;
+ }
+
+ private final FileFilter filter = new FileFilter()
+ {
public boolean accept( File pathname )
{
return pathname.getName().endsWith( "ar" );