Return-Path: X-Original-To: apmail-felix-commits-archive@www.apache.org Delivered-To: apmail-felix-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 7E6A96B43 for ; Tue, 28 Jun 2011 16:15:17 +0000 (UTC) Received: (qmail 88337 invoked by uid 500); 28 Jun 2011 16:15:17 -0000 Delivered-To: apmail-felix-commits-archive@felix.apache.org Received: (qmail 88228 invoked by uid 500); 28 Jun 2011 16:15:16 -0000 Mailing-List: contact commits-help@felix.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@felix.apache.org Delivered-To: mailing list commits@felix.apache.org Received: (qmail 88218 invoked by uid 99); 28 Jun 2011 16:15:16 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 28 Jun 2011 16:15:16 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 28 Jun 2011 16:15:13 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 8755023888CF for ; Tue, 28 Jun 2011 16:14:52 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1140703 - /felix/trunk/bundleplugin/src/main/java/org/apache/felix/bundleplugin/BundlePlugin.java Date: Tue, 28 Jun 2011 16:14:52 -0000 To: commits@felix.apache.org From: mcculls@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20110628161452.8755023888CF@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org 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;