You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by mc...@apache.org on 2011/06/28 18:14:52 UTC
svn commit: r1140703 -
/felix/trunk/bundleplugin/src/main/java/org/apache/felix/bundleplugin/BundlePlugin.java
Author: mcculls
Date: Tue Jun 28 16:14:52 2011
New Revision: 1140703
URL: http://svn.apache.org/viewvc?rev=1140703&view=rev
Log:
Refactor internals to help reduce code duplication
Modified:
felix/trunk/bundleplugin/src/main/java/org/apache/felix/bundleplugin/BundlePlugin.java
Modified: felix/trunk/bundleplugin/src/main/java/org/apache/felix/bundleplugin/BundlePlugin.java
URL: http://svn.apache.org/viewvc/felix/trunk/bundleplugin/src/main/java/org/apache/felix/bundleplugin/BundlePlugin.java?rev=1140703&r1=1140702&r2=1140703&view=diff
==============================================================================
--- felix/trunk/bundleplugin/src/main/java/org/apache/felix/bundleplugin/BundlePlugin.java (original)
+++ felix/trunk/bundleplugin/src/main/java/org/apache/felix/bundleplugin/BundlePlugin.java Tue Jun 28 16:14:52 2011
@@ -286,44 +286,46 @@ public class BundlePlugin extends Abstra
}
- protected void execute( MavenProject currentProject, Map originalInstructions, Properties properties,
- Jar[] classpath ) throws MojoExecutionException
+ protected boolean reportErrors( String prefix, Builder builder )
{
- try
- {
- File jarFile = new File( getBuildDirectory(), getBundleName( currentProject ) );
-
- Builder builder = buildOSGiBundle( currentProject, originalInstructions, properties, classpath );
+ List errors = builder.getErrors();
+ List warnings = builder.getWarnings();
- List errors = builder.getErrors();
- List warnings = builder.getWarnings();
+ for ( Iterator w = warnings.iterator(); w.hasNext(); )
+ {
+ String msg = ( String ) w.next();
+ getLog().warn( prefix + " : " + msg );
+ }
- String warningPrefix = "Warning building bundle " + currentProject.getArtifact() + " : ";
- for ( Iterator w = warnings.iterator(); w.hasNext(); )
+ boolean hasErrors = false;
+ String fileNotFound = "Input file does not exist: ";
+ for ( Iterator e = errors.iterator(); e.hasNext(); )
+ {
+ String msg = ( String ) e.next();
+ if ( msg.startsWith( fileNotFound ) && msg.endsWith( "~" ) )
{
- String msg = ( String ) w.next();
- getLog().warn( warningPrefix + msg );
+ // 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" );
}
-
- boolean hasErrors = false;
- String errorPrefix = "Error building bundle " + currentProject.getArtifact() + " : ";
- String fileNotFound = "Input file does not exist: ";
- for ( Iterator e = errors.iterator(); e.hasNext(); )
+ else
{
- String msg = ( String ) e.next();
- if ( msg.startsWith( fileNotFound ) && msg.endsWith( "~" ) )
- {
- // treat as warning; this error happens when you have duplicate entries in Include-Resource
- String duplicate = Processor.removeDuplicateMarker( msg.substring( fileNotFound.length() ) );
- getLog().warn( warningPrefix + "Duplicate path '" + duplicate + "' in Include-Resource" );
- }
- else
- {
- getLog().error( errorPrefix + msg );
- hasErrors = true;
- }
+ getLog().error( prefix + " : " + msg );
+ hasErrors = true;
}
+ }
+ return hasErrors;
+ }
+
+ protected void execute( MavenProject currentProject, Map originalInstructions, Properties properties,
+ Jar[] classpath ) throws MojoExecutionException
+ {
+ try
+ {
+ File jarFile = new File( getBuildDirectory(), getBundleName( currentProject ) );
+ Builder builder = buildOSGiBundle( currentProject, originalInstructions, properties, classpath );
+ boolean hasErrors = reportErrors( "Bundle " + currentProject.getArtifact(), builder );
if ( hasErrors )
{
String failok = builder.getProperty( "-failok" );
@@ -1157,15 +1159,18 @@ public class BundlePlugin extends Abstra
{
List resources = new ArrayList(project.getResources());
- // also scan for any "packageinfo" files lurking in the source folders
- List packageInfoIncludes = Collections.singletonList( "**/packageinfo" );
- for ( Iterator i = project.getCompileSourceRoots().iterator(); i.hasNext(); )
- {
- String sourceRoot = (String) i.next();
- Resource packageInfoResource = new Resource();
- packageInfoResource.setDirectory( sourceRoot );
- packageInfoResource.setIncludes( packageInfoIncludes );
- resources.add( packageInfoResource );
+ if ( project.getCompileSourceRoots() != null )
+ {
+ // also scan for any "packageinfo" files lurking in the source folders
+ List packageInfoIncludes = Collections.singletonList( "**/packageinfo" );
+ for ( Iterator i = project.getCompileSourceRoots().iterator(); i.hasNext(); )
+ {
+ String sourceRoot = (String) i.next();
+ Resource packageInfoResource = new Resource();
+ packageInfoResource.setDirectory( sourceRoot );
+ packageInfoResource.setIncludes( packageInfoIncludes );
+ resources.add( packageInfoResource );
+ }
}
return resources;