|
2 | 2 |
|
3 | 3 | /*
|
4 | 4 | * Copyright (c) 2004-2005, Codehaus.org
|
5 |
| - * |
| 5 | + * |
6 | 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
|
7 | 7 | * associated documentation files (the "Software"), to deal in the Software without restriction,
|
8 | 8 | * including without limitation the rights to use, copy, modify, merge, publish, distribute,
|
9 | 9 | * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
|
10 | 10 | * furnished to do so, subject to the following conditions:
|
11 |
| - * |
| 11 | + * |
12 | 12 | * The above copyright notice and this permission notice shall be included in all copies or
|
13 | 13 | * substantial portions of the Software.
|
14 |
| - * |
| 14 | + * |
15 | 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
|
16 | 16 | * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17 | 17 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
|
31 | 31 | /**
|
32 | 32 | * Generates a Plexus {@code components.xml} component descriptor file from source (javadoc) or
|
33 | 33 | * class annotations and manually crafted descriptor files.
|
34 |
| - * |
| 34 | + * |
35 | 35 | * @author Jason van Zyl
|
36 | 36 | * @author Trygve Laugstøl
|
37 | 37 | */
|
38 |
| -@Mojo( name = "generate-metadata", defaultPhase = LifecyclePhase.PROCESS_CLASSES, requiresDependencyResolution = ResolutionScope.COMPILE ) |
39 |
| -public class PlexusDescriptorMojo |
40 |
| - extends AbstractDescriptorMojo |
41 |
| -{ |
| 38 | +@Mojo( |
| 39 | + name = "generate-metadata", |
| 40 | + defaultPhase = LifecyclePhase.PROCESS_CLASSES, |
| 41 | + requiresDependencyResolution = ResolutionScope.COMPILE) |
| 42 | +public class PlexusDescriptorMojo extends AbstractDescriptorMojo { |
42 | 43 | /**
|
43 | 44 | * The output location for the generated descriptor.
|
44 | 45 | */
|
45 |
| - @Parameter( defaultValue = "${project.build.outputDirectory}/META-INF/plexus/components.xml", required = true ) |
| 46 | + @Parameter(defaultValue = "${project.build.outputDirectory}/META-INF/plexus/components.xml", required = true) |
46 | 47 | protected File generatedMetadata;
|
47 | 48 |
|
48 | 49 | /**
|
49 | 50 | * The location of manually crafted component descriptors. The contents of the descriptor files in this directory is
|
50 | 51 | * merged with the information extracted from the project's sources/classes.
|
51 | 52 | */
|
52 |
| - @Parameter( defaultValue = "${basedir}/src/main/resources/META-INF/plexus", required = true ) |
| 53 | + @Parameter(defaultValue = "${basedir}/src/main/resources/META-INF/plexus", required = true) |
53 | 54 | protected File staticMetadataDirectory;
|
54 | 55 |
|
55 | 56 | /**
|
56 | 57 | * The output location for the intermediary descriptor. This descriptors contains only the information extracted
|
57 | 58 | * from the project's sources/classes.
|
58 | 59 | */
|
59 |
| - @Parameter( defaultValue = "${project.build.directory}/components.xml", required = true ) |
| 60 | + @Parameter(defaultValue = "${project.build.directory}/components.xml", required = true) |
60 | 61 | protected File intermediaryMetadata;
|
61 | 62 |
|
62 |
| - public void execute() |
63 |
| - throws MojoExecutionException |
64 |
| - { |
| 63 | + public void execute() throws MojoExecutionException { |
65 | 64 | MetadataGenerationRequest request = new MetadataGenerationRequest();
|
66 | 65 |
|
67 |
| - try |
68 |
| - { |
| 66 | + try { |
69 | 67 | request.classpath = mavenProject.getCompileClasspathElements();
|
70 |
| - request.classesDirectory = new File( mavenProject.getBuild().getOutputDirectory() ); |
| 68 | + request.classesDirectory = new File(mavenProject.getBuild().getOutputDirectory()); |
71 | 69 | request.sourceDirectories = mavenProject.getCompileSourceRoots();
|
72 | 70 | request.sourceEncoding = sourceEncoding;
|
73 | 71 | request.componentDescriptorDirectory = staticMetadataDirectory;
|
74 | 72 | request.intermediaryFile = intermediaryMetadata;
|
75 | 73 | request.outputFile = generatedMetadata;
|
76 | 74 | request.extractors = extractors;
|
77 |
| - |
78 |
| - metadataGenerator.generateDescriptor( request ); |
79 |
| - } |
80 |
| - catch ( Exception e ) |
81 |
| - { |
82 |
| - throw new MojoExecutionException( "Error generating metadata: ", e ); |
| 75 | + |
| 76 | + metadataGenerator.generateDescriptor(request); |
| 77 | + } catch (Exception e) { |
| 78 | + throw new MojoExecutionException("Error generating metadata: ", e); |
83 | 79 | }
|
84 | 80 | }
|
85 | 81 | }
|
0 commit comments