Apply Felix formatting
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@616179 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/bundleplugin/src/main/java/org/apache/felix/bundleplugin/BundleAllPlugin.java b/bundleplugin/src/main/java/org/apache/felix/bundleplugin/BundleAllPlugin.java
index c7ec59b..d9b49e7 100644
--- a/bundleplugin/src/main/java/org/apache/felix/bundleplugin/BundleAllPlugin.java
+++ b/bundleplugin/src/main/java/org/apache/felix/bundleplugin/BundleAllPlugin.java
@@ -18,6 +18,7 @@
*/
package org.apache.felix.bundleplugin;
+
import java.io.File;
import java.io.FilenameFilter;
import java.io.IOException;
@@ -54,6 +55,7 @@
import aQute.lib.osgi.Analyzer;
import aQute.lib.osgi.Jar;
+
/**
* Create OSGi bundles from all dependencies in the Maven project
*
@@ -62,8 +64,7 @@
* @requiresDependencyResolution runtime
* @description build an OSGi bundle jar for all transitive dependencies
*/
-public class BundleAllPlugin
- extends ManifestPlugin
+public class BundleAllPlugin extends ManifestPlugin
{
private static final String LS = System.getProperty( "line.separator" );
@@ -128,27 +129,28 @@
*/
private boolean ignoreMissingArtifacts;
- private Set artifactsBeingProcessed = new HashSet();
+ private Set artifactsBeingProcessed = new HashSet();
- public void execute()
- throws MojoExecutionException
+
+ public void execute() throws MojoExecutionException
{
BundleInfo bundleInfo = bundleAll( getProject() );
logDuplicatedPackages( bundleInfo );
}
+
/**
* Bundle a project and all its dependencies
*
* @param project
* @throws MojoExecutionException
*/
- private BundleInfo bundleAll( MavenProject project )
- throws MojoExecutionException
+ private BundleInfo bundleAll( MavenProject project ) throws MojoExecutionException
{
return bundleAll( project, Integer.MAX_VALUE );
}
+
/**
* Bundle a project and its transitive dependencies up to some depth level
*
@@ -156,8 +158,7 @@
* @param depth how deep to process the dependency tree
* @throws MojoExecutionException
*/
- protected BundleInfo bundleAll( MavenProject project, int depth )
- throws MojoExecutionException
+ protected BundleInfo bundleAll( MavenProject project, int depth ) throws MojoExecutionException
{
if ( alreadyBundled( project.getArtifact() ) )
@@ -178,7 +179,7 @@
try
{
dependencyTree = dependencyTreeBuilder.buildDependencyTree( project, localRepository, factory,
- artifactMetadataSource, null, collector );
+ artifactMetadataSource, null, collector );
}
catch ( DependencyTreeBuilderException e )
{
@@ -197,7 +198,7 @@
for ( Iterator it = dependencyTree.inverseIterator(); it.hasNext(); )
{
- DependencyNode node = (DependencyNode) it.next();
+ DependencyNode node = ( DependencyNode ) it.next();
if ( !it.hasNext() )
{
/* this is the root, current project */
@@ -238,7 +239,8 @@
if ( nodeDepth > depth )
{
/* node is deeper than we want */
- getLog().debug( "Ignoring " + node.getArtifact() + ", depth is " + nodeDepth + ", bigger than " + depth );
+ getLog()
+ .debug( "Ignoring " + node.getArtifact() + ", depth is " + nodeDepth + ", bigger than " + depth );
continue;
}
@@ -246,7 +248,7 @@
try
{
childProject = mavenProjectBuilder.buildFromRepository( artifact, remoteRepositories, localRepository,
- true );
+ true );
if ( childProject.getDependencyArtifacts() == null )
{
childProject.setDependencyArtifacts( childProject.createArtifacts( factory, null, null ) );
@@ -276,14 +278,15 @@
else
{
getLog().debug(
- "Not processing due to scope (" + childProject.getArtifact().getScope() + "): "
- + childProject.getArtifact() );
+ "Not processing due to scope (" + childProject.getArtifact().getScope() + "): "
+ + childProject.getArtifact() );
}
}
return bundleRoot( project, bundleInfo );
}
+
/**
* Bundle the root of a dependency tree after all its children have been bundled
*
@@ -292,8 +295,7 @@
* @return
* @throws MojoExecutionException
*/
- private BundleInfo bundleRoot( MavenProject project, BundleInfo bundleInfo )
- throws MojoExecutionException
+ private BundleInfo bundleRoot( MavenProject project, BundleInfo bundleInfo ) throws MojoExecutionException
{
/* do not bundle the project the mojo was called on */
if ( getProject() != project )
@@ -309,14 +311,14 @@
return bundleInfo;
}
+
/**
* Bundle one project only without building its childre
*
* @param project
* @throws MojoExecutionException
*/
- BundleInfo bundle( MavenProject project )
- throws MojoExecutionException
+ BundleInfo bundle( MavenProject project ) throws MojoExecutionException
{
Artifact artifact = project.getArtifact();
getLog().info( "Bundling " + artifact );
@@ -349,8 +351,8 @@
{
/* if it is already an OSGi jar copy it as is */
getLog().info(
- "Using existing OSGi bundle for " + project.getGroupId() + ":" + project.getArtifactId()
- + ":" + project.getVersion() );
+ "Using existing OSGi bundle for " + project.getGroupId() + ":" + project.getArtifactId() + ":"
+ + project.getVersion() );
String exportHeader = osgiJar.getManifest().getMainAttributes().getValue( Analyzer.EXPORT_PACKAGE );
exportedPackages = analyzer.parseHeader( exportHeader ).keySet();
}
@@ -377,8 +379,8 @@
}
}
- private boolean isOsgi( Jar jar )
- throws IOException
+
+ private boolean isOsgi( Jar jar ) throws IOException
{
if ( jar.getManifest() != null )
{
@@ -387,37 +389,43 @@
return false;
}
+
private BundleInfo addExportedPackages( MavenProject project, Collection packages )
{
BundleInfo bundleInfo = new BundleInfo();
for ( Iterator it = packages.iterator(); it.hasNext(); )
{
- String packageName = (String) it.next();
+ String packageName = ( String ) it.next();
bundleInfo.addExportedPackage( packageName, project.getArtifact() );
}
return bundleInfo;
}
+
private String getArtifactKey( Artifact artifact )
{
return artifact.getGroupId() + ":" + artifact.getArtifactId();
}
+
protected String getBundleName( MavenProject project )
{
return getBundleName( project.getArtifact() );
}
+
private String getBundleName( Artifact artifact )
{
return getMaven2OsgiConverter().getBundleFileName( artifact );
}
+
private boolean alreadyBundled( Artifact artifact )
{
return getBuiltFile( artifact ) != null;
}
+
/**
* Use previously built bundles when available.
*
@@ -435,6 +443,7 @@
return super.getFile( artifact );
}
+
private File getBuiltFile( final Artifact artifact )
{
File bundle = null;
@@ -482,6 +491,7 @@
return bundle;
}
+
/**
* Check that the bundleName provided correspond to the artifact provided.
* Used to determine when the bundle name is a timestamped snapshot and the artifact is a snapshot not timestamped.
@@ -510,13 +520,14 @@
return false;
}
+
protected File getOutputFile( Artifact artifact )
{
return new File( getOutputDirectory(), getBundleName( artifact ) );
}
- private Artifact resolveArtifact( Artifact artifact )
- throws MojoExecutionException, ArtifactNotFoundException
+
+ private Artifact resolveArtifact( Artifact artifact ) throws MojoExecutionException, ArtifactNotFoundException
{
VersionRange versionRange;
if ( artifact.getVersion() != null )
@@ -534,8 +545,7 @@
* the extra null parameter
*/
Artifact resolvedArtifact = factory.createDependencyArtifact( artifact.getGroupId(), artifact.getArtifactId(),
- versionRange, artifact.getType(), artifact
- .getClassifier(), artifact.getScope(), null );
+ versionRange, artifact.getType(), artifact.getClassifier(), artifact.getScope(), null );
try
{
@@ -549,6 +559,7 @@
return resolvedArtifact;
}
+
/**
* Log what packages are exported in more than one bundle
*/
@@ -558,14 +569,14 @@
for ( Iterator it = duplicatedExports.entrySet().iterator(); it.hasNext(); )
{
- Map.Entry entry = (Map.Entry) it.next();
- String packageName = (String) entry.getKey();
- Collection artifacts = (Collection) entry.getValue();
+ Map.Entry entry = ( Map.Entry ) it.next();
+ String packageName = ( String ) entry.getKey();
+ Collection artifacts = ( Collection ) entry.getValue();
getLog().warn( "Package " + packageName + " is exported in more than a bundle: " );
for ( Iterator it2 = artifacts.iterator(); it2.hasNext(); )
{
- Artifact artifact = (Artifact) it2.next();
+ Artifact artifact = ( Artifact ) it2.next();
getLog().warn( " " + artifact );
}
diff --git a/bundleplugin/src/main/java/org/apache/felix/bundleplugin/BundleInfo.java b/bundleplugin/src/main/java/org/apache/felix/bundleplugin/BundleInfo.java
index 26538a4..42f83b5 100644
--- a/bundleplugin/src/main/java/org/apache/felix/bundleplugin/BundleInfo.java
+++ b/bundleplugin/src/main/java/org/apache/felix/bundleplugin/BundleInfo.java
@@ -14,6 +14,7 @@
*/
package org.apache.felix.bundleplugin;
+
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
@@ -23,6 +24,7 @@
import org.apache.maven.artifact.Artifact;
+
/**
* Information result of the bundling process
*
@@ -38,9 +40,10 @@
*/
private Map exportedPackages = new HashMap();
+
public void addExportedPackage( String packageName, Artifact artifact )
{
- Set artifacts = (Set) getExportedPackages().get( packageName );
+ Set artifacts = ( Set ) getExportedPackages().get( packageName );
if ( artifacts == null )
{
artifacts = new HashSet();
@@ -49,11 +52,13 @@
artifacts.add( artifact );
}
+
Map getExportedPackages()
{
return exportedPackages;
}
+
/**
* Get a list of packages that are exported in more than one bundle.
* Key is package name and value list of artifacts where it's exported.
@@ -65,17 +70,17 @@
for ( Iterator it = getExportedPackages().entrySet().iterator(); it.hasNext(); )
{
- Map.Entry entry = (Map.Entry) it.next();
- Set artifacts = (Set) entry.getValue();
+ Map.Entry entry = ( Map.Entry ) it.next();
+ Set artifacts = ( Set ) entry.getValue();
if ( artifacts.size() > 1 )
{
/* remove warnings caused by different versions of same artifact */
Set artifactKeys = new HashSet();
- String packageName = (String) entry.getKey();
+ String packageName = ( String ) entry.getKey();
for ( Iterator it2 = artifacts.iterator(); it2.hasNext(); )
{
- Artifact artifact = (Artifact) it2.next();
+ Artifact artifact = ( Artifact ) it2.next();
artifactKeys.add( artifact.getGroupId() + "." + artifact.getArtifactId() );
}
@@ -89,15 +94,16 @@
return duplicatedExports;
}
+
public void merge( BundleInfo bundleInfo )
{
for ( Iterator it = bundleInfo.getExportedPackages().entrySet().iterator(); it.hasNext(); )
{
- Map.Entry entry = (Map.Entry) it.next();
- String packageName = (String) entry.getKey();
- Collection artifacts = (Collection) entry.getValue();
+ Map.Entry entry = ( Map.Entry ) it.next();
+ String packageName = ( String ) entry.getKey();
+ Collection artifacts = ( Collection ) entry.getValue();
- Collection artifactsWithPackage = (Collection) getExportedPackages().get( packageName );
+ Collection artifactsWithPackage = ( Collection ) getExportedPackages().get( packageName );
if ( artifactsWithPackage == null )
{
artifactsWithPackage = new HashSet();
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 71f957c..2ddda68 100644
--- a/bundleplugin/src/main/java/org/apache/felix/bundleplugin/BundlePlugin.java
+++ b/bundleplugin/src/main/java/org/apache/felix/bundleplugin/BundlePlugin.java
@@ -18,6 +18,7 @@
*/
package org.apache.felix.bundleplugin;
+
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
@@ -61,6 +62,7 @@
import aQute.lib.osgi.FileResource;
import aQute.lib.osgi.Jar;
+
/**
* Create an OSGi bundle from Maven project
*
@@ -69,7 +71,8 @@
* @requiresDependencyResolution runtime
* @description build an OSGi bundle jar
*/
-public class BundlePlugin extends AbstractMojo {
+public class BundlePlugin extends AbstractMojo
+{
/**
* Directory where the manifest will be written
@@ -107,7 +110,8 @@
*
* @parameter
*/
- private List supportedProjectTypes = Arrays.asList(new String[]{"jar","bundle"});
+ private List supportedProjectTypes = Arrays.asList( new String[]
+ { "jar", "bundle" } );
/**
* The directory for the generated bundles.
@@ -123,7 +127,7 @@
* @parameter expression="${basedir}"
* @required
*/
- private File baseDir;
+ private File baseDir;
/**
* The directory for the generated JAR.
@@ -131,7 +135,7 @@
* @parameter expression="${project.build.directory}"
* @required
*/
- private String buildDirectory;
+ private String buildDirectory;
/**
* The Maven project.
@@ -147,7 +151,7 @@
*
* @parameter
*/
- private Map instructions = new HashMap();
+ private Map instructions = new HashMap();
/**
* @component
@@ -156,8 +160,10 @@
private static final String MAVEN_RESOURCES = "{maven-resources}";
private static final String MAVEN_RESOURCES_REGEX = "\\{maven-resources\\}";
- private static final String[] EMPTY_STRING_ARRAY = {};
- private static final String[] DEFAULT_INCLUDES = {"**/**"};
+ private static final String[] EMPTY_STRING_ARRAY =
+ {};
+ private static final String[] DEFAULT_INCLUDES =
+ { "**/**" };
protected Maven2OsgiConverter getMaven2OsgiConverter()
@@ -165,16 +171,19 @@
return this.maven2OsgiConverter;
}
- void setMaven2OsgiConverter(Maven2OsgiConverter maven2OsgiConverter)
+
+ void setMaven2OsgiConverter( Maven2OsgiConverter maven2OsgiConverter )
{
this.maven2OsgiConverter = maven2OsgiConverter;
}
+
protected MavenProject getProject()
{
return this.project;
}
+
/**
* @see org.apache.maven.plugin.AbstractMojo#execute()
*/
@@ -183,81 +192,86 @@
Properties properties = new Properties();
// ignore project types not supported, useful when the plugin is configured in the parent pom
- if (!this.supportedProjectTypes.contains(this.getProject().getArtifact().getType()))
+ if ( !this.supportedProjectTypes.contains( this.getProject().getArtifact().getType() ) )
{
- this.getLog().debug("Ignoring project " + this.getProject().getArtifact() + " : type " + this.getProject().getArtifact().getType() +
- " is not supported by bundle plugin, supported types are " + this.supportedProjectTypes );
+ this.getLog().debug(
+ "Ignoring project " + this.getProject().getArtifact() + " : type "
+ + this.getProject().getArtifact().getType()
+ + " is not supported by bundle plugin, supported types are " + this.supportedProjectTypes );
return;
}
- this.execute(this.project, this.instructions, properties);
+ this.execute( this.project, this.instructions, properties );
}
- protected void execute(MavenProject project, Map instructions, Properties properties)
- throws MojoExecutionException
+
+ protected void execute( MavenProject project, Map instructions, Properties properties )
+ throws MojoExecutionException
{
try
{
- this.execute(project, instructions, properties, this.getClasspath(project));
+ this.execute( project, instructions, properties, this.getClasspath( project ) );
}
catch ( IOException e )
{
- throw new MojoExecutionException("Error calculating classpath for project " + project, e);
+ throw new MojoExecutionException( "Error calculating classpath for project " + project, e );
}
}
+
/* transform directives from their XML form to the expected BND syntax (eg. _include becomes -include) */
- protected Map transformDirectives(Map instructions)
+ protected Map transformDirectives( Map instructions )
{
Map transformedInstructions = new HashMap();
- for (Iterator i = instructions.entrySet().iterator(); i.hasNext();)
+ for ( Iterator i = instructions.entrySet().iterator(); i.hasNext(); )
{
- Map.Entry e = (Map.Entry)i.next();
+ Map.Entry e = ( Map.Entry ) i.next();
- String key = (String)e.getKey();
- if (key.startsWith("_"))
+ String key = ( String ) e.getKey();
+ if ( key.startsWith( "_" ) )
{
- key = "-"+key.substring(1);
+ key = "-" + key.substring( 1 );
}
- String value = (String)e.getValue();
- if (null == value)
+ String value = ( String ) e.getValue();
+ if ( null == value )
{
value = "";
}
else
{
- value = value.replaceAll("[\r\n]", "");
+ value = value.replaceAll( "[\r\n]", "" );
}
- transformedInstructions.put(key, value);
+ transformedInstructions.put( key, value );
}
return transformedInstructions;
}
- protected void execute(MavenProject project, Map instructions, Properties properties, Jar[] classpath)
- throws MojoExecutionException
+
+ protected void execute( MavenProject project, Map instructions, Properties properties, Jar[] classpath )
+ throws MojoExecutionException
{
try
{
- File jarFile = new File(this.getBuildDirectory(), this.getBundleName(project));
+ File jarFile = new File( this.getBuildDirectory(), this.getBundleName( project ) );
- properties.putAll(this.getDefaultProperties(project));
+ properties.putAll( this.getDefaultProperties( project ) );
String bsn = project.getGroupId() + "." + project.getArtifactId();
- if (!instructions.containsKey(Analyzer.PRIVATE_PACKAGE))
+ if ( !instructions.containsKey( Analyzer.PRIVATE_PACKAGE ) )
{
- properties.put(Analyzer.EXPORT_PACKAGE, bsn + ".*");
+ properties.put( Analyzer.EXPORT_PACKAGE, bsn + ".*" );
}
- properties.putAll(this.transformDirectives(instructions));
+ properties.putAll( this.transformDirectives( instructions ) );
// pass maven resource paths onto BND analyzer
- final String mavenResourcePaths = this.getMavenResourcePaths(project);
- final String includeResource = (String)properties.get(Analyzer.INCLUDE_RESOURCE);
- if (includeResource != null)
+ final String mavenResourcePaths = this.getMavenResourcePaths( project );
+ final String includeResource = ( String ) properties.get( Analyzer.INCLUDE_RESOURCE );
+ if ( includeResource != null )
{
- if (includeResource.indexOf(MAVEN_RESOURCES) >= 0)
+ if ( includeResource.indexOf( MAVEN_RESOURCES ) >= 0 )
{
// if there is no maven resource path, we do a special treatment and replace
// every occurance of MAVEN_RESOURCES and a following comma with an empty string
@@ -266,69 +280,71 @@
String cleanedResource = removeMavenResourcesTag( includeResource );
if ( cleanedResource.length() > 0 )
{
- properties.put(Analyzer.INCLUDE_RESOURCE, cleanedResource);
+ properties.put( Analyzer.INCLUDE_RESOURCE, cleanedResource );
}
else
{
- properties.remove(Analyzer.INCLUDE_RESOURCE);
+ properties.remove( Analyzer.INCLUDE_RESOURCE );
}
}
else
{
- String combinedResource = includeResource.replaceAll(MAVEN_RESOURCES_REGEX, mavenResourcePaths);
- properties.put(Analyzer.INCLUDE_RESOURCE, combinedResource);
+ String combinedResource = includeResource
+ .replaceAll( MAVEN_RESOURCES_REGEX, mavenResourcePaths );
+ properties.put( Analyzer.INCLUDE_RESOURCE, combinedResource );
}
}
else if ( mavenResourcePaths.length() > 0 )
{
- this.getLog().warn(Analyzer.INCLUDE_RESOURCE + ": overriding " + mavenResourcePaths + " with " +
- includeResource + " (add " + MAVEN_RESOURCES + " if you want to include the maven resources)");
+ this.getLog().warn(
+ Analyzer.INCLUDE_RESOURCE + ": overriding " + mavenResourcePaths + " with " + includeResource
+ + " (add " + MAVEN_RESOURCES + " if you want to include the maven resources)" );
}
}
- else if (mavenResourcePaths.length() > 0 )
+ else if ( mavenResourcePaths.length() > 0 )
{
- properties.put(Analyzer.INCLUDE_RESOURCE, mavenResourcePaths);
+ properties.put( Analyzer.INCLUDE_RESOURCE, mavenResourcePaths );
}
Builder builder = new Builder();
- builder.setBase(project.getBasedir());
- builder.setProperties(properties);
- builder.setClasspath(classpath);
+ builder.setBase( project.getBasedir() );
+ builder.setProperties( properties );
+ builder.setClasspath( classpath );
- Collection embeddableArtifacts = getEmbeddableArtifacts(project, properties);
- if (embeddableArtifacts.size() > 0)
+ Collection embeddableArtifacts = getEmbeddableArtifacts( project, properties );
+ if ( embeddableArtifacts.size() > 0 )
{
// add BND instructions to embed selected dependencies
- new DependencyEmbedder(embeddableArtifacts).processHeaders(properties);
+ new DependencyEmbedder( embeddableArtifacts ).processHeaders( properties );
}
builder.build();
Jar jar = builder.getJar();
- this.doMavenMetadata(project, jar);
- builder.setJar(jar);
+ this.doMavenMetadata( project, jar );
+ builder.setJar( jar );
List errors = builder.getErrors();
List warnings = builder.getWarnings();
- for (Iterator w = warnings.iterator(); w.hasNext();)
+ for ( Iterator w = warnings.iterator(); w.hasNext(); )
{
- String msg = (String) w.next();
- this.getLog().warn("Warning building bundle " + project.getArtifact() + " : " + msg);
+ String msg = ( String ) w.next();
+ this.getLog().warn( "Warning building bundle " + project.getArtifact() + " : " + msg );
}
- for (Iterator e = errors.iterator(); e.hasNext();)
+ for ( Iterator e = errors.iterator(); e.hasNext(); )
{
- String msg = (String) e.next();
- this.getLog().error("Error building bundle " + project.getArtifact() + " : " + msg);
+ String msg = ( String ) e.next();
+ this.getLog().error( "Error building bundle " + project.getArtifact() + " : " + msg );
}
- if (errors.size() > 0)
+ if ( errors.size() > 0 )
{
String failok = properties.getProperty( "-failok" );
- if (null == failok || "false".equalsIgnoreCase( failok ))
+ if ( null == failok || "false".equalsIgnoreCase( failok ) )
{
jarFile.delete();
- throw new MojoFailureException("Error(s) found in bundle configuration");
+ throw new MojoFailureException( "Error(s) found in bundle configuration" );
}
}
@@ -361,7 +377,7 @@
List sections = archiveConfig.getManifestSections();
for ( Iterator i = sections.iterator(); i.hasNext(); )
{
- ManifestSection section = (ManifestSection) i.next();
+ ManifestSection section = ( ManifestSection ) i.next();
Attributes attributes = new Attributes();
if ( !section.isManifestEntriesEmpty() )
@@ -369,8 +385,8 @@
Map entries = section.getManifestEntries();
for ( Iterator j = entries.entrySet().iterator(); j.hasNext(); )
{
- Map.Entry entry = (Map.Entry) j.next();
- attributes.putValue( (String)entry.getKey(), (String)entry.getValue() );
+ Map.Entry entry = ( Map.Entry ) j.next();
+ attributes.putValue( ( String ) entry.getKey(), ( String ) entry.getValue() );
}
}
@@ -387,20 +403,20 @@
bundleManifest.getEntries().putAll( mavenManifest.getEntries() );
jar.setManifest( bundleManifest );
}
- catch (Exception e)
+ catch ( Exception e )
{
getLog().warn( "Unable to merge Maven manifest: " + e.getLocalizedMessage() );
}
-
- jarFile.getParentFile().mkdirs();
- builder.getJar().write(jarFile);
- Artifact bundleArtifact = project.getArtifact();
- bundleArtifact.setFile(jarFile);
- if (unpackBundle)
+ jarFile.getParentFile().mkdirs();
+ builder.getJar().write( jarFile );
+ Artifact bundleArtifact = project.getArtifact();
+ bundleArtifact.setFile( jarFile );
+
+ if ( unpackBundle )
{
File outputDir = this.getOutputDirectory();
- if (null == outputDir)
+ if ( null == outputDir )
{
outputDir = new File( this.getBuildDirectory(), "classes" );
}
@@ -411,7 +427,7 @@
* this directory must exist before unpacking, otherwise the plexus
* unarchiver decides to use the current working directory instead!
*/
- if (!outputDir.exists())
+ if ( !outputDir.exists() )
{
outputDir.mkdirs();
}
@@ -427,7 +443,7 @@
}
}
- if (manifestLocation != null)
+ if ( manifestLocation != null )
{
File outputFile = new File( manifestLocation, "MANIFEST.MF" );
@@ -445,125 +461,133 @@
// workaround for MNG-1682: force maven to install artifact using the "jar" handler
bundleArtifact.setArtifactHandler( artifactHandlerManager.getArtifactHandler( "jar" ) );
}
- catch (MojoFailureException e)
+ catch ( MojoFailureException e )
{
getLog().error( e.getLocalizedMessage() );
throw new MojoExecutionException( "Error(s) found in bundle configuration", e );
}
- catch (Exception e)
+ catch ( Exception e )
{
getLog().error( "An internal error occurred", e );
throw new MojoExecutionException( "Internal error in maven-bundle-plugin", e );
}
}
+
private String removeMavenResourcesTag( String includeResource )
{
StringBuffer buf = new StringBuffer();
- String[] clauses = includeResource.split(",");
- for (int i = 0; i < clauses.length; i++)
+ String[] clauses = includeResource.split( "," );
+ for ( int i = 0; i < clauses.length; i++ )
{
String clause = clauses[i].trim();
- if (!MAVEN_RESOURCES.equals(clause))
+ if ( !MAVEN_RESOURCES.equals( clause ) )
{
- if (buf.length() > 0)
+ if ( buf.length() > 0 )
{
- buf.append(',');
+ buf.append( ',' );
}
- buf.append(clause);
+ buf.append( clause );
}
}
return buf.toString();
}
- private Map getProperies(Model projectModel, String prefix, Object model)
+
+ private Map getProperies( Model projectModel, String prefix, Object model )
{
Map properties = new HashMap();
Method methods[] = Model.class.getDeclaredMethods();
- for (int i = 0; i < methods.length; i++)
+ for ( int i = 0; i < methods.length; i++ )
{
String name = methods[i].getName();
- if ( name.startsWith("get") )
+ if ( name.startsWith( "get" ) )
{
try
{
- Object v = methods[i].invoke(projectModel, null );
+ Object v = methods[i].invoke( projectModel, null );
if ( v != null )
{
- name = prefix + Character.toLowerCase(name.charAt(3)) + name.substring(4);
+ name = prefix + Character.toLowerCase( name.charAt( 3 ) ) + name.substring( 4 );
if ( v.getClass().isArray() )
- properties.put( name, Arrays.asList((Object[])v).toString() );
+ properties.put( name, Arrays.asList( ( Object[] ) v ).toString() );
else
properties.put( name, v );
}
}
- catch (Exception e)
+ catch ( Exception e )
{
// too bad
}
- }
+ }
}
return properties;
}
- private StringBuffer printLicenses(List licenses)
+
+ private StringBuffer printLicenses( List licenses )
{
- if (licenses == null || licenses.size() == 0)
+ if ( licenses == null || licenses.size() == 0 )
return null;
StringBuffer sb = new StringBuffer();
String del = "";
- for (Iterator i = licenses.iterator(); i.hasNext();)
+ for ( Iterator i = licenses.iterator(); i.hasNext(); )
{
- License l = (License) i.next();
+ License l = ( License ) i.next();
String url = l.getUrl();
- if (url == null) continue;
- sb.append(del);
- sb.append(url);
+ if ( url == null )
+ continue;
+ sb.append( del );
+ sb.append( url );
del = ", ";
}
- if (sb.length() == 0) return null;
+ if ( sb.length() == 0 )
+ return null;
return sb;
}
+
/**
* @param jar
* @throws IOException
*/
- private void doMavenMetadata(MavenProject project, Jar jar) throws IOException {
- String path = "META-INF/maven/" + project.getGroupId() + "/"
- + project.getArtifactId();
- File pomFile = new File(this.baseDir, "pom.xml");
- jar.putResource(path + "/pom.xml", new FileResource(pomFile));
+ private void doMavenMetadata( MavenProject project, Jar jar ) throws IOException
+ {
+ String path = "META-INF/maven/" + project.getGroupId() + "/" + project.getArtifactId();
+ File pomFile = new File( this.baseDir, "pom.xml" );
+ jar.putResource( path + "/pom.xml", new FileResource( pomFile ) );
Properties p = new Properties();
- p.put("version", project.getVersion());
- p.put("groupId", project.getGroupId());
- p.put("artifactId", project.getArtifactId());
+ p.put( "version", project.getVersion() );
+ p.put( "groupId", project.getGroupId() );
+ p.put( "artifactId", project.getArtifactId() );
ByteArrayOutputStream out = new ByteArrayOutputStream();
- p.store(out, "Generated by org.apache.felix.plugin.bundle");
- jar.putResource(path + "/pom.properties", new EmbeddedResource(out
- .toByteArray(), System.currentTimeMillis()));
+ p.store( out, "Generated by org.apache.felix.plugin.bundle" );
+ jar
+ .putResource( path + "/pom.properties",
+ new EmbeddedResource( out.toByteArray(), System.currentTimeMillis() ) );
}
+
/**
* @return
* @throws ZipException
* @throws IOException
*/
- protected Jar[] getClasspath(MavenProject project) throws ZipException, IOException
+ protected Jar[] getClasspath( MavenProject project ) throws ZipException, IOException
{
List list = new ArrayList();
- if (this.getOutputDirectory() != null && this.getOutputDirectory().exists())
+ if ( this.getOutputDirectory() != null && this.getOutputDirectory().exists() )
{
- list.add(new Jar(".", this.getOutputDirectory()));
+ list.add( new Jar( ".", this.getOutputDirectory() ) );
}
final Set artifacts;
- if (excludeDependencies)
+ if ( excludeDependencies )
{
artifacts = Collections.EMPTY_SET;
}
@@ -572,82 +596,90 @@
artifacts = project.getArtifacts();
}
- for (Iterator it = artifacts.iterator(); it.hasNext();)
+ for ( Iterator it = artifacts.iterator(); it.hasNext(); )
{
- Artifact artifact = (Artifact) it.next();
- if (artifact.getArtifactHandler().isAddedToClasspath())
+ Artifact artifact = ( Artifact ) it.next();
+ if ( artifact.getArtifactHandler().isAddedToClasspath() )
{
- if (Artifact.SCOPE_COMPILE.equals(artifact.getScope())
- || Artifact.SCOPE_SYSTEM.equals(artifact.getScope())
- || Artifact.SCOPE_PROVIDED.equals(artifact.getScope()))
+ if ( Artifact.SCOPE_COMPILE.equals( artifact.getScope() )
+ || Artifact.SCOPE_SYSTEM.equals( artifact.getScope() )
+ || Artifact.SCOPE_PROVIDED.equals( artifact.getScope() ) )
{
- File file = this.getFile(artifact);
- if (file == null)
+ File file = this.getFile( artifact );
+ if ( file == null )
{
- getLog().warn( "File is not available for artifact " + artifact + " in project " + project.getArtifact() );
+ getLog().warn(
+ "File is not available for artifact " + artifact + " in project " + project.getArtifact() );
continue;
}
- Jar jar = new Jar(artifact.getArtifactId(), file);
- list.add(jar);
+ Jar jar = new Jar( artifact.getArtifactId(), file );
+ list.add( jar );
}
}
}
Jar[] cp = new Jar[list.size()];
- list.toArray(cp);
+ list.toArray( cp );
return cp;
}
+
/**
* Get the file for an Artifact
*
* @param artifact
*/
- protected File getFile(Artifact artifact)
+ protected File getFile( Artifact artifact )
{
return artifact.getFile();
}
- private void header(Properties properties, String key, Object value)
+
+ private void header( Properties properties, String key, Object value )
{
- if (value == null)
+ if ( value == null )
return;
- if (value instanceof Collection && ((Collection) value).isEmpty())
+ if ( value instanceof Collection && ( ( Collection ) value ).isEmpty() )
return;
- properties.put(key, value.toString().replaceAll("[\r\n]", ""));
+ properties.put( key, value.toString().replaceAll( "[\r\n]", "" ) );
}
+
/**
* Convert a Maven version into an OSGi compliant version
*
* @param version Maven version
* @return the OSGi version
*/
- protected String convertVersionToOsgi(String version)
+ protected String convertVersionToOsgi( String version )
{
return this.getMaven2OsgiConverter().getVersion( version );
}
+
/**
* TODO this should return getMaven2Osgi().getBundleFileName( project.getArtifact() )
*/
- protected String getBundleName(MavenProject project)
+ protected String getBundleName( MavenProject project )
{
return project.getBuild().getFinalName() + ".jar";
}
+
protected String getBuildDirectory()
{
return this.buildDirectory;
}
- void setBuildDirectory(String buildirectory)
+
+ void setBuildDirectory( String buildirectory )
{
this.buildDirectory = buildirectory;
}
- protected Properties getDefaultProperties(MavenProject project)
+
+ protected Properties getDefaultProperties( MavenProject project )
{
Properties properties = new Properties();
@@ -656,86 +688,88 @@
{
bsn = maven2OsgiConverter.getBundleSymbolicName( project.getArtifact() );
}
- catch (Exception e)
+ catch ( Exception e )
{
bsn = project.getGroupId() + "." + project.getArtifactId();
}
// Setup defaults
- properties.put(Analyzer.BUNDLE_SYMBOLICNAME, bsn);
- properties.put(Analyzer.IMPORT_PACKAGE, "*");
- properties.put(Analyzer.BUNDLE_VERSION, project.getVersion());
+ properties.put( Analyzer.BUNDLE_SYMBOLICNAME, bsn );
+ properties.put( Analyzer.IMPORT_PACKAGE, "*" );
+ properties.put( Analyzer.BUNDLE_VERSION, project.getVersion() );
// remove the verbose Include-Resource entry from generated manifest
- properties.put(Analyzer.REMOVE_HEADERS, Analyzer.INCLUDE_RESOURCE);
+ properties.put( Analyzer.REMOVE_HEADERS, Analyzer.INCLUDE_RESOURCE );
- this.header(properties, Analyzer.BUNDLE_DESCRIPTION, project
- .getDescription());
- StringBuffer licenseText = this.printLicenses(project.getLicenses());
- if (licenseText != null) {
- this.header(properties, Analyzer.BUNDLE_LICENSE, licenseText);
- }
- this.header(properties, Analyzer.BUNDLE_NAME, project.getName());
-
- if (project.getOrganization() != null)
+ this.header( properties, Analyzer.BUNDLE_DESCRIPTION, project.getDescription() );
+ StringBuffer licenseText = this.printLicenses( project.getLicenses() );
+ if ( licenseText != null )
{
- this.header(properties, Analyzer.BUNDLE_VENDOR, project
- .getOrganization().getName());
- if (project.getOrganization().getUrl() != null)
+ this.header( properties, Analyzer.BUNDLE_LICENSE, licenseText );
+ }
+ this.header( properties, Analyzer.BUNDLE_NAME, project.getName() );
+
+ if ( project.getOrganization() != null )
+ {
+ this.header( properties, Analyzer.BUNDLE_VENDOR, project.getOrganization().getName() );
+ if ( project.getOrganization().getUrl() != null )
{
- this.header(properties, Analyzer.BUNDLE_DOCURL, project
- .getOrganization().getUrl());
+ this.header( properties, Analyzer.BUNDLE_DOCURL, project.getOrganization().getUrl() );
}
}
- properties.putAll(project.getProperties());
- properties.putAll(project.getModel().getProperties());
- properties.putAll( this.getProperies(project.getModel(), "project.build.", project.getBuild()));
- properties.putAll( this.getProperies(project.getModel(), "pom.", project.getModel()));
- properties.putAll( this.getProperies(project.getModel(), "project.", project));
- properties.put("project.baseDir", this.baseDir );
- properties.put("project.build.directory", this.getBuildDirectory() );
- properties.put("project.build.outputdirectory", this.getOutputDirectory() );
+ properties.putAll( project.getProperties() );
+ properties.putAll( project.getModel().getProperties() );
+ properties.putAll( this.getProperies( project.getModel(), "project.build.", project.getBuild() ) );
+ properties.putAll( this.getProperies( project.getModel(), "pom.", project.getModel() ) );
+ properties.putAll( this.getProperies( project.getModel(), "project.", project ) );
+ properties.put( "project.baseDir", this.baseDir );
+ properties.put( "project.build.directory", this.getBuildDirectory() );
+ properties.put( "project.build.outputdirectory", this.getOutputDirectory() );
return properties;
}
- void setBasedir(File basedir)
+
+ void setBasedir( File basedir )
{
this.baseDir = basedir;
}
+
File getOutputDirectory()
{
return this.outputDirectory;
}
- void setOutputDirectory(File outputDirectory)
+
+ void setOutputDirectory( File outputDirectory )
{
this.outputDirectory = outputDirectory;
}
- String getMavenResourcePaths(MavenProject project)
+
+ String getMavenResourcePaths( MavenProject project )
{
final String basePath = project.getBasedir().getAbsolutePath();
StringBuffer resourcePaths = new StringBuffer();
- for (Iterator i = project.getResources().iterator(); i.hasNext();)
+ for ( Iterator i = project.getResources().iterator(); i.hasNext(); )
{
- org.apache.maven.model.Resource resource = (org.apache.maven.model.Resource)i.next();
+ org.apache.maven.model.Resource resource = ( org.apache.maven.model.Resource ) i.next();
final String sourcePath = resource.getDirectory();
final String targetPath = resource.getTargetPath();
// ignore empty or non-local resources
- if (new File(sourcePath).exists() && ((targetPath == null) || (targetPath.indexOf("..") < 0)))
+ if ( new File( sourcePath ).exists() && ( ( targetPath == null ) || ( targetPath.indexOf( ".." ) < 0 ) ) )
{
DirectoryScanner scanner = new DirectoryScanner();
scanner.setBasedir( resource.getDirectory() );
if ( resource.getIncludes() != null && !resource.getIncludes().isEmpty() )
{
- scanner.setIncludes( (String[]) resource.getIncludes().toArray( EMPTY_STRING_ARRAY ) );
+ scanner.setIncludes( ( String[] ) resource.getIncludes().toArray( EMPTY_STRING_ARRAY ) );
}
else
{
@@ -744,7 +778,7 @@
if ( resource.getExcludes() != null && !resource.getExcludes().isEmpty() )
{
- scanner.setExcludes( (String[]) resource.getExcludes().toArray( EMPTY_STRING_ARRAY ) );
+ scanner.setExcludes( ( String[] ) resource.getExcludes().toArray( EMPTY_STRING_ARRAY ) );
}
scanner.addDefaultExcludes();
@@ -754,11 +788,11 @@
for ( Iterator j = includedFiles.iterator(); j.hasNext(); )
{
- String name = (String) j.next();
+ String name = ( String ) j.next();
String path = sourcePath + '/' + name;
// make relative to project
- if (path.startsWith(basePath))
+ if ( path.startsWith( basePath ) )
{
if ( path.length() == basePath.length() )
{
@@ -774,43 +808,44 @@
// this is a workaround for a problem with bnd 0.0.189
if ( File.separatorChar != '/' )
{
- name = name.replace(File.separatorChar, '/');
- path = path.replace(File.separatorChar, '/');
+ name = name.replace( File.separatorChar, '/' );
+ path = path.replace( File.separatorChar, '/' );
}
// copy to correct place
path = name + '=' + path;
- if (targetPath != null)
+ if ( targetPath != null )
{
path = targetPath + '/' + path;
}
- if (resourcePaths.length() > 0)
+ if ( resourcePaths.length() > 0 )
{
- resourcePaths.append(',');
+ resourcePaths.append( ',' );
}
- if (resource.isFiltering())
+ if ( resource.isFiltering() )
{
- resourcePaths.append('{');
- resourcePaths.append(path);
- resourcePaths.append('}');
+ resourcePaths.append( '{' );
+ resourcePaths.append( path );
+ resourcePaths.append( '}' );
}
else
{
- resourcePaths.append(path);
+ resourcePaths.append( path );
}
- }
+ }
}
}
return resourcePaths.toString();
}
- Collection getEmbeddableArtifacts(MavenProject project, Properties properties)
+
+ Collection getEmbeddableArtifacts( MavenProject project, Properties properties )
{
- String embedTransitive = properties.getProperty(DependencyEmbedder.EMBED_TRANSITIVE);
- if (Boolean.valueOf(embedTransitive).booleanValue())
+ String embedTransitive = properties.getProperty( DependencyEmbedder.EMBED_TRANSITIVE );
+ if ( Boolean.valueOf( embedTransitive ).booleanValue() )
{
// includes transitive dependencies
return project.getArtifacts();
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 b0992e3..c770ebe 100644
--- a/bundleplugin/src/main/java/org/apache/felix/bundleplugin/DependencyEmbedder.java
+++ b/bundleplugin/src/main/java/org/apache/felix/bundleplugin/DependencyEmbedder.java
@@ -18,6 +18,7 @@
*/
package org.apache.felix.bundleplugin;
+
import java.io.File;
import java.util.Collection;
import java.util.HashSet;
@@ -28,9 +29,10 @@
import org.apache.maven.artifact.Artifact;
import org.apache.maven.plugin.MojoExecutionException;
+import aQute.lib.header.OSGiHeader;
import aQute.lib.osgi.Analyzer;
import aQute.lib.osgi.Instruction;
-import aQute.lib.header.OSGiHeader;
+
/**
* Add BND directives to embed selected dependencies inside a bundle
@@ -39,11 +41,11 @@
*/
public class DependencyEmbedder
{
- public static final String EMBED_DEPENDENCY = "Embed-Dependency";
- public static final String EMBED_DIRECTORY = "Embed-Directory";
- public static final String EMBED_STRIP_GROUP = "Embed-StripGroup";
+ public static final String EMBED_DEPENDENCY = "Embed-Dependency";
+ public static final String EMBED_DIRECTORY = "Embed-Directory";
+ public static final String EMBED_STRIP_GROUP = "Embed-StripGroup";
public static final String EMBED_STRIP_VERSION = "Embed-StripVersion";
- public static final String EMBED_TRANSITIVE = "Embed-Transitive";
+ public static final String EMBED_TRANSITIVE = "Embed-Transitive";
/**
* Dependency artifacts.
@@ -60,7 +62,8 @@
*/
private final Collection embeddedArtifacts;
- public DependencyEmbedder(Collection dependencyArtifacts)
+
+ public DependencyEmbedder( Collection dependencyArtifacts )
{
this.dependencyArtifacts = dependencyArtifacts;
@@ -68,25 +71,25 @@
this.embeddedArtifacts = new HashSet();
}
- public void processHeaders(Properties properties)
- throws MojoExecutionException
+
+ public void processHeaders( Properties properties ) throws MojoExecutionException
{
this.inlinedArtifacts.clear();
this.embeddedArtifacts.clear();
- String embedDependencyHeader = properties.getProperty(EMBED_DEPENDENCY);
- if (null != embedDependencyHeader && embedDependencyHeader.length() > 0)
+ String embedDependencyHeader = properties.getProperty( EMBED_DEPENDENCY );
+ if ( null != embedDependencyHeader && embedDependencyHeader.length() > 0 )
{
- Map embedInstructions = OSGiHeader.parseHeader(embedDependencyHeader);
- this.processEmbedInstructions(embedInstructions);
+ Map embedInstructions = OSGiHeader.parseHeader( embedDependencyHeader );
+ this.processEmbedInstructions( embedInstructions );
- for (Iterator i = this.inlinedArtifacts.iterator(); i.hasNext();)
+ for ( Iterator i = this.inlinedArtifacts.iterator(); i.hasNext(); )
{
- DependencyEmbedder.inlineDependency(properties, (Artifact)i.next());
+ DependencyEmbedder.inlineDependency( properties, ( Artifact ) i.next() );
}
- for (Iterator i = this.embeddedArtifacts.iterator(); i.hasNext();)
+ for ( Iterator i = this.embeddedArtifacts.iterator(); i.hasNext(); )
{
- DependencyEmbedder.embedDependency(properties, (Artifact)i.next());
+ DependencyEmbedder.embedDependency( properties, ( Artifact ) i.next() );
}
}
}
@@ -96,235 +99,241 @@
Instruction instruction;
String defaultValue;
- public DependencyFilter(String expression)
+
+ public DependencyFilter( String expression )
{
- this(expression, "");
+ this( expression, "" );
}
- public DependencyFilter(String expression, String defaultValue)
+
+ public DependencyFilter( String expression, String defaultValue )
{
- this.instruction = Instruction.getPattern(expression);
+ this.instruction = Instruction.getPattern( expression );
this.defaultValue = defaultValue;
}
- public void filter(Collection dependencies)
+
+ public void filter( Collection dependencies )
{
- for (Iterator i = dependencies.iterator(); i.hasNext();)
+ for ( Iterator i = dependencies.iterator(); i.hasNext(); )
{
- if (false == matches((Artifact)i.next()))
+ if ( false == matches( ( Artifact ) i.next() ) )
{
i.remove();
}
}
}
- abstract boolean matches(Artifact dependency);
- boolean matches(String text)
+ abstract boolean matches( Artifact dependency );
+
+
+ boolean matches( String text )
{
- if (null == text)
+ if ( null == text )
{
text = defaultValue;
}
- boolean result = this.instruction.matches(text);
+ boolean result = this.instruction.matches( text );
return this.instruction.isNegated() ? !result : result;
}
}
- protected void processEmbedInstructions(Map embedInstructions)
- throws MojoExecutionException
+
+ protected void processEmbedInstructions( Map embedInstructions ) throws MojoExecutionException
{
DependencyFilter filter;
- for (Iterator clauseIterator = embedInstructions.entrySet().iterator(); clauseIterator.hasNext();)
+ for ( Iterator clauseIterator = embedInstructions.entrySet().iterator(); clauseIterator.hasNext(); )
{
boolean inline = false;
// must use a fresh *modifiable* collection for each unique clause
- Collection filteredDependencies = new HashSet(this.dependencyArtifacts);
+ Collection filteredDependencies = new HashSet( this.dependencyArtifacts );
// CLAUSE: REGEXP --> { ATTRIBUTE MAP }
- Map.Entry clause = (Map.Entry)clauseIterator.next();
+ Map.Entry clause = ( Map.Entry ) clauseIterator.next();
- filter = new DependencyFilter((String)clause.getKey())
+ filter = new DependencyFilter( ( String ) clause.getKey() )
{
- boolean matches(Artifact dependency)
+ boolean matches( Artifact dependency )
{
- return super.matches(dependency.getArtifactId());
+ return super.matches( dependency.getArtifactId() );
}
};
// FILTER ON MAIN CLAUSE
- filter.filter(filteredDependencies);
+ filter.filter( filteredDependencies );
- for (Iterator attrIterator = ((Map)clause.getValue()).entrySet().iterator(); attrIterator.hasNext();)
+ for ( Iterator attrIterator = ( ( Map ) clause.getValue() ).entrySet().iterator(); attrIterator.hasNext(); )
{
// ATTRIBUTE: KEY --> REGEXP
- Map.Entry attr = (Map.Entry)attrIterator.next();
+ Map.Entry attr = ( Map.Entry ) attrIterator.next();
- if ("groupId".equals(attr.getKey()))
+ if ( "groupId".equals( attr.getKey() ) )
{
- filter = new DependencyFilter((String)attr.getValue())
+ filter = new DependencyFilter( ( String ) attr.getValue() )
{
- boolean matches(Artifact dependency)
+ boolean matches( Artifact dependency )
{
- return super.matches(dependency.getGroupId());
+ return super.matches( dependency.getGroupId() );
}
};
}
- else if ("artifactId".equals(attr.getKey()))
+ else if ( "artifactId".equals( attr.getKey() ) )
{
- filter = new DependencyFilter((String)attr.getValue())
+ filter = new DependencyFilter( ( String ) attr.getValue() )
{
- boolean matches(Artifact dependency)
+ boolean matches( Artifact dependency )
{
- return super.matches(dependency.getArtifactId());
+ return super.matches( dependency.getArtifactId() );
}
};
}
- else if ("version".equals(attr.getKey()))
+ else if ( "version".equals( attr.getKey() ) )
{
- filter = new DependencyFilter((String)attr.getValue())
+ filter = new DependencyFilter( ( String ) attr.getValue() )
{
- boolean matches(Artifact dependency)
+ boolean matches( Artifact dependency )
{
try
{
// use the symbolic version if available (ie. 1.0.0-SNAPSHOT)
- return super.matches(dependency.getSelectedVersion().toString());
+ return super.matches( dependency.getSelectedVersion().toString() );
}
- catch (Exception e)
+ catch ( Exception e )
{
- return super.matches(dependency.getVersion());
+ return super.matches( dependency.getVersion() );
}
}
};
}
- else if ("scope".equals(attr.getKey()))
+ else if ( "scope".equals( attr.getKey() ) )
{
- filter = new DependencyFilter((String)attr.getValue(), "compile")
+ filter = new DependencyFilter( ( String ) attr.getValue(), "compile" )
{
- boolean matches(Artifact dependency)
+ boolean matches( Artifact dependency )
{
- return super.matches(dependency.getScope());
+ return super.matches( dependency.getScope() );
}
};
}
- else if ("type".equals(attr.getKey()))
+ else if ( "type".equals( attr.getKey() ) )
{
- filter = new DependencyFilter((String)attr.getValue(), "jar")
+ filter = new DependencyFilter( ( String ) attr.getValue(), "jar" )
{
- boolean matches(Artifact dependency)
+ boolean matches( Artifact dependency )
{
- return super.matches(dependency.getType());
+ return super.matches( dependency.getType() );
}
};
}
- else if ("classifier".equals(attr.getKey()))
+ else if ( "classifier".equals( attr.getKey() ) )
{
- filter = new DependencyFilter((String)attr.getValue())
+ filter = new DependencyFilter( ( String ) attr.getValue() )
{
- boolean matches(Artifact dependency)
+ boolean matches( Artifact dependency )
{
- return super.matches(dependency.getClassifier());
+ return super.matches( dependency.getClassifier() );
}
};
}
- else if ("optional".equals(attr.getKey()))
+ else if ( "optional".equals( attr.getKey() ) )
{
- filter = new DependencyFilter((String)attr.getValue(), "false")
+ filter = new DependencyFilter( ( String ) attr.getValue(), "false" )
{
- boolean matches(Artifact dependency)
+ boolean matches( Artifact dependency )
{
- return super.matches(""+dependency.isOptional());
+ return super.matches( "" + dependency.isOptional() );
}
};
}
- else if ("inline".equals(attr.getKey()))
+ else if ( "inline".equals( attr.getKey() ) )
{
- inline = Boolean.valueOf((String)attr.getValue()).booleanValue();
+ inline = Boolean.valueOf( ( String ) attr.getValue() ).booleanValue();
continue;
}
else
{
- throw new MojoExecutionException("Unexpected attribute " + attr.getKey());
+ throw new MojoExecutionException( "Unexpected attribute " + attr.getKey() );
}
// FILTER ON EACH ATTRIBUTE
- filter.filter(filteredDependencies);
+ filter.filter( filteredDependencies );
}
- if (inline)
+ if ( inline )
{
- this.inlinedArtifacts.addAll(filteredDependencies);
+ this.inlinedArtifacts.addAll( filteredDependencies );
}
else
{
- this.embeddedArtifacts.addAll(filteredDependencies);
+ this.embeddedArtifacts.addAll( filteredDependencies );
}
}
// remove any inlined artifacts from the embedded list
- this.embeddedArtifacts.removeAll(this.inlinedArtifacts);
+ this.embeddedArtifacts.removeAll( this.inlinedArtifacts );
}
- public static void embedDependency(Properties properties, Artifact dependency)
+
+ public static void embedDependency( Properties properties, Artifact dependency )
{
File sourceFile = dependency.getFile();
- if (null != sourceFile && sourceFile.exists())
+ if ( null != sourceFile && sourceFile.exists() )
{
- String bundleClassPath = properties.getProperty(Analyzer.BUNDLE_CLASSPATH);
- String includeResource = properties.getProperty(Analyzer.INCLUDE_RESOURCE);
+ String bundleClassPath = properties.getProperty( Analyzer.BUNDLE_CLASSPATH );
+ String includeResource = properties.getProperty( Analyzer.INCLUDE_RESOURCE );
- if (null == bundleClassPath)
+ if ( null == bundleClassPath )
{
bundleClassPath = ".,";
}
- else if (bundleClassPath.length() > 0)
+ else if ( bundleClassPath.length() > 0 )
{
bundleClassPath += ",";
}
- if (null == includeResource)
+ if ( null == includeResource )
{
includeResource = "";
}
- else if (includeResource.length() > 0)
+ else if ( includeResource.length() > 0 )
{
includeResource += ",";
}
- String embedDirectory = properties.getProperty(EMBED_DIRECTORY);
- String embedStripGroup = properties.getProperty(EMBED_STRIP_GROUP, "true");
- String embedStripVersion = properties.getProperty(EMBED_STRIP_VERSION);
+ String embedDirectory = properties.getProperty( EMBED_DIRECTORY );
+ String embedStripGroup = properties.getProperty( EMBED_STRIP_GROUP, "true" );
+ String embedStripVersion = properties.getProperty( EMBED_STRIP_VERSION );
- if ("".equals(embedDirectory) || ".".equals(embedDirectory))
+ if ( "".equals( embedDirectory ) || ".".equals( embedDirectory ) )
{
embedDirectory = null;
}
- if (false == Boolean.valueOf(embedStripGroup).booleanValue())
+ if ( false == Boolean.valueOf( embedStripGroup ).booleanValue() )
{
- embedDirectory = new File(embedDirectory, dependency.getGroupId()).getPath();
+ embedDirectory = new File( embedDirectory, dependency.getGroupId() ).getPath();
}
File targetFile;
- if (Boolean.valueOf(embedStripVersion).booleanValue())
+ if ( Boolean.valueOf( embedStripVersion ).booleanValue() )
{
String extension = dependency.getArtifactHandler().getExtension();
- if (extension != null)
+ if ( extension != null )
{
- targetFile = new File(embedDirectory, dependency.getArtifactId() + "." + extension);
+ targetFile = new File( embedDirectory, dependency.getArtifactId() + "." + extension );
}
else
{
- targetFile = new File(embedDirectory, dependency.getArtifactId());
+ targetFile = new File( embedDirectory, dependency.getArtifactId() );
}
}
else
{
- targetFile = new File(embedDirectory, sourceFile.getName());
+ targetFile = new File( embedDirectory, sourceFile.getName() );
}
String targetFilePath = targetFile.getPath();
@@ -332,45 +341,48 @@
// replace windows backslash with a slash
if ( File.separatorChar != '/' )
{
- targetFilePath = targetFilePath.replace(File.separatorChar, '/');
+ targetFilePath = targetFilePath.replace( File.separatorChar, '/' );
}
bundleClassPath += targetFilePath;
includeResource += targetFilePath + "=" + sourceFile;
- properties.setProperty(Analyzer.BUNDLE_CLASSPATH, bundleClassPath);
- properties.setProperty(Analyzer.INCLUDE_RESOURCE, includeResource);
+ properties.setProperty( Analyzer.BUNDLE_CLASSPATH, bundleClassPath );
+ properties.setProperty( Analyzer.INCLUDE_RESOURCE, includeResource );
}
}
- public static void inlineDependency(Properties properties, Artifact dependency)
+
+ public static void inlineDependency( Properties properties, Artifact dependency )
{
File sourceFile = dependency.getFile();
- if (null != sourceFile && sourceFile.exists())
+ if ( null != sourceFile && sourceFile.exists() )
{
- String includeResource = properties.getProperty(Analyzer.INCLUDE_RESOURCE);
+ String includeResource = properties.getProperty( Analyzer.INCLUDE_RESOURCE );
- if (null == includeResource)
+ if ( null == includeResource )
{
includeResource = "";
}
- else if (includeResource.length() > 0)
+ else if ( includeResource.length() > 0 )
{
includeResource += ",";
}
includeResource += "@" + sourceFile;
- properties.setProperty(Analyzer.INCLUDE_RESOURCE, includeResource);
+ properties.setProperty( Analyzer.INCLUDE_RESOURCE, includeResource );
}
}
+
public Collection getInlinedArtifacts()
{
return this.inlinedArtifacts;
}
+
public Collection getEmbeddedArtifacts()
{
return this.embeddedArtifacts;
diff --git a/bundleplugin/src/main/java/org/apache/felix/bundleplugin/JarPluginConfiguration.java b/bundleplugin/src/main/java/org/apache/felix/bundleplugin/JarPluginConfiguration.java
index f0ab2bb..0461b54 100644
--- a/bundleplugin/src/main/java/org/apache/felix/bundleplugin/JarPluginConfiguration.java
+++ b/bundleplugin/src/main/java/org/apache/felix/bundleplugin/JarPluginConfiguration.java
@@ -18,6 +18,7 @@
*/
package org.apache.felix.bundleplugin;
+
import org.apache.maven.archiver.MavenArchiveConfiguration;
import org.apache.maven.project.MavenProject;
import org.codehaus.plexus.component.configurator.converters.composite.ObjectWithFieldsConverter;
@@ -29,6 +30,7 @@
import org.codehaus.plexus.configuration.xml.XmlPlexusConfiguration;
import org.codehaus.plexus.util.xml.Xpp3Dom;
+
/**
* Provide access to the archive configuration from the jar plugin
*
@@ -52,7 +54,7 @@
converter.processConfiguration( converters, archiveConfig, loader, archiveSettings, evaluator, null );
}
- catch( Exception e )
+ catch ( Exception e )
{
// ignore and return empty configuration...
}
@@ -60,11 +62,13 @@
return archiveConfig;
}
+
private static PlexusConfiguration getCorePluginConfiguration( MavenProject project, String pluginName )
{
return getPluginConfiguration( project, "org.apache.maven.plugins", "maven-" + pluginName + "-plugin" );
}
+
private static PlexusConfiguration getPluginConfiguration( MavenProject project, String groupId, String artifactId )
{
Xpp3Dom pluginConfig = project.getGoalConfiguration( groupId, artifactId, null, null );
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 bf4db79..93bf4c6 100644
--- a/bundleplugin/src/main/java/org/apache/felix/bundleplugin/ManifestPlugin.java
+++ b/bundleplugin/src/main/java/org/apache/felix/bundleplugin/ManifestPlugin.java
@@ -18,6 +18,7 @@
*/
package org.apache.felix.bundleplugin;
+
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
@@ -33,6 +34,7 @@
import aQute.lib.osgi.Analyzer;
import aQute.lib.osgi.Jar;
+
/**
* Generate an OSGi manifest for this project
*
@@ -40,8 +42,7 @@
* @phase process-classes
* @requiresDependencyResolution runtime
*/
-public class ManifestPlugin
- extends BundlePlugin
+public class ManifestPlugin extends BundlePlugin
{
protected void execute( MavenProject project, Map instructions, Properties properties, Jar[] classpath )
throws MojoExecutionException
@@ -53,7 +54,8 @@
}
catch ( FileNotFoundException e )
{
- throw new MojoExecutionException( "Cannot find " + e.getMessage() + " (manifest goal must be run after compile phase)", e );
+ throw new MojoExecutionException( "Cannot find " + e.getMessage()
+ + " (manifest goal must be run after compile phase)", e );
}
catch ( IOException e )
{
@@ -72,24 +74,26 @@
}
}
- public Manifest getManifest( MavenProject project, Jar[] classpath )
- throws IOException
+
+ public Manifest getManifest( MavenProject project, Jar[] classpath ) throws IOException
{
return this.getManifest( project, null, null, classpath );
}
+
public Manifest getManifest( MavenProject project, Map instructions, Properties properties, Jar[] classpath )
throws IOException
{
return this.getAnalyzer( project, instructions, properties, classpath ).getJar().getManifest();
}
- protected Analyzer getAnalyzer( MavenProject project, Jar[] classpath )
- throws IOException
+
+ protected Analyzer getAnalyzer( MavenProject project, Jar[] classpath ) throws IOException
{
return this.getAnalyzer( project, new HashMap(), new Properties(), classpath );
}
+
protected Analyzer getAnalyzer( MavenProject project, Map instructions, Properties properties, Jar[] classpath )
throws IOException
{
@@ -137,8 +141,8 @@
return analyzer;
}
- public static void writeManifest( Manifest manifest, File outputFile )
- throws IOException
+
+ public static void writeManifest( Manifest manifest, File outputFile ) throws IOException
{
outputFile.getParentFile().mkdirs();
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 8324072..73fca8a 100644
--- a/bundleplugin/src/main/java/org/apache/felix/bundleplugin/PackageVersionAnalyzer.java
+++ b/bundleplugin/src/main/java/org/apache/felix/bundleplugin/PackageVersionAnalyzer.java
@@ -18,6 +18,7 @@
*/
package org.apache.felix.bundleplugin;
+
import java.io.IOException;
import java.util.Iterator;
import java.util.Map;
@@ -25,14 +26,14 @@
import aQute.lib.osgi.Builder;
import aQute.lib.osgi.Jar;
+
/**
* Extension of {@link aQute.lib.osgi.Builder} to handle package versions
*
* @author <a href="mailto:carlos@apache.org">Carlos Sanchez</a>
* @version $Id$
*/
-public class PackageVersionAnalyzer
- extends Builder
+public class PackageVersionAnalyzer extends Builder
{
/**
@@ -53,10 +54,10 @@
String bundleVersion = getProperties().getProperty( BUNDLE_VERSION );
for ( Iterator it = contained.entrySet().iterator(); it.hasNext(); )
{
- Map.Entry entry = (Map.Entry) it.next();
+ Map.Entry entry = ( Map.Entry ) it.next();
/* remove packages under META-INF */
- String packageName = (String) entry.getKey();
+ String packageName = ( String ) entry.getKey();
if ( packageName.startsWith( "META-INF." ) )
{
it.remove();
@@ -65,7 +66,7 @@
/* set package versions to bundle version values */
if ( bundleVersion != null )
{
- Map values = (Map) entry.getValue();
+ Map values = ( Map ) entry.getValue();
if ( values.get( "version" ) == null )
{
values.put( "version", bundleVersion );
diff --git a/bundleplugin/src/main/java/org/apache/felix/bundleplugin/WrapPlugin.java b/bundleplugin/src/main/java/org/apache/felix/bundleplugin/WrapPlugin.java
index f19810b..80b4818 100644
--- a/bundleplugin/src/main/java/org/apache/felix/bundleplugin/WrapPlugin.java
+++ b/bundleplugin/src/main/java/org/apache/felix/bundleplugin/WrapPlugin.java
@@ -18,8 +18,10 @@
*/
package org.apache.felix.bundleplugin;
+
import org.apache.maven.plugin.MojoExecutionException;
+
/**
*
* @goal wrap
@@ -27,12 +29,10 @@
* @requiresDependencyResolution runtime
* @description build an OSGi bundle jar for direct dependencies
*/
-public class WrapPlugin
- extends BundleAllPlugin
+public class WrapPlugin extends BundleAllPlugin
{
- public void execute()
- throws MojoExecutionException
+ public void execute() throws MojoExecutionException
{
BundleInfo bundleInfo = bundleAll( getProject(), 1 );
logDuplicatedPackages( bundleInfo );