1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.felix.bundleplugin;
20
21
22 import java.io.File;
23 import java.io.FileNotFoundException;
24 import java.io.IOException;
25 import java.util.Map;
26
27 import org.apache.maven.plugin.MojoExecutionException;
28 import org.apache.maven.plugin.MojoFailureException;
29 import org.apache.maven.plugins.annotations.Mojo;
30 import org.apache.maven.plugins.annotations.ResolutionScope;
31
32 import aQute.bnd.osgi.Jar;
33 import org.apache.maven.shared.dependency.graph.DependencyNode;
34
35
36
37
38
39 @Mojo( name = "instructions", requiresDependencyResolution = ResolutionScope.TEST, threadSafe = true )
40 public class InstructionsPlugin extends BundlePlugin
41 {
42 @Override
43 protected void execute( Map<String, String> instructions, ClassPathItem[] classpath )
44 throws MojoExecutionException
45 {
46 if ( dumpInstructions == null )
47 {
48 dumpInstructions = new File( getBuildDirectory(), "instructions.bnd" );
49 }
50
51 try
52 {
53 addMavenInstructions( project, getOSGiBuilder(project, instructions, classpath) );
54 }
55 catch ( FileNotFoundException e )
56 {
57 throw new MojoExecutionException( "Cannot find " + e.getMessage(), e );
58 }
59 catch ( IOException e )
60 {
61 throw new MojoExecutionException( "Error trying to generate instructions", e );
62 }
63 catch ( MojoFailureException e )
64 {
65 getLog().error( e.getLocalizedMessage() );
66 throw new MojoExecutionException( "Error(s) found in instructions", e );
67 }
68 catch ( Exception e )
69 {
70 getLog().error( "An internal error occurred", e );
71 throw new MojoExecutionException( "Internal error in maven-bundle-plugin", e );
72 }
73 }
74 }