Apply Felix code format
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1140901 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/bundleplugin/src/main/java/org/apache/felix/bundleplugin/AbstractDependencyFilter.java b/bundleplugin/src/main/java/org/apache/felix/bundleplugin/AbstractDependencyFilter.java
index 06cf109..3918cc3 100644
--- a/bundleplugin/src/main/java/org/apache/felix/bundleplugin/AbstractDependencyFilter.java
+++ b/bundleplugin/src/main/java/org/apache/felix/bundleplugin/AbstractDependencyFilter.java
@@ -115,7 +115,8 @@
StringBuilder tag = new StringBuilder();
tag.append( clause.getKey() );
- if( !((String)clause.getKey()).matches("\\*~*") ) {
+ if ( !( ( String ) clause.getKey() ).matches( "\\*~*" ) )
+ {
filter = new DependencyFilter( ( String ) clause.getKey() )
{
boolean matches( Artifact dependency )
diff --git a/bundleplugin/src/main/java/org/apache/felix/bundleplugin/BlueprintPlugin.java b/bundleplugin/src/main/java/org/apache/felix/bundleplugin/BlueprintPlugin.java
index 81aaee9..2c8b3d9 100644
--- a/bundleplugin/src/main/java/org/apache/felix/bundleplugin/BlueprintPlugin.java
+++ b/bundleplugin/src/main/java/org/apache/felix/bundleplugin/BlueprintPlugin.java
@@ -33,6 +33,7 @@
import java.util.Set;
import java.util.TreeSet;
import java.util.regex.Pattern;
+
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.stream.StreamResult;
@@ -48,134 +49,150 @@
import aQute.libg.reporter.Reporter;
-public class BlueprintPlugin implements AnalyzerPlugin {
+public class BlueprintPlugin implements AnalyzerPlugin
+{
-
- static Pattern QN = Pattern.compile("[_A-Za-z$][_A-Za-z0-9$]*(\\.[_A-Za-z$][_A-Za-z0-9$]*)*");
- static Pattern PATHS = Pattern.compile( ".*\\.xml");
+ static Pattern QN = Pattern.compile( "[_A-Za-z$][_A-Za-z0-9$]*(\\.[_A-Za-z$][_A-Za-z0-9$]*)*" );
+ static Pattern PATHS = Pattern.compile( ".*\\.xml" );
Transformer transformer;
- public BlueprintPlugin() throws Exception {
- transformer = getTransformer(getClass().getResource("blueprint.xsl"));
+
+ public BlueprintPlugin() throws Exception
+ {
+ transformer = getTransformer( getClass().getResource( "blueprint.xsl" ) );
}
- public boolean analyzeJar(Analyzer analyzer) throws Exception {
- transformer.setParameter("nsh_interface", analyzer.getProperty("nsh_interface") != null ? analyzer.getProperty("nsh_interface") : "");
- transformer.setParameter("nsh_namespace", analyzer.getProperty("nsh_namespace") != null ? analyzer.getProperty("nsh_namespace") : "");
+
+ public boolean analyzeJar( Analyzer analyzer ) throws Exception
+ {
+ transformer.setParameter( "nsh_interface",
+ analyzer.getProperty( "nsh_interface" ) != null ? analyzer.getProperty( "nsh_interface" ) : "" );
+ transformer.setParameter( "nsh_namespace",
+ analyzer.getProperty( "nsh_namespace" ) != null ? analyzer.getProperty( "nsh_namespace" ) : "" );
Set<String> headers = Create.set();
- String bpHeader = analyzer.getProperty("Bundle-Blueprint", "OSGI-INF/blueprint");
- Map<String, Map<String,String>> map = Processor.parseHeader(bpHeader, null);
- for (String root : map.keySet())
+ String bpHeader = analyzer.getProperty( "Bundle-Blueprint", "OSGI-INF/blueprint" );
+ Map<String, Map<String, String>> map = Processor.parseHeader( bpHeader, null );
+ for ( String root : map.keySet() )
{
Jar jar = analyzer.getJar();
- Map<String, Resource> dir = jar.getDirectories().get(root);
- if(dir == null || dir.isEmpty())
+ Map<String, Resource> dir = jar.getDirectories().get( root );
+ if ( dir == null || dir.isEmpty() )
{
- Resource resource = jar.getResource(root);
- if(resource != null)
- process(analyzer, root, resource, headers);
+ Resource resource = jar.getResource( root );
+ if ( resource != null )
+ process( analyzer, root, resource, headers );
return false;
}
- for(Map.Entry<String,Resource> entry : dir.entrySet())
+ for ( Map.Entry<String, Resource> entry : dir.entrySet() )
{
String path = entry.getKey();
Resource resource = entry.getValue();
- if(PATHS.matcher(path).matches())
- process(analyzer, path, resource, headers);
+ if ( PATHS.matcher( path ).matches() )
+ process( analyzer, path, resource, headers );
}
}
// Group and analyze
Map<String, Set<Attribute>> hdrs = Create.map();
- for (String str : headers) {
- int idx = str.indexOf(':');
- if (idx < 0)
+ for ( String str : headers )
+ {
+ int idx = str.indexOf( ':' );
+ if ( idx < 0 )
{
- analyzer.warning((new StringBuilder("Error analyzing services in blueprint resource: ")).append(str).toString());
+ analyzer.warning( ( new StringBuilder( "Error analyzing services in blueprint resource: " ) ).append(
+ str ).toString() );
continue;
}
- String h = str.substring(0, idx).trim();
- String v = str.substring(idx + 1).trim();
- Set<Attribute> att = hdrs.get(h);
- if (att == null) {
+ String h = str.substring( 0, idx ).trim();
+ String v = str.substring( idx + 1 ).trim();
+ Set<Attribute> att = hdrs.get( h );
+ if ( att == null )
+ {
att = new TreeSet<Attribute>();
- hdrs.put(h, att);
+ hdrs.put( h, att );
}
- att.addAll(parseHeader(v, null));
+ att.addAll( parseHeader( v, null ) );
}
// Merge
- for (String header : hdrs.keySet())
+ for ( String header : hdrs.keySet() )
{
- if ("Import-Class".equals(header) || "Import-Package".equals(header))
+ if ( "Import-Class".equals( header ) || "Import-Package".equals( header ) )
{
- Set<Attribute> newAttr = hdrs.get(header);
- for (Attribute a : newAttr)
+ Set<Attribute> newAttr = hdrs.get( header );
+ for ( Attribute a : newAttr )
{
String pkg = a.getName();
- if ("Import-Class".equals(header))
+ if ( "Import-Class".equals( header ) )
{
- int n = a.getName().lastIndexOf('.');
- if (n > 0) {
- pkg = pkg.subSequence(0, n).toString();
- } else {
+ int n = a.getName().lastIndexOf( '.' );
+ if ( n > 0 )
+ {
+ pkg = pkg.subSequence( 0, n ).toString();
+ }
+ else
+ {
continue;
}
}
- if (!analyzer.getReferred().containsKey(pkg))
+ if ( !analyzer.getReferred().containsKey( pkg ) )
{
- analyzer.getReferred().put(pkg, a.getProperties());
+ analyzer.getReferred().put( pkg, a.getProperties() );
}
}
}
else
{
- Set<Attribute> orgAttr = parseHeader(analyzer.getProperty(header), null);
- Set<Attribute> newAttr = hdrs.get(header);
- for (Iterator<Attribute> it = newAttr.iterator(); it.hasNext();)
+ Set<Attribute> orgAttr = parseHeader( analyzer.getProperty( header ), null );
+ Set<Attribute> newAttr = hdrs.get( header );
+ for ( Iterator<Attribute> it = newAttr.iterator(); it.hasNext(); )
{
Attribute a = it.next();
- for (Attribute b : orgAttr)
+ for ( Attribute b : orgAttr )
{
- if (b.getName().equals(a.getName()))
+ if ( b.getName().equals( a.getName() ) )
{
it.remove();
break;
}
}
}
- orgAttr.addAll(newAttr);
+ orgAttr.addAll( newAttr );
// Rebuild from orgAttr
StringBuilder sb = new StringBuilder();
- for (Attribute a : orgAttr)
+ for ( Attribute a : orgAttr )
{
- if (sb.length() > 0)
+ if ( sb.length() > 0 )
{
- sb.append(",");
+ sb.append( "," );
}
- sb.append(a.getName());
- for (Map.Entry<String, String> prop : a.getProperties().entrySet())
+ sb.append( a.getName() );
+ for ( Map.Entry<String, String> prop : a.getProperties().entrySet() )
{
- sb.append(';').append(prop.getKey()).append("=");
- if (prop.getValue().matches("[0-9a-zA-Z_-]+")) {
- sb.append(prop.getValue());
- } else {
- sb.append("\"");
- sb.append(prop.getValue().replace("\"", "\\\""));
- sb.append("\"");
+ sb.append( ';' ).append( prop.getKey() ).append( "=" );
+ if ( prop.getValue().matches( "[0-9a-zA-Z_-]+" ) )
+ {
+ sb.append( prop.getValue() );
+ }
+ else
+ {
+ sb.append( "\"" );
+ sb.append( prop.getValue().replace( "\"", "\\\"" ) );
+ sb.append( "\"" );
}
}
}
- analyzer.setProperty(header, sb.toString());
+ analyzer.setProperty( header, sb.toString() );
}
}
return false;
}
- private void process(Analyzer analyzer, String path, Resource resource, Set<String> headers)
+
+ private void process( Analyzer analyzer, String path, Resource resource, Set<String> headers )
{
InputStream in = null;
try
@@ -183,46 +200,47 @@
in = resource.openInputStream();
// Retrieve headers
- Set<String> set = analyze(in);
- headers.addAll(set);
+ Set<String> set = analyze( in );
+ headers.addAll( set );
}
- catch(Exception e)
+ catch ( Exception e )
{
- analyzer.error((new StringBuilder("Unexpected exception in processing spring resources(")).append(path).append("): ").append(e).toString());
+ analyzer.error( ( new StringBuilder( "Unexpected exception in processing spring resources(" ) )
+ .append( path ).append( "): " ).append( e ).toString() );
}
finally
{
try
{
- if (in != null)
+ if ( in != null )
{
in.close();
}
}
- catch (IOException e)
+ catch ( IOException e )
{
}
}
}
- public Set<String> analyze(InputStream in)
- throws Exception
+
+ public Set<String> analyze( InputStream in ) throws Exception
{
Set<String> refers = new HashSet<String>();
ByteArrayOutputStream bout = new ByteArrayOutputStream();
- javax.xml.transform.Result r = new StreamResult(bout);
- javax.xml.transform.Source s = new StreamSource(in);
- transformer.transform(s, r);
- ByteArrayInputStream bin = new ByteArrayInputStream(bout.toByteArray());
+ javax.xml.transform.Result r = new StreamResult( bout );
+ javax.xml.transform.Source s = new StreamSource( in );
+ transformer.transform( s, r );
+ ByteArrayInputStream bin = new ByteArrayInputStream( bout.toByteArray() );
bout.close();
- BufferedReader br = new BufferedReader(new InputStreamReader(bin));
- for(String line = br.readLine(); line != null; line = br.readLine())
+ BufferedReader br = new BufferedReader( new InputStreamReader( bin ) );
+ for ( String line = br.readLine(); line != null; line = br.readLine() )
{
line = line.trim();
- line = line.replace(";availability:=mandatory", "");
- if(line.length() > 0)
+ line = line.replace( ";availability:=mandatory", "" );
+ if ( line.length() > 0 )
{
- refers.add(line);
+ refers.add( line );
}
}
@@ -230,136 +248,157 @@
return refers;
}
- protected Transformer getTransformer(URL url)
- throws Exception
+
+ protected Transformer getTransformer( URL url ) throws Exception
{
TransformerFactory tf = TransformerFactory.newInstance();
- javax.xml.transform.Source source = new StreamSource(url.openStream());
- return tf.newTransformer(source);
+ javax.xml.transform.Source source = new StreamSource( url.openStream() );
+ return tf.newTransformer( source );
}
public static class Attribute implements Comparable<Attribute>
{
private final String name;
- private final Map<String,String> properties;
+ private final Map<String, String> properties;
- public Attribute(String name, Map<String, String> properties) {
+
+ public Attribute( String name, Map<String, String> properties )
+ {
this.name = name;
this.properties = properties;
}
- public String getName() {
+
+ public String getName()
+ {
return name;
}
- public Map<String, String> getProperties() {
+
+ public Map<String, String> getProperties()
+ {
return properties;
}
- public int compareTo(Attribute a) {
- int c = name.compareTo(a.name);
- if (c == 0)
+
+ public int compareTo( Attribute a )
+ {
+ int c = name.compareTo( a.name );
+ if ( c == 0 )
{
- c = properties.equals(a.properties) ? 0 :
- properties.size() < a.properties.size() ? -1 :
- properties.hashCode() < a.properties.hashCode() ? -1 : +1;
+ c = properties.equals( a.properties ) ? 0 : properties.size() < a.properties.size() ? -1 : properties
+ .hashCode() < a.properties.hashCode() ? -1 : +1;
}
return c;
}
@Override
- public boolean equals(Object o) {
- if (this == o) return true;
- if (o == null || getClass() != o.getClass()) return false;
+ public boolean equals( Object o )
+ {
+ if ( this == o )
+ return true;
+ if ( o == null || getClass() != o.getClass() )
+ return false;
- Attribute attribute = (Attribute) o;
+ Attribute attribute = ( Attribute ) o;
- if (name != null ? !name.equals(attribute.name) : attribute.name != null) return false;
- if (properties != null ? !properties.equals(attribute.properties) : attribute.properties != null)
+ if ( name != null ? !name.equals( attribute.name ) : attribute.name != null )
+ return false;
+ if ( properties != null ? !properties.equals( attribute.properties ) : attribute.properties != null )
return false;
return true;
}
+
@Override
- public int hashCode() {
+ public int hashCode()
+ {
int result = name != null ? name.hashCode() : 0;
- result = 31 * result + (properties != null ? properties.hashCode() : 0);
+ result = 31 * result + ( properties != null ? properties.hashCode() : 0 );
return result;
}
}
- public static Set<Attribute> parseHeader(String value, Reporter logger)
+
+ public static Set<Attribute> parseHeader( String value, Reporter logger )
{
- if ((value == null) || (value.trim().length() == 0)) {
+ if ( ( value == null ) || ( value.trim().length() == 0 ) )
+ {
return new TreeSet<Attribute>();
}
Set<Attribute> result = new TreeSet<Attribute>();
- QuotedTokenizer qt = new QuotedTokenizer(value, ";=,");
+ QuotedTokenizer qt = new QuotedTokenizer( value, ";=," );
char del = '\0';
- do {
+ do
+ {
boolean hadAttribute = false;
- Map<String,String> clause = Create.map();
+ Map<String, String> clause = Create.map();
List<String> aliases = Create.list();
- String name = qt.nextToken(",;");
+ String name = qt.nextToken( ",;" );
del = qt.getSeparator();
- if ((name == null) || (name.length() == 0)) {
- if ((logger != null) && (logger.isPedantic())) {
- logger.warning("Empty clause, usually caused by repeating a comma without any name field or by having " +
- "spaces after the backslash of a property file: " +
- value);
+ if ( ( name == null ) || ( name.length() == 0 ) )
+ {
+ if ( ( logger != null ) && ( logger.isPedantic() ) )
+ {
+ logger
+ .warning( "Empty clause, usually caused by repeating a comma without any name field or by having "
+ + "spaces after the backslash of a property file: " + value );
}
- if (name != null)
+ if ( name != null )
continue;
break;
}
name = name.trim();
- aliases.add(name);
+ aliases.add( name );
String advalue;
- while (del == ';') {
+ while ( del == ';' )
+ {
String adname = qt.nextToken();
- if ((del = qt.getSeparator()) != '=') {
- if ((hadAttribute) && (logger != null)) {
- logger.error("Header contains name field after attribute or directive: " +
- adname +
- " from " +
- value +
- ". Name fields must be consecutive, separated by a ';' like a;b;c;x=3;y=4");
+ if ( ( del = qt.getSeparator() ) != '=' )
+ {
+ if ( ( hadAttribute ) && ( logger != null ) )
+ {
+ logger.error( "Header contains name field after attribute or directive: " + adname + " from "
+ + value + ". Name fields must be consecutive, separated by a ';' like a;b;c;x=3;y=4" );
}
- if ((adname != null) && (adname.length() > 0))
- aliases.add(adname.trim());
- } else {
+ if ( ( adname != null ) && ( adname.length() > 0 ) )
+ aliases.add( adname.trim() );
+ }
+ else
+ {
advalue = qt.nextToken();
- if ((clause.containsKey(adname)) && (logger != null) && (logger.isPedantic())) {
- logger.warning("Duplicate attribute/directive name " +
- adname +
- " in " +
- value +
- ". This attribute/directive will be ignored");
+ if ( ( clause.containsKey( adname ) ) && ( logger != null ) && ( logger.isPedantic() ) )
+ {
+ logger.warning( "Duplicate attribute/directive name " + adname + " in " + value
+ + ". This attribute/directive will be ignored" );
}
- if (advalue == null) {
- if (logger != null) {
- logger.error("No value after '=' sign for attribute " + adname);
+ if ( advalue == null )
+ {
+ if ( logger != null )
+ {
+ logger.error( "No value after '=' sign for attribute " + adname );
}
advalue = "";
}
- clause.put(adname.trim(), advalue.trim());
+ clause.put( adname.trim(), advalue.trim() );
del = qt.getSeparator();
hadAttribute = true;
}
}
- for (String clauseName : aliases) {
- result.add(new Attribute(clauseName, clause));
+ for ( String clauseName : aliases )
+ {
+ result.add( new Attribute( clauseName, clause ) );
}
}
- while (del == ',');
+ while ( del == ',' );
return result;
}
diff --git a/bundleplugin/src/main/java/org/apache/felix/bundleplugin/BundlePlugin.java b/bundleplugin/src/main/java/org/apache/felix/bundleplugin/BundlePlugin.java
index fd31a98..f5402a6 100644
--- a/bundleplugin/src/main/java/org/apache/felix/bundleplugin/BundlePlugin.java
+++ b/bundleplugin/src/main/java/org/apache/felix/bundleplugin/BundlePlugin.java
@@ -202,7 +202,7 @@
* @required
* @readonly
*/
- private MavenSession m_mavenSession;
+ private MavenSession m_mavenSession;
private static final String MAVEN_SYMBOLICNAME = "maven-symbolicname";
private static final String MAVEN_RESOURCES = "{maven-resources}";
@@ -324,7 +324,7 @@
{
// treat as warning; this error happens when you have duplicate entries in Include-Resource
String duplicate = Processor.removeDuplicateMarker( msg.substring( fileNotFound.length() ) );
- getLog().warn( prefix + " : Duplicate path '" + duplicate + "' in Include-Resource" );
+ getLog().warn( prefix + " : Duplicate path '" + duplicate + "' in Include-Resource" );
}
else
{
@@ -429,6 +429,7 @@
return builder;
}
+
protected void addMavenInstructions( MavenProject currentProject, Builder builder ) throws Exception
{
if ( currentProject.getBasedir() != null )
@@ -599,8 +600,7 @@
}
- protected void mergeMavenManifest( MavenProject currentProject, Builder builder )
- throws Exception
+ protected void mergeMavenManifest( MavenProject currentProject, Builder builder ) throws Exception
{
Jar jar = builder.getJar();
@@ -685,20 +685,23 @@
// adjust the import package attributes so that optional dependencies use
// optional resolution.
- String importPackages = bundleManifest.getMainAttributes().getValue("Import-Package");
- if( importPackages!=null ) {
- Set optionalPackages = getOptionalPackages(currentProject);
+ String importPackages = bundleManifest.getMainAttributes().getValue( "Import-Package" );
+ if ( importPackages != null )
+ {
+ Set optionalPackages = getOptionalPackages( currentProject );
- Map<String, Map<String, String>> values = new Analyzer().parseHeader(importPackages);
- for (Map.Entry<String, Map<String, String>> entry: values.entrySet()) {
+ Map<String, Map<String, String>> values = new Analyzer().parseHeader( importPackages );
+ for ( Map.Entry<String, Map<String, String>> entry : values.entrySet() )
+ {
String pkg = entry.getKey();
Map<String, String> options = entry.getValue();
- if( !options.containsKey("resolution:") && optionalPackages.contains(pkg) ) {
- options.put("resolution:", "optional");
+ if ( !options.containsKey( "resolution:" ) && optionalPackages.contains( pkg ) )
+ {
+ options.put( "resolution:", "optional" );
}
}
- String result = Processor.printClauses(values, "resolution:");
- bundleManifest.getMainAttributes().putValue("Import-Package", result);
+ String result = Processor.printClauses( values, "resolution:" );
+ bundleManifest.getMainAttributes().putValue( "Import-Package", result );
}
jar.setManifest( bundleManifest );
@@ -733,7 +736,7 @@
{
if ( !Artifact.SCOPE_TEST.equals( artifact.getScope() ) )
{
- inscope.add(artifact);
+ inscope.add( artifact );
}
}
}
@@ -742,13 +745,15 @@
for ( Iterator it = inscope.iterator(); it.hasNext(); )
{
Artifact artifact = ( Artifact ) it.next();
- if( artifact.isOptional() ) {
+ if ( artifact.isOptional() )
+ {
String id = artifact.toString();
- if( artifact.getScope()!=null ) {
+ if ( artifact.getScope() != null )
+ {
// strip the scope...
- id = id.replaceFirst(":[^:]*$", "");
+ id = id.replaceFirst( ":[^:]*$", "" );
}
- optionalArtifactIds.add(id);
+ optionalArtifactIds.add( id );
}
}
@@ -765,35 +770,43 @@
}
Jar jar = new Jar( artifact.getArtifactId(), file );
- if( isTransitivelyOptional(optionalArtifactIds, artifact) ) {
- optional.addAll(jar.getPackages());
- } else {
- required.addAll(jar.getPackages());
+ if ( isTransitivelyOptional( optionalArtifactIds, artifact ) )
+ {
+ optional.addAll( jar.getPackages() );
+ }
+ else
+ {
+ required.addAll( jar.getPackages() );
}
jar.close();
}
- optional.removeAll(required);
+ optional.removeAll( required );
return optional;
}
+
/**
* Check to see if any dependency along the dependency trail of
* the artifact is optional.
*
* @param artifact
*/
- protected boolean isTransitivelyOptional(HashSet optionalArtifactIds, Artifact artifact) {
+ protected boolean isTransitivelyOptional( HashSet optionalArtifactIds, Artifact artifact )
+ {
List trail = artifact.getDependencyTrail();
- for (Iterator iterator = trail.iterator(); iterator.hasNext();) {
- String next = (String) iterator.next();
- if( optionalArtifactIds.contains(next) ) {
+ for ( Iterator iterator = trail.iterator(); iterator.hasNext(); )
+ {
+ String next = ( String ) iterator.next();
+ if ( optionalArtifactIds.contains( next ) )
+ {
return true;
}
}
return false;
}
+
private void unpackBundle( File jarFile )
{
File outputDir = getOutputDirectory();
@@ -917,9 +930,7 @@
p.put( "artifactId", currentProject.getArtifactId() );
ByteArrayOutputStream out = new ByteArrayOutputStream();
p.store( out, "Generated by org.apache.felix.bundleplugin" );
- jar
- .putResource( path + "/pom.properties",
- new EmbeddedResource( out.toByteArray(), System.currentTimeMillis() ) );
+ jar.putResource( path + "/pom.properties", new EmbeddedResource( out.toByteArray(), System.currentTimeMillis() ) );
}
@@ -1071,7 +1082,7 @@
properties.put( MAVEN_SYMBOLICNAME, bsn );
properties.put( Analyzer.BUNDLE_SYMBOLICNAME, bsn );
properties.put( Analyzer.IMPORT_PACKAGE, "*" );
- properties.put( Analyzer.BUNDLE_VERSION, getMaven2OsgiConverter().getVersion(currentProject.getVersion()) );
+ properties.put( Analyzer.BUNDLE_VERSION, getMaven2OsgiConverter().getVersion( currentProject.getVersion() ) );
// remove the extraneous Include-Resource and Private-Package entries from generated manifest
properties.put( Constants.REMOVEHEADERS, Analyzer.INCLUDE_RESOURCE + ',' + Analyzer.PRIVATE_PACKAGE );
@@ -1120,9 +1131,7 @@
properties.put( "classifier", classifier == null ? "" : classifier );
// Add default plugins
- header( properties, Analyzer.PLUGIN,
- BlueprintPlugin.class.getName() + ","
- + SpringXMLType.class.getName());
+ header( properties, Analyzer.PLUGIN, BlueprintPlugin.class.getName() + "," + SpringXMLType.class.getName() );
return properties;
}
@@ -1170,8 +1179,8 @@
StringBuffer exportedPkgs = new StringBuffer();
StringBuffer privatePkgs = new StringBuffer();
-
- boolean noprivatePackages = "!*".equals(analyzer.getProperty( Analyzer.PRIVATE_PACKAGE ) );
+
+ boolean noprivatePackages = "!*".equals( analyzer.getProperty( Analyzer.PRIVATE_PACKAGE ) );
for ( Iterator i = packages.iterator(); i.hasNext(); )
{
@@ -1183,7 +1192,7 @@
// we can't export the default package (".") and we shouldn't export internal packages
if ( noprivatePackages || !( ".".equals( pkg ) || pkg.contains( ".internal" ) || pkg.contains( ".impl" ) ) )
{
- if( exportedPkgs.length() > 0 )
+ if ( exportedPkgs.length() > 0 )
{
exportedPkgs.append( ';' );
}
@@ -1207,7 +1216,7 @@
else
{
String exported = analyzer.getProperty( Analyzer.EXPORT_PACKAGE );
- if( exported.indexOf( LOCAL_PACKAGES ) >= 0 )
+ if ( exported.indexOf( LOCAL_PACKAGES ) >= 0 )
{
String newExported = StringUtils.replace( exported, LOCAL_PACKAGES, exportedPkgs.toString() );
analyzer.setProperty( Analyzer.EXPORT_PACKAGE, newExported );
@@ -1232,7 +1241,7 @@
private static List getMavenResources( MavenProject currentProject )
{
- List resources = new ArrayList(currentProject.getResources());
+ List resources = new ArrayList( currentProject.getResources() );
if ( currentProject.getCompileSourceRoots() != null )
{
@@ -1240,7 +1249,7 @@
List packageInfoIncludes = Collections.singletonList( "**/packageinfo" );
for ( Iterator i = currentProject.getCompileSourceRoots().iterator(); i.hasNext(); )
{
- String sourceRoot = (String) i.next();
+ String sourceRoot = ( String ) i.next();
Resource packageInfoResource = new Resource();
packageInfoResource.setDirectory( sourceRoot );
packageInfoResource.setIncludes( packageInfoIncludes );
@@ -1334,7 +1343,7 @@
}
StringBuffer resourcePaths = new StringBuffer();
- for ( Iterator i = pathSet.iterator() ; i.hasNext(); )
+ for ( Iterator i = pathSet.iterator(); i.hasNext(); )
{
resourcePaths.append( i.next() );
if ( i.hasNext() )
diff --git a/bundleplugin/src/main/java/org/apache/felix/bundleplugin/DependencyEmbedder.java b/bundleplugin/src/main/java/org/apache/felix/bundleplugin/DependencyEmbedder.java
index 6937206..9c01de8 100644
--- a/bundleplugin/src/main/java/org/apache/felix/bundleplugin/DependencyEmbedder.java
+++ b/bundleplugin/src/main/java/org/apache/felix/bundleplugin/DependencyEmbedder.java
@@ -26,8 +26,8 @@
import java.util.Map;
import org.apache.maven.artifact.Artifact;
-import org.apache.maven.plugin.logging.Log;
import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.logging.Log;
import org.codehaus.plexus.util.StringUtils;
import aQute.lib.osgi.Analyzer;
diff --git a/bundleplugin/src/main/java/org/apache/felix/bundleplugin/ManifestPlugin.java b/bundleplugin/src/main/java/org/apache/felix/bundleplugin/ManifestPlugin.java
index 4d46efd..212dd3d 100644
--- a/bundleplugin/src/main/java/org/apache/felix/bundleplugin/ManifestPlugin.java
+++ b/bundleplugin/src/main/java/org/apache/felix/bundleplugin/ManifestPlugin.java
@@ -127,8 +127,8 @@
}
- protected Analyzer getAnalyzer( MavenProject project, Jar[] classpath )
- throws IOException, MojoExecutionException, Exception
+ protected Analyzer getAnalyzer( MavenProject project, Jar[] classpath ) throws IOException, MojoExecutionException,
+ Exception
{
return getAnalyzer( project, new LinkedHashMap(), new Properties(), classpath );
}
@@ -152,9 +152,9 @@
analyzer.setJar( file );
- if ( analyzer.getProperty( Analyzer.EXPORT_PACKAGE ) == null &&
- analyzer.getProperty( Analyzer.EXPORT_CONTENTS ) == null &&
- analyzer.getProperty( Analyzer.PRIVATE_PACKAGE ) == null )
+ if ( analyzer.getProperty( Analyzer.EXPORT_PACKAGE ) == null
+ && analyzer.getProperty( Analyzer.EXPORT_CONTENTS ) == null
+ && analyzer.getProperty( Analyzer.PRIVATE_PACKAGE ) == null )
{
String export = analyzer.calculateExportsFromContents( analyzer.getJar() );
analyzer.setProperty( Analyzer.EXPORT_PACKAGE, export );
diff --git a/bundleplugin/src/main/java/org/apache/felix/bundleplugin/PackageVersionAnalyzer.java b/bundleplugin/src/main/java/org/apache/felix/bundleplugin/PackageVersionAnalyzer.java
index e6ee34b..c4d24b9 100644
--- a/bundleplugin/src/main/java/org/apache/felix/bundleplugin/PackageVersionAnalyzer.java
+++ b/bundleplugin/src/main/java/org/apache/felix/bundleplugin/PackageVersionAnalyzer.java
@@ -32,34 +32,34 @@
/*
* Remove META-INF subfolders from exports and set package versions to bundle version.
*/
-/*
- public Map analyzeBundleClasspath( Jar dot, Map bundleClasspath, Map contained, Map referred, Map uses )
- throws IOException
- {
- Map classSpace = super.analyzeBundleClasspath( dot, bundleClasspath, contained, referred, uses );
- String bundleVersion = getProperty( BUNDLE_VERSION );
- for ( Iterator it = contained.entrySet().iterator(); it.hasNext(); )
+ /*
+ public Map analyzeBundleClasspath( Jar dot, Map bundleClasspath, Map contained, Map referred, Map uses )
+ throws IOException
{
- Map.Entry entry = ( Map.Entry ) it.next();
-
- // remove packages under META-INF
- String packageName = ( String ) entry.getKey();
- if ( packageName.startsWith( "META-INF." ) )
+ Map classSpace = super.analyzeBundleClasspath( dot, bundleClasspath, contained, referred, uses );
+ String bundleVersion = getProperty( BUNDLE_VERSION );
+ for ( Iterator it = contained.entrySet().iterator(); it.hasNext(); )
{
- it.remove();
- }
+ Map.Entry entry = ( Map.Entry ) it.next();
- // set package versions to bundle version values
- if ( bundleVersion != null )
- {
- Map values = ( Map ) entry.getValue();
- if ( values.get( "version" ) == null )
+ // remove packages under META-INF
+ String packageName = ( String ) entry.getKey();
+ if ( packageName.startsWith( "META-INF." ) )
{
- values.put( "version", bundleVersion );
+ it.remove();
+ }
+
+ // set package versions to bundle version values
+ if ( bundleVersion != null )
+ {
+ Map values = ( Map ) entry.getValue();
+ if ( values.get( "version" ) == null )
+ {
+ values.put( "version", bundleVersion );
+ }
}
}
+ return classSpace;
}
- return classSpace;
- }
-*/
+ */
}
diff --git a/bundleplugin/src/main/java/org/apache/felix/bundleplugin/VersionCleanerPlugin.java b/bundleplugin/src/main/java/org/apache/felix/bundleplugin/VersionCleanerPlugin.java
index 6b33c9d..22e9024 100644
--- a/bundleplugin/src/main/java/org/apache/felix/bundleplugin/VersionCleanerPlugin.java
+++ b/bundleplugin/src/main/java/org/apache/felix/bundleplugin/VersionCleanerPlugin.java
@@ -18,6 +18,7 @@
*/
package org.apache.felix.bundleplugin;
+
import java.util.LinkedHashMap;
import java.util.Map;
@@ -28,12 +29,14 @@
import org.apache.maven.shared.osgi.DefaultMaven2OsgiConverter;
import org.apache.maven.shared.osgi.Maven2OsgiConverter;
+
/**
* @goal cleanVersions
* @description clean OSGi versions
* @threadSafe
*/
-public class VersionCleanerPlugin extends AbstractMojo {
+public class VersionCleanerPlugin extends AbstractMojo
+{
/**
* The BND instructions for the bundle.
@@ -53,21 +56,27 @@
private Maven2OsgiConverter maven2OsgiConverter = new DefaultMaven2OsgiConverter();
- public Maven2OsgiConverter getMaven2OsgiConverter() {
+
+ public Maven2OsgiConverter getMaven2OsgiConverter()
+ {
return maven2OsgiConverter;
}
- public void setMaven2OsgiConverter(Maven2OsgiConverter maven2OsgiConverter) {
+
+ public void setMaven2OsgiConverter( Maven2OsgiConverter maven2OsgiConverter )
+ {
this.maven2OsgiConverter = maven2OsgiConverter;
}
- public void execute() throws MojoExecutionException, MojoFailureException {
- for (Object key : versions.keySet())
+
+ public void execute() throws MojoExecutionException, MojoFailureException
+ {
+ for ( Object key : versions.keySet() )
{
- String name = (String) key;
- String version = (String) versions.get(key);
- String osgi = maven2OsgiConverter.getVersion(version);
- project.getProperties().put(name, osgi);
+ String name = ( String ) key;
+ String version = ( String ) versions.get( key );
+ String osgi = maven2OsgiConverter.getVersion( version );
+ project.getProperties().put( name, osgi );
}
}
}
diff --git a/bundleplugin/src/main/java/org/apache/felix/obrplugin/ObrDeploy.java b/bundleplugin/src/main/java/org/apache/felix/obrplugin/ObrDeploy.java
index 258e470..bd69d17 100644
--- a/bundleplugin/src/main/java/org/apache/felix/obrplugin/ObrDeploy.java
+++ b/bundleplugin/src/main/java/org/apache/felix/obrplugin/ObrDeploy.java
@@ -233,7 +233,7 @@
{
// public URL differs from the bundle file location
URI uri = URI.create( bundleUrl );
- log.info("Computed bundle uri: " + uri);
+ log.info( "Computed bundle uri: " + uri );
userConfig.setRemoteBundle( uri );
}
else if ( prefixUrl != null )
@@ -244,7 +244,7 @@
.toASCIIString();
URL resourceURL = new URL( new URL( prefixUrl + '/' ), relative );
URI uri = URI.create( resourceURL.toString() );
- log.info("Computed bundle uri: " + uri);
+ log.info( "Computed bundle uri: " + uri );
userConfig.setRemoteBundle( uri );
}
diff --git a/bundleplugin/src/main/java/org/apache/felix/obrplugin/ObrDeployFile.java b/bundleplugin/src/main/java/org/apache/felix/obrplugin/ObrDeployFile.java
index 2dc8f55..8a33c7a 100644
--- a/bundleplugin/src/main/java/org/apache/felix/obrplugin/ObrDeployFile.java
+++ b/bundleplugin/src/main/java/org/apache/felix/obrplugin/ObrDeployFile.java
@@ -187,14 +187,14 @@
{
// public URL differs from the bundle file location
URI uri = URI.create( bundleUrl );
- log.info("Computed bundle uri: " + uri);
+ log.info( "Computed bundle uri: " + uri );
userConfig.setRemoteBundle( uri );
}
else if ( null != file )
{
// assume file will be deployed in remote repository, so find the remote relative location
URI uri = URI.create( localRepository.pathOf( project.getArtifact() ) );
- log.info("Computed bundle uri: " + uri);
+ log.info( "Computed bundle uri: " + uri );
userConfig.setRemoteBundle( uri );
}
diff --git a/bundleplugin/src/main/java/org/apache/felix/obrplugin/ObrIndex.java b/bundleplugin/src/main/java/org/apache/felix/obrplugin/ObrIndex.java
index cfa77f5..9667af5 100644
--- a/bundleplugin/src/main/java/org/apache/felix/obrplugin/ObrIndex.java
+++ b/bundleplugin/src/main/java/org/apache/felix/obrplugin/ObrIndex.java
@@ -18,6 +18,7 @@
*/
package org.apache.felix.obrplugin;
+
import java.io.File;
import java.io.FileFilter;
import java.io.FileWriter;
@@ -38,6 +39,7 @@
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.logging.Log;
+
/**
* Index the content of a maven repository using OBR
*
@@ -46,7 +48,8 @@
*
* @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
*/
-public final class ObrIndex extends AbstractMojo {
+public final class ObrIndex extends AbstractMojo
+{
/**
* OBR Repository.
@@ -78,56 +81,62 @@
*/
private ArtifactRepository localRepository;
- public void execute() throws MojoExecutionException {
+
+ public void execute() throws MojoExecutionException
+ {
Log log = getLog();
try
{
- log.info("Indexing...");
+ log.info( "Indexing..." );
String repo = mavenRepository;
- if (repo == null) {
+ if ( repo == null )
+ {
repo = localRepository.getBasedir();
}
- URI mavenRepoUri = new File(repo).toURI();
+ URI mavenRepoUri = new File( repo ).toURI();
URI repositoryXml = ObrUtils.findRepositoryXml( repo, obrRepository );
- log.info("Repository: " + mavenRepoUri);
- log.info("OBR xml: " + repositoryXml);
- log.info("URL template: " + urlTemplate);
+ log.info( "Repository: " + mavenRepoUri );
+ log.info( "OBR xml: " + repositoryXml );
+ log.info( "URL template: " + urlTemplate );
List<File> files = new ArrayList<File>();
- findAllJars( new File(repo), files );
+ findAllJars( new File( repo ), files );
DataModelHelperImpl dmh = new DataModelHelperImpl();
RepositoryImpl repository;
- File obrRepoFile = new File(repositoryXml);
- if (obrRepoFile.isFile()) {
- repository = (RepositoryImpl) dmh.repository( repositoryXml.toURL() );
- } else {
+ File obrRepoFile = new File( repositoryXml );
+ if ( obrRepoFile.isFile() )
+ {
+ repository = ( RepositoryImpl ) dmh.repository( repositoryXml.toURL() );
+ }
+ else
+ {
repository = new RepositoryImpl();
}
- for (File file : files)
+ for ( File file : files )
{
try
{
- ResourceImpl resource = (ResourceImpl) dmh.createResource(file.toURI().toURL());
- if (resource != null)
+ ResourceImpl resource = ( ResourceImpl ) dmh.createResource( file.toURI().toURL() );
+ if ( resource != null )
{
- repository.addResource(resource);
- doTemplate(mavenRepoUri, file, resource);
- log.info("Adding resource: " + file);
+ repository.addResource( resource );
+ doTemplate( mavenRepoUri, file, resource );
+ log.info( "Adding resource: " + file );
}
else
{
- log.info("Ignoring non OSGi bundle: " + file);
+ log.info( "Ignoring non OSGi bundle: " + file );
}
}
- catch (Exception e)
+ catch ( Exception e )
{
- log.warn("Error processing bundle: " + file + " " + e.getMessage());
+ log.warn( "Error processing bundle: " + file + " " + e.getMessage() );
}
}
Writer writer = new FileWriter( obrRepoFile );
@@ -146,94 +155,105 @@
}
}
- protected void doTemplate(URI root, File path, ResourceImpl resource) throws IOException, URISyntaxException
+
+ protected void doTemplate( URI root, File path, ResourceImpl resource ) throws IOException, URISyntaxException
{
path = path.getAbsoluteFile().getCanonicalFile();
- String finalUri = root.relativize(path.toURI()).toString();
- if ("maven".equals(urlTemplate))
+ String finalUri = root.relativize( path.toURI() ).toString();
+ if ( "maven".equals( urlTemplate ) )
{
- String dir = root.relativize(path.toURI()).toString();
- String[] p = dir.split("/");
- if (p.length >= 4 && p[p.length-1].startsWith(p[p.length-3] + "-" + p[p.length-2]))
+ String dir = root.relativize( path.toURI() ).toString();
+ String[] p = dir.split( "/" );
+ if ( p.length >= 4 && p[p.length - 1].startsWith( p[p.length - 3] + "-" + p[p.length - 2] ) )
{
- String artifactId = p[p.length-3];
- String version = p[p.length-2];
+ String artifactId = p[p.length - 3];
+ String version = p[p.length - 2];
String classifier;
String type;
String artifactIdVersion = artifactId + "-" + version;
StringBuffer sb = new StringBuffer();
- if (p[p.length-1].charAt(artifactIdVersion.length()) == '-')
+ if ( p[p.length - 1].charAt( artifactIdVersion.length() ) == '-' )
{
- classifier = p[p.length-1].substring(artifactIdVersion.length() + 1, p[p.length-1].lastIndexOf('.'));
+ classifier = p[p.length - 1].substring( artifactIdVersion.length() + 1,
+ p[p.length - 1].lastIndexOf( '.' ) );
}
else
{
classifier = null;
}
- type = p[p.length-1].substring(p[p.length-1].lastIndexOf('.') + 1);
- sb.append("mvn:");
- for (int j = 0; j < p.length - 3; j++)
+ type = p[p.length - 1].substring( p[p.length - 1].lastIndexOf( '.' ) + 1 );
+ sb.append( "mvn:" );
+ for ( int j = 0; j < p.length - 3; j++ )
{
- if (j > 0)
+ if ( j > 0 )
{
- sb.append('.');
+ sb.append( '.' );
}
- sb.append(p[j]);
+ sb.append( p[j] );
}
- sb.append('/').append(artifactId).append('/').append(version);
- if (!"jar".equals(type) || classifier != null)
+ sb.append( '/' ).append( artifactId ).append( '/' ).append( version );
+ if ( !"jar".equals( type ) || classifier != null )
{
- sb.append('/');
- if (!"jar".equals(type))
+ sb.append( '/' );
+ if ( !"jar".equals( type ) )
{
- sb.append(type);
+ sb.append( type );
}
- if (classifier != null)
+ if ( classifier != null )
{
- sb.append('/').append(classifier);
+ sb.append( '/' ).append( classifier );
}
}
finalUri = sb.toString();
}
}
- else if (urlTemplate != null)
+ else if ( urlTemplate != null )
{
String dir = path.getParentFile().toURI().toURL().toString();
- if (dir.endsWith("/"))
- dir = dir.substring(0, dir.length() - 1);
+ if ( dir.endsWith( "/" ) )
+ dir = dir.substring( 0, dir.length() - 1 );
- if (dir.startsWith(root.toString()))
- dir = dir.substring(root.toString().length());
+ if ( dir.startsWith( root.toString() ) )
+ dir = dir.substring( root.toString().length() );
- String url = urlTemplate.replaceAll("%v", "" + resource.getVersion());
- url = url.replaceAll("%s", resource.getSymbolicName());
- url = url.replaceAll("%f", path.getName());
- url = url.replaceAll("%p", dir);
+ String url = urlTemplate.replaceAll( "%v", "" + resource.getVersion() );
+ url = url.replaceAll( "%s", resource.getSymbolicName() );
+ url = url.replaceAll( "%f", path.getName() );
+ url = url.replaceAll( "%p", dir );
finalUri = url;
}
- resource.put(Resource.URI, finalUri, Property.URI);
+ resource.put( Resource.URI, finalUri, Property.URI );
}
- private final FileFilter filter = new FileFilter() {
+ private final FileFilter filter = new FileFilter()
+ {
- public boolean accept(File pathname) {
- return pathname.getName().endsWith("ar");
+ public boolean accept( File pathname )
+ {
+ return pathname.getName().endsWith( "ar" );
}
};
- private void findAllJars(File mainRoot, List<File> files) {
+ private void findAllJars( File mainRoot, List<File> files )
+ {
List<File> roots = new ArrayList<File>();
- roots.add(mainRoot);
- while (!roots.isEmpty()) {
- File root = roots.remove(0);
+ roots.add( mainRoot );
+ while ( !roots.isEmpty() )
+ {
+ File root = roots.remove( 0 );
File[] children = root.listFiles();
- if (children != null) {
- for (File child : children) {
- if (child.isFile() && filter.accept(child)) {
- files.add(child);
- } else if (child.isDirectory()) {
- roots.add(child);
+ if ( children != null )
+ {
+ for ( File child : children )
+ {
+ if ( child.isFile() && filter.accept( child ) )
+ {
+ files.add( child );
+ }
+ else if ( child.isDirectory() )
+ {
+ roots.add( child );
}
}
}
diff --git a/bundleplugin/src/main/java/org/apache/felix/obrplugin/ObrInstall.java b/bundleplugin/src/main/java/org/apache/felix/obrplugin/ObrInstall.java
index 24fe99a..5f4039d 100644
--- a/bundleplugin/src/main/java/org/apache/felix/obrplugin/ObrInstall.java
+++ b/bundleplugin/src/main/java/org/apache/felix/obrplugin/ObrInstall.java
@@ -41,7 +41,7 @@
*
* @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
*/
-public final class ObrInstall extends AbstractMojo
+public final class ObrInstall extends AbstractMojo
{
/**
* OBR Repository.
diff --git a/bundleplugin/src/main/java/org/apache/felix/obrplugin/ObrUpdate.java b/bundleplugin/src/main/java/org/apache/felix/obrplugin/ObrUpdate.java
index 6c9fe01..00adea4 100644
--- a/bundleplugin/src/main/java/org/apache/felix/obrplugin/ObrUpdate.java
+++ b/bundleplugin/src/main/java/org/apache/felix/obrplugin/ObrUpdate.java
@@ -167,15 +167,15 @@
try
{
- m_resourceBundle = (ResourceImpl) new DataModelHelperImpl().createResource( bundleJar.toURL() );
- if (m_resourceBundle == null)
+ m_resourceBundle = ( ResourceImpl ) new DataModelHelperImpl().createResource( bundleJar.toURL() );
+ if ( m_resourceBundle == null )
{
return;
}
}
- catch (IOException e)
+ catch ( IOException e )
{
- throw new MojoExecutionException("Unable to load resource information", e);
+ throw new MojoExecutionException( "Unable to load resource information", e );
}
m_resourceBundle.put( Resource.SIZE, String.valueOf( bundleFile.length() ) );
@@ -202,11 +202,11 @@
String sourcePath = relativisePath( sourceJar );
String docPath = relativisePath( docJar );
-// m_resourceBundle.construct( m_project, bindexExtractor, sourcePath, docPath );
-// TODO: rebuild wrt m_project
+ // m_resourceBundle.construct( m_project, bindexExtractor, sourcePath, docPath );
+ // TODO: rebuild wrt m_project
m_repository.addResource( m_resourceBundle );
- m_repository.setLastModified(System.currentTimeMillis());
+ m_repository.setLastModified( System.currentTimeMillis() );
}
@@ -246,7 +246,7 @@
try
{
- new DataModelHelperImpl().writeRepository(m_repository, writer);
+ new DataModelHelperImpl().writeRepository( m_repository, writer );
}
catch ( IOException e )
{
@@ -271,11 +271,11 @@
}
- /**
- * Parse the repository descriptor file.
- *
- * @throws MojoExecutionException if the plugin failed
- */
+ /**
+ * Parse the repository descriptor file.
+ *
+ * @throws MojoExecutionException if the plugin failed
+ */
public void parseRepositoryXml() throws MojoExecutionException
{
File fout = new File( m_repositoryXml );
@@ -288,7 +288,7 @@
{
try
{
- m_repository = (RepositoryImpl) new DataModelHelperImpl().repository( m_repositoryXml.toURL() );
+ m_repository = ( RepositoryImpl ) new DataModelHelperImpl().repository( m_repositoryXml.toURL() );
}
catch ( Exception e )
{
@@ -301,54 +301,55 @@
/**
* put the information from obr.xml into ressourceBundle object.
*/
- private void parseObrXml() throws MojoExecutionException {
+ private void parseObrXml() throws MojoExecutionException
+ {
try
{
- InputStream is = new FileInputStream(new File(m_obrXml));
+ InputStream is = new FileInputStream( new File( m_obrXml ) );
try
{
KXmlParser kxp = new KXmlParser();
- kxp.setInput(is, null);
+ kxp.setInput( is, null );
kxp.nextTag(); // skip top level element
kxp.nextTag(); // go to first child element
- parseObrXml(kxp);
+ parseObrXml( kxp );
}
finally
{
is.close();
}
}
- catch (Exception e)
+ catch ( Exception e )
{
- throw new MojoExecutionException("Unable to parse obr xml: " + m_obrXml, e);
+ throw new MojoExecutionException( "Unable to parse obr xml: " + m_obrXml, e );
}
}
- private void parseObrXml(KXmlParser kxp) throws Exception
+
+ private void parseObrXml( KXmlParser kxp ) throws Exception
{
PullParser parser = new PullParser();
- while (kxp.getEventType() == XmlPullParser.START_TAG)
+ while ( kxp.getEventType() == XmlPullParser.START_TAG )
{
- if (RepositoryParser.CATEGORY.equals(kxp.getName()))
+ if ( RepositoryParser.CATEGORY.equals( kxp.getName() ) )
{
- m_resourceBundle.addCategory(parser.parseCategory(kxp));
+ m_resourceBundle.addCategory( parser.parseCategory( kxp ) );
}
- else if (RepositoryParser.REQUIRE.equals(kxp.getName()))
+ else if ( RepositoryParser.REQUIRE.equals( kxp.getName() ) )
{
- m_resourceBundle.addRequire(parser.parseRequire(kxp));
+ m_resourceBundle.addRequire( parser.parseRequire( kxp ) );
}
- else if (RepositoryParser.CAPABILITY.equals(kxp.getName()))
+ else if ( RepositoryParser.CAPABILITY.equals( kxp.getName() ) )
{
- m_resourceBundle.addCapability(parser.parseCapability(kxp));
+ m_resourceBundle.addCapability( parser.parseCapability( kxp ) );
}
else
{
kxp.nextTag();
- parseObrXml(kxp);
+ parseObrXml( kxp );
}
kxp.nextTag();
}
}
-
}
diff --git a/bundleplugin/src/main/java/org/apache/maven/shared/dependency/tree/DependencyTreeResolutionListener.java b/bundleplugin/src/main/java/org/apache/maven/shared/dependency/tree/DependencyTreeResolutionListener.java
index b03b914..cd3b3c3 100644
--- a/bundleplugin/src/main/java/org/apache/maven/shared/dependency/tree/DependencyTreeResolutionListener.java
+++ b/bundleplugin/src/main/java/org/apache/maven/shared/dependency/tree/DependencyTreeResolutionListener.java
@@ -1,5 +1,6 @@
package org.apache.maven.shared.dependency.tree;
+
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -34,6 +35,7 @@
import org.apache.maven.shared.dependency.tree.traversal.CollectingDependencyNodeVisitor;
import org.codehaus.plexus.logging.Logger;
+
/**
* An artifact resolution listener that constructs a dependency tree.
*
@@ -44,7 +46,7 @@
public class DependencyTreeResolutionListener implements ResolutionListener, ResolutionListenerForDepMgmt
{
// fields -----------------------------------------------------------------
-
+
/**
* The log to write debug messages to.
*/
@@ -69,7 +71,7 @@
* The dependency node currently being processed by this listener.
*/
private DependencyNode currentNode;
-
+
/**
* Map < String replacementId, String premanaged version >
*/
@@ -80,6 +82,7 @@
*/
private Map managedScopes = new HashMap();
+
// constructors -----------------------------------------------------------
/**
@@ -91,13 +94,14 @@
public DependencyTreeResolutionListener( Logger logger )
{
this.logger = logger;
-
+
parentNodes = new Stack();
nodesByArtifact = new IdentityHashMap();
rootNode = null;
currentNode = null;
}
+
// ResolutionListener methods ---------------------------------------------
/**
@@ -108,31 +112,33 @@
log( "testArtifact: artifact=" + artifact );
}
+
/**
* {@inheritDoc}
*/
public void startProcessChildren( Artifact artifact )
{
log( "startProcessChildren: artifact=" + artifact );
-
+
if ( !currentNode.getArtifact().equals( artifact ) )
{
throw new IllegalStateException( "Artifact was expected to be " + currentNode.getArtifact() + " but was "
- + artifact );
+ + artifact );
}
parentNodes.push( currentNode );
}
+
/**
* {@inheritDoc}
*/
public void endProcessChildren( Artifact artifact )
{
- DependencyNode node = (DependencyNode) parentNodes.pop();
+ DependencyNode node = ( DependencyNode ) parentNodes.pop();
log( "endProcessChildren: artifact=" + artifact );
-
+
if ( node == null )
{
throw new IllegalStateException( "Parent dependency node was null" );
@@ -141,17 +147,18 @@
if ( !node.getArtifact().equals( artifact ) )
{
throw new IllegalStateException( "Parent dependency node artifact was expected to be " + node.getArtifact()
- + " but was " + artifact );
+ + " but was " + artifact );
}
}
+
/**
* {@inheritDoc}
*/
public void includeArtifact( Artifact artifact )
{
log( "includeArtifact: artifact=" + artifact );
-
+
DependencyNode existingNode = getNode( artifact );
/*
@@ -170,18 +177,19 @@
}
}
+
/**
* {@inheritDoc}
*/
public void omitForNearer( Artifact omitted, Artifact kept )
{
log( "omitForNearer: omitted=" + omitted + " kept=" + kept );
-
+
if ( !omitted.getDependencyConflictId().equals( kept.getDependencyConflictId() ) )
{
throw new IllegalArgumentException( "Omitted artifact dependency conflict id "
- + omitted.getDependencyConflictId() + " differs from kept artifact dependency conflict id "
- + kept.getDependencyConflictId() );
+ + omitted.getDependencyConflictId() + " differs from kept artifact dependency conflict id "
+ + kept.getDependencyConflictId() );
}
if ( isCurrentNodeIncluded() )
@@ -200,15 +208,15 @@
}
omittedNode.omitForConflict( kept );
-
+
/*
* Add the dependency management information cached in any prior manageArtifact calls, since omitForNearer
* is always called after manageArtifact.
*/
flushDependencyManagement( omittedNode );
-
+
DependencyNode keptNode = getNode( kept );
-
+
if ( keptNode == null )
{
addNode( kept );
@@ -216,13 +224,14 @@
}
}
+
/**
* {@inheritDoc}
*/
public void updateScope( Artifact artifact, String scope )
{
log( "updateScope: artifact=" + artifact + ", scope=" + scope );
-
+
DependencyNode node = getNode( artifact );
if ( node == null )
@@ -234,33 +243,35 @@
node.setOriginalScope( artifact.getScope() );
}
+
/**
* {@inheritDoc}
*/
public void manageArtifact( Artifact artifact, Artifact replacement )
{
// TODO: remove when ResolutionListenerForDepMgmt merged into ResolutionListener
-
+
log( "manageArtifact: artifact=" + artifact + ", replacement=" + replacement );
-
+
if ( replacement.getVersion() != null )
{
manageArtifactVersion( artifact, replacement );
}
-
+
if ( replacement.getScope() != null )
{
manageArtifactScope( artifact, replacement );
}
}
+
/**
* {@inheritDoc}
*/
public void omitForCycle( Artifact artifact )
{
log( "omitForCycle: artifact=" + artifact );
-
+
if ( isCurrentNodeIncluded() )
{
DependencyNode node = createNode( artifact );
@@ -269,13 +280,14 @@
}
}
+
/**
* {@inheritDoc}
*/
public void updateScopeCurrentPom( Artifact artifact, String scopeIgnored )
{
log( "updateScopeCurrentPom: artifact=" + artifact + ", scopeIgnored=" + scopeIgnored );
-
+
DependencyNode node = getNode( artifact );
if ( node == null )
@@ -288,6 +300,7 @@
node.setFailedUpdateScope( scopeIgnored );
}
+
/**
* {@inheritDoc}
*/
@@ -309,25 +322,27 @@
node.setAvailableVersions( artifact.getAvailableVersions() );
}
+
/**
* {@inheritDoc}
*/
public void restrictRange( Artifact artifact, Artifact replacement, VersionRange versionRange )
{
log( "restrictRange: artifact=" + artifact + ", replacement=" + replacement + ", versionRange=" + versionRange );
-
+
// TODO: track range restriction in node (MNG-3093)
}
-
+
+
// ResolutionListenerForDepMgmt methods -----------------------------------
-
+
/**
* {@inheritDoc}
*/
public void manageArtifactVersion( Artifact artifact, Artifact replacement )
{
log( "manageArtifactVersion: artifact=" + artifact + ", replacement=" + replacement );
-
+
/*
* DefaultArtifactCollector calls manageArtifact twice: first with the change; then subsequently with no change.
* We ignore the second call when the versions are equal.
@@ -342,13 +357,14 @@
}
}
+
/**
* {@inheritDoc}
*/
public void manageArtifactScope( Artifact artifact, Artifact replacement )
{
log( "manageArtifactScope: artifact=" + artifact + ", replacement=" + replacement );
-
+
/*
* DefaultArtifactCollector calls manageArtifact twice: first with the change; then subsequently with no change.
* We ignore the second call when the scopes are equal.
@@ -362,7 +378,8 @@
managedScopes.put( getRangeId( replacement ), artifact.getScope() );
}
}
-
+
+
// public methods ---------------------------------------------------------
/**
@@ -376,6 +393,7 @@
return Collections.unmodifiableCollection( nodesByArtifact.values() );
}
+
/**
* Gets the root dependency node of the computed dependency tree.
*
@@ -386,8 +404,9 @@
return rootNode;
}
+
// private methods --------------------------------------------------------
-
+
/**
* Writes the specified message to the log at debug level with indentation for the current node's depth.
*
@@ -410,6 +429,7 @@
logger.debug( buffer.toString() );
}
+
/**
* Creates a new dependency node for the specified artifact and appends it to the current parent dependency node.
*
@@ -423,14 +443,15 @@
if ( !parentNodes.isEmpty() )
{
- DependencyNode parent = (DependencyNode) parentNodes.peek();
+ DependencyNode parent = ( DependencyNode ) parentNodes.peek();
parent.addChild( node );
}
return node;
}
-
+
+
/**
* Creates a new dependency node for the specified artifact, appends it to the current parent dependency node and
* puts it into the dependency node cache.
@@ -444,23 +465,24 @@
{
DependencyNode node = createNode( artifact );
- DependencyNode previousNode = (DependencyNode) nodesByArtifact.put( node.getArtifact(), node );
-
+ DependencyNode previousNode = ( DependencyNode ) nodesByArtifact.put( node.getArtifact(), node );
+
if ( previousNode != null )
{
throw new IllegalStateException( "Duplicate node registered for artifact: " + node.getArtifact() );
}
-
+
if ( rootNode == null )
{
rootNode = node;
}
currentNode = node;
-
+
return node;
}
+
/**
* Gets the dependency node for the specified artifact from the dependency node cache.
*
@@ -471,9 +493,10 @@
*/
private DependencyNode getNode( Artifact artifact )
{
- return (DependencyNode) nodesByArtifact.get( artifact );
+ return ( DependencyNode ) nodesByArtifact.get( artifact );
}
+
/**
* Removes the dependency node for the specified artifact from the dependency node cache.
*
@@ -482,15 +505,16 @@
*/
private void removeNode( Artifact artifact )
{
- DependencyNode node = (DependencyNode) nodesByArtifact.remove( artifact );
+ DependencyNode node = ( DependencyNode ) nodesByArtifact.remove( artifact );
if ( !artifact.equals( node.getArtifact() ) )
{
throw new IllegalStateException( "Removed dependency node artifact was expected to be " + artifact
- + " but was " + node.getArtifact() );
+ + " but was " + node.getArtifact() );
}
}
+
/**
* Gets whether the all the ancestors of the dependency node currently being processed by this listener have an
* included state.
@@ -504,7 +528,7 @@
for ( Iterator iterator = parentNodes.iterator(); included && iterator.hasNext(); )
{
- DependencyNode node = (DependencyNode) iterator.next();
+ DependencyNode node = ( DependencyNode ) iterator.next();
if ( node.getState() != DependencyNode.INCLUDED )
{
@@ -515,6 +539,7 @@
return included;
}
+
/**
* Updates the specified node with any dependency management information cached in prior <code>manageArtifact</code>
* calls.
@@ -525,26 +550,27 @@
private void flushDependencyManagement( DependencyNode node )
{
Artifact artifact = node.getArtifact();
- String premanagedVersion = (String) managedVersions.get( getRangeId( artifact ) );
- String premanagedScope = (String) managedScopes.get( getRangeId( artifact ) );
-
+ String premanagedVersion = ( String ) managedVersions.get( getRangeId( artifact ) );
+ String premanagedScope = ( String ) managedScopes.get( getRangeId( artifact ) );
+
if ( premanagedVersion != null || premanagedScope != null )
{
if ( premanagedVersion != null )
{
node.setPremanagedVersion( premanagedVersion );
}
-
+
if ( premanagedScope != null )
{
node.setPremanagedScope( premanagedScope );
}
-
+
premanagedVersion = null;
premanagedScope = null;
}
}
+
private static String getRangeId( Artifact artifact )
{
return artifact.getDependencyConflictId() + ":" + artifact.getVersionRange();
diff --git a/bundleplugin/src/main/java/org/apache/maven/shared/osgi/DefaultMaven2OsgiConverter.java b/bundleplugin/src/main/java/org/apache/maven/shared/osgi/DefaultMaven2OsgiConverter.java
index db45c43..a622d78 100644
--- a/bundleplugin/src/main/java/org/apache/maven/shared/osgi/DefaultMaven2OsgiConverter.java
+++ b/bundleplugin/src/main/java/org/apache/maven/shared/osgi/DefaultMaven2OsgiConverter.java
@@ -18,6 +18,7 @@
*/
package org.apache.maven.shared.osgi;
+
import java.io.File;
import java.io.IOException;
import java.util.Enumeration;
@@ -34,6 +35,7 @@
import aQute.lib.osgi.Analyzer;
+
/**
* Default implementation of {@link Maven2OsgiConverter}
*
@@ -42,17 +44,18 @@
* @author <a href="mailto:carlos@apache.org">Carlos Sanchez</a>
* @version $Id: DefaultMaven2OsgiConverter.java 661727 2008-05-30 14:21:49Z bentmann $
*/
-public class DefaultMaven2OsgiConverter
- implements Maven2OsgiConverter
+public class DefaultMaven2OsgiConverter implements Maven2OsgiConverter
{
private static final String FILE_SEPARATOR = System.getProperty( "file.separator" );
+
private String getBundleSymbolicName( String groupId, String artifactId )
{
return groupId + "." + artifactId;
}
+
/**
* Get the symbolic name as groupId + "." + artifactId, with the following exceptions
* <ul>
@@ -87,7 +90,7 @@
Iterator it = bundleSymbolicNameHeader.keySet().iterator();
if ( it.hasNext() )
{
- return (String) it.next();
+ return ( String ) it.next();
}
}
}
@@ -140,6 +143,7 @@
return getBundleSymbolicName( artifact.getGroupId(), artifact.getArtifactId() );
}
+
private String getGroupIdFromPackage( File artifactFile )
{
try
@@ -150,7 +154,7 @@
Enumeration entries = jar.entries();
while ( entries.hasMoreElements() )
{
- ZipEntry entry = (ZipEntry) entries.nextElement();
+ ZipEntry entry = ( ZipEntry ) entries.nextElement();
if ( entry.getName().endsWith( ".class" ) )
{
File f = new File( entry.getName() );
@@ -167,7 +171,7 @@
String[] groupIdSections = null;
for ( Iterator it = packageNames.iterator(); it.hasNext(); )
{
- String packageName = (String) it.next();
+ String packageName = ( String ) it.next();
String[] packageNameSections = packageName.split( "\\" + FILE_SEPARATOR );
if ( groupIdSections == null )
@@ -223,19 +227,22 @@
}
}
+
public String getBundleFileName( Artifact artifact )
{
return getBundleSymbolicName( artifact ) + "_" + getVersion( artifact.getVersion() ) + ".jar";
}
+
public String getVersion( Artifact artifact )
{
return getVersion( artifact.getVersion() );
}
+
public String getVersion( String version )
{
- return cleanupVersion(version);
+ return cleanupVersion( version );
}
/**
@@ -246,58 +253,78 @@
* @param VERSION_STRING
* @return
*/
- static final Pattern FUZZY_VERSION = Pattern.compile("(\\d+)(\\.(\\d+)(\\.(\\d+))?)?([^a-zA-Z0-9](.*))?",
- Pattern.DOTALL);
+ static final Pattern FUZZY_VERSION = Pattern.compile( "(\\d+)(\\.(\\d+)(\\.(\\d+))?)?([^a-zA-Z0-9](.*))?",
+ Pattern.DOTALL );
- static public String cleanupVersion(String version) {
+
+ static public String cleanupVersion( String version )
+ {
StringBuffer result = new StringBuffer();
- Matcher m = FUZZY_VERSION.matcher(version);
- if (m.matches()) {
- String major = m.group(1);
- String minor = m.group(3);
- String micro = m.group(5);
- String qualifier = m.group(7);
+ Matcher m = FUZZY_VERSION.matcher( version );
+ if ( m.matches() )
+ {
+ String major = m.group( 1 );
+ String minor = m.group( 3 );
+ String micro = m.group( 5 );
+ String qualifier = m.group( 7 );
- if (major != null) {
- result.append(major);
- if (minor != null) {
- result.append(".");
- result.append(minor);
- if (micro != null) {
- result.append(".");
- result.append(micro);
- if (qualifier != null) {
- result.append(".");
- cleanupModifier(result, qualifier);
+ if ( major != null )
+ {
+ result.append( major );
+ if ( minor != null )
+ {
+ result.append( "." );
+ result.append( minor );
+ if ( micro != null )
+ {
+ result.append( "." );
+ result.append( micro );
+ if ( qualifier != null )
+ {
+ result.append( "." );
+ cleanupModifier( result, qualifier );
}
- } else if (qualifier != null) {
- result.append(".0.");
- cleanupModifier(result, qualifier);
- } else {
- result.append(".0");
}
- } else if (qualifier != null) {
- result.append(".0.0.");
- cleanupModifier(result, qualifier);
- } else {
- result.append(".0.0");
+ else if ( qualifier != null )
+ {
+ result.append( ".0." );
+ cleanupModifier( result, qualifier );
+ }
+ else
+ {
+ result.append( ".0" );
+ }
+ }
+ else if ( qualifier != null )
+ {
+ result.append( ".0.0." );
+ cleanupModifier( result, qualifier );
+ }
+ else
+ {
+ result.append( ".0.0" );
}
}
- } else {
- result.append("0.0.0.");
- cleanupModifier(result, version);
+ }
+ else
+ {
+ result.append( "0.0.0." );
+ cleanupModifier( result, version );
}
return result.toString();
}
- static void cleanupModifier(StringBuffer result, String modifier) {
- for (int i = 0; i < modifier.length(); i++) {
- char c = modifier.charAt(i);
- if ((c >= '0' && c <= '9') || (c >= 'a' && c <= 'z')
- || (c >= 'A' && c <= 'Z') || c == '_' || c == '-')
- result.append(c);
+
+ static void cleanupModifier( StringBuffer result, String modifier )
+ {
+ for ( int i = 0; i < modifier.length(); i++ )
+ {
+ char c = modifier.charAt( i );
+ if ( ( c >= '0' && c <= '9' ) || ( c >= 'a' && c <= 'z' ) || ( c >= 'A' && c <= 'Z' ) || c == '_'
+ || c == '-' )
+ result.append( c );
else
- result.append('_');
+ result.append( '_' );
}
}
diff --git a/bundleplugin/src/main/java/org/apache/maven/shared/osgi/ManifestReadingException.java b/bundleplugin/src/main/java/org/apache/maven/shared/osgi/ManifestReadingException.java
index 38483d8..433cc80 100644
--- a/bundleplugin/src/main/java/org/apache/maven/shared/osgi/ManifestReadingException.java
+++ b/bundleplugin/src/main/java/org/apache/maven/shared/osgi/ManifestReadingException.java
@@ -18,14 +18,14 @@
*/
package org.apache.maven.shared.osgi;
+
/**
* Exception while reading the manifest. Encapsulates an IOException to make it runtime
*
* @author <a href="mailto:carlos@apache.org">Carlos Sanchez</a>
* @version $Id: ManifestReadingException.java 661727 2008-05-30 14:21:49Z bentmann $
*/
-public class ManifestReadingException
- extends RuntimeException
+public class ManifestReadingException extends RuntimeException
{
public ManifestReadingException()
@@ -33,16 +33,19 @@
super();
}
+
public ManifestReadingException( String message, Throwable cause )
{
super( message, cause );
}
+
public ManifestReadingException( String message )
{
super( message );
}
+
public ManifestReadingException( Throwable cause )
{
super( cause );
diff --git a/bundleplugin/src/main/java/org/apache/maven/shared/osgi/Maven2OsgiConverter.java b/bundleplugin/src/main/java/org/apache/maven/shared/osgi/Maven2OsgiConverter.java
index eec6cc5..a843920 100644
--- a/bundleplugin/src/main/java/org/apache/maven/shared/osgi/Maven2OsgiConverter.java
+++ b/bundleplugin/src/main/java/org/apache/maven/shared/osgi/Maven2OsgiConverter.java
@@ -18,8 +18,10 @@
*/
package org.apache.maven.shared.osgi;
+
import org.apache.maven.artifact.Artifact;
+
/**
* Converter from Maven groupId,artifactId and versions to OSGi Bundle-SymbolicName and version
*
@@ -37,8 +39,10 @@
*/
String getBundleSymbolicName( Artifact artifact );
+
String getBundleFileName( Artifact artifact );
+
/**
* Convert a Maven version into an OSGi compliant version
*
@@ -47,6 +51,7 @@
*/
String getVersion( Artifact artifact );
+
/**
* Convert a Maven version into an OSGi compliant version
*
diff --git a/bundleplugin/src/test/java/org/apache/felix/bundleplugin/BlueprintComponentTest.java b/bundleplugin/src/test/java/org/apache/felix/bundleplugin/BlueprintComponentTest.java
index 17d2d44..b62083e 100644
--- a/bundleplugin/src/test/java/org/apache/felix/bundleplugin/BlueprintComponentTest.java
+++ b/bundleplugin/src/test/java/org/apache/felix/bundleplugin/BlueprintComponentTest.java
@@ -18,6 +18,7 @@
*/
package org.apache.felix.bundleplugin;
+
import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
@@ -27,70 +28,81 @@
import java.util.Properties;
import java.util.jar.Manifest;
-import aQute.lib.osgi.Builder;
import junit.framework.TestCase;
-import org.apache.felix.bundleplugin.ManifestPlugin;
+
import org.apache.maven.model.Resource;
import org.apache.maven.plugin.testing.stubs.MavenProjectStub;
import org.osgi.framework.Constants;
-public class BlueprintComponentTest extends TestCase {
+import aQute.lib.osgi.Builder;
+
+
+public class BlueprintComponentTest extends TestCase
+{
public void testBlueprint() throws Exception
{
- MavenProjectStub project = new MavenProjectStub() {
+ MavenProjectStub project = new MavenProjectStub()
+ {
private final List resources = new ArrayList();
- @Override
- public void addResource(Resource resource) {
- resources.add(resource);
- }
+
@Override
- public List getResources() {
+ public void addResource( Resource resource )
+ {
+ resources.add( resource );
+ }
+
+
+ @Override
+ public List getResources()
+ {
return resources;
}
+
@Override
public File getBasedir()
{
- return new File("target/tmp/basedir");
+ return new File( "target/tmp/basedir" );
}
};
project.setGroupId( "group" );
project.setArtifactId( "artifact" );
project.setVersion( "1.1.0.0" );
Resource r = new Resource();
- r.setDirectory(new File("src/test/resources").getAbsoluteFile().getCanonicalPath());
- r.setIncludes(Arrays.asList("**/*.*"));
- project.addResource(r);
- project.addCompileSourceRoot(new File("src/test/resources").getAbsoluteFile().getCanonicalPath());
+ r.setDirectory( new File( "src/test/resources" ).getAbsoluteFile().getCanonicalPath() );
+ r.setIncludes( Arrays.asList( "**/*.*" ) );
+ project.addResource( r );
+ project.addCompileSourceRoot( new File( "src/test/resources" ).getAbsoluteFile().getCanonicalPath() );
ManifestPlugin plugin = new ManifestPlugin();
- plugin.setBuildDirectory("target/tmp/basedir/target");
- plugin.setOutputDirectory(new File("target/tmp/basedir/target/classes"));
+ plugin.setBuildDirectory( "target/tmp/basedir/target" );
+ plugin.setOutputDirectory( new File( "target/tmp/basedir/target/classes" ) );
Map instructions = new HashMap();
- instructions.put("Test", "Foo");
+ instructions.put( "Test", "Foo" );
- instructions.put("nsh_interface", "foo.bar.Namespace");
- instructions.put("nsh_namespace", "ns");
+ instructions.put( "nsh_interface", "foo.bar.Namespace" );
+ instructions.put( "nsh_namespace", "ns" );
- instructions.put("Export-Service", "p7.Foo;mk=mv");
- instructions.put("Import-Service", "org.osgi.service.cm.ConfigurationAdmin;availability:=optional");
+ instructions.put( "Export-Service", "p7.Foo;mk=mv" );
+ instructions.put( "Import-Service", "org.osgi.service.cm.ConfigurationAdmin;availability:=optional" );
Properties props = new Properties();
- Builder builder = plugin.buildOSGiBundle(project, instructions, props, plugin.getClasspath(project));
+ Builder builder = plugin.buildOSGiBundle( project, instructions, props, plugin.getClasspath( project ) );
Manifest manifest = builder.getJar().getManifest();
- String expSvc = manifest.getMainAttributes().getValue(Constants.EXPORT_SERVICE);
- String impSvc = manifest.getMainAttributes().getValue(Constants.IMPORT_SERVICE);
- assertNotNull(expSvc);
- assertNotNull(impSvc);
+ String expSvc = manifest.getMainAttributes().getValue( Constants.EXPORT_SERVICE );
+ String impSvc = manifest.getMainAttributes().getValue( Constants.IMPORT_SERVICE );
+ assertNotNull( expSvc );
+ assertNotNull( impSvc );
- String impPkg = manifest.getMainAttributes().getValue(Constants.IMPORT_PACKAGE);
- List<String> pkgs = Arrays.asList(impPkg.split(","));
- for (int i = 1; i <= 13; i++) {
- assertTrue(pkgs.contains("p" + i));
+ String impPkg = manifest.getMainAttributes().getValue( Constants.IMPORT_PACKAGE );
+ List<String> pkgs = Arrays.asList( impPkg.split( "," ) );
+ for ( int i = 1; i <= 13; i++ )
+ {
+ assertTrue( pkgs.contains( "p" + i ) );
}
}
diff --git a/bundleplugin/src/test/java/org/apache/felix/bundleplugin/BundleAllPluginTest.java b/bundleplugin/src/test/java/org/apache/felix/bundleplugin/BundleAllPluginTest.java
index 253725c..d26483d 100644
--- a/bundleplugin/src/test/java/org/apache/felix/bundleplugin/BundleAllPluginTest.java
+++ b/bundleplugin/src/test/java/org/apache/felix/bundleplugin/BundleAllPluginTest.java
@@ -114,8 +114,8 @@
exports.containsKey( packages[i] ) );
}
- assertFalse( "Bundle info contains a package that it is not exported in the manifest", exports
- .containsKey( "org.apache.maven.model.io.xpp3" ) );
+ assertFalse( "Bundle info contains a package that it is not exported in the manifest",
+ exports.containsKey( "org.apache.maven.model.io.xpp3" ) );
}
// public void testRewriting()
diff --git a/bundleplugin/src/test/java/org/apache/felix/bundleplugin/BundlePluginTest.java b/bundleplugin/src/test/java/org/apache/felix/bundleplugin/BundlePluginTest.java
index bcafd68..773ab1c 100644
--- a/bundleplugin/src/test/java/org/apache/felix/bundleplugin/BundlePluginTest.java
+++ b/bundleplugin/src/test/java/org/apache/felix/bundleplugin/BundlePluginTest.java
@@ -22,13 +22,13 @@
import java.io.File;
import java.util.Map;
-import java.util.TreeMap;
import java.util.Properties;
+import java.util.TreeMap;
+import org.apache.maven.model.Organization;
import org.apache.maven.plugin.testing.stubs.MavenProjectStub;
import org.apache.maven.project.MavenProject;
import org.apache.maven.shared.osgi.DefaultMaven2OsgiConverter;
-import org.apache.maven.model.Organization;
import aQute.lib.osgi.Analyzer;
import aQute.lib.osgi.Builder;
@@ -112,7 +112,7 @@
project.setArtifactId( "artifact" );
project.setVersion( "1.1.0.0" );
-// PackageVersionAnalyzer analyzer = new PackageVersionAnalyzer();
+ // PackageVersionAnalyzer analyzer = new PackageVersionAnalyzer();
Builder analyzer = new Builder();
Jar jar = new Jar( "name", osgiBundleFile );
analyzer.setJar( jar );
@@ -165,6 +165,7 @@
assertEquals( "", transformedInstructions.get( "-z" ) );
}
+
public void testDefaultPropertiesIncludeOrganization()
{
final Organization organization = new Organization();
@@ -174,7 +175,8 @@
// MavenProjectStub.setOrganization(Organization) doesn't do anything, so we have to make it work this way
MavenProject project = new MavenProjectStub()
{
- @Override public Organization getOrganization()
+ @Override
+ public Organization getOrganization()
{
return organization;
}
@@ -190,12 +192,14 @@
assertEquals( organization.getUrl(), properties.getProperty( "pom.organization.url" ) );
}
+
public void testVersion() throws Exception
{
String cleanupVersion = Builder.cleanupVersion( "0.0.0.4aug2000r7-dev" );
assertEquals( "0.0.0.4aug2000r7-dev", cleanupVersion );
}
-
+
+
public void testPackageInfoDetection() throws Exception
{
MavenProject project = new MavenProjectStub();
@@ -203,7 +207,7 @@
String resourcePaths = plugin.getMavenResourcePaths( project );
- assertEquals( "org/apache/felix/bundleplugin/packageinfo=" +
- "src/test/java/org/apache/felix/bundleplugin/packageinfo", resourcePaths );
+ assertEquals( "org/apache/felix/bundleplugin/packageinfo="
+ + "src/test/java/org/apache/felix/bundleplugin/packageinfo", resourcePaths );
}
}