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 import java.util.Properties;
27
28 import org.apache.maven.plugin.MojoExecutionException;
29 import org.apache.maven.plugin.MojoFailureException;
30 import org.apache.maven.plugins.annotations.Mojo;
31 import org.apache.maven.plugins.annotations.ResolutionScope;
32 import org.apache.maven.project.MavenProject;
33
34 import aQute.bnd.osgi.Jar;
35 import org.apache.maven.shared.dependency.graph.DependencyNode;
36
37
38
39
40
41 @Mojo( name = "instructions", requiresDependencyResolution = ResolutionScope.TEST, threadSafe = true )
42 public class InstructionsPlugin extends BundlePlugin
43 {
44 @Override
45 protected void execute( MavenProject project, DependencyNode dependencyGraph, Map<String, String> instructions, Properties properties, Jar[] classpath )
46 throws MojoExecutionException
47 {
48 if ( dumpInstructions == null )
49 {
50 dumpInstructions = new File( getBuildDirectory(), "instructions.bnd" );
51 }
52
53 try
54 {
55 addMavenInstructions( project, dependencyGraph, getOSGiBuilder(project, instructions, properties, classpath) );
56 }
57 catch ( FileNotFoundException e )
58 {
59 throw new MojoExecutionException( "Cannot find " + e.getMessage(), e );
60 }
61 catch ( IOException e )
62 {
63 throw new MojoExecutionException( "Error trying to generate instructions", e );
64 }
65 catch ( MojoFailureException e )
66 {
67 getLog().error( e.getLocalizedMessage() );
68 throw new MojoExecutionException( "Error(s) found in instructions", e );
69 }
70 catch ( Exception e )
71 {
72 getLog().error( "An internal error occurred", e );
73 throw new MojoExecutionException( "Internal error in maven-bundle-plugin", e );
74 }
75 }
76 }