Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
CompileMojo |
|
| 3.0;3 |
1 | package org.apache.maven.plugin.coreit; | |
2 | ||
3 | /* | |
4 | * Licensed to the Apache Software Foundation (ASF) under one | |
5 | * or more contributor license agreements. See the NOTICE file | |
6 | * distributed with this work for additional information | |
7 | * regarding copyright ownership. The ASF licenses this file | |
8 | * to you under the Apache License, Version 2.0 (the | |
9 | * "License"); you may not use this file except in compliance | |
10 | * with the License. You may obtain a copy of the License at | |
11 | * | |
12 | * http://www.apache.org/licenses/LICENSE-2.0 | |
13 | * | |
14 | * Unless required by applicable law or agreed to in writing, | |
15 | * software distributed under the License is distributed on an | |
16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | |
17 | * KIND, either express or implied. See the License for the | |
18 | * specific language governing permissions and limitations | |
19 | * under the License. | |
20 | */ | |
21 | ||
22 | import org.apache.maven.artifact.DependencyResolutionRequiredException; | |
23 | import org.apache.maven.plugin.MojoExecutionException; | |
24 | ||
25 | /** | |
26 | * Creates text files that list the dependencies with scope compile in the order returned from the Maven core. | |
27 | * | |
28 | * @goal compile | |
29 | * @requiresDependencyResolution compile | |
30 | * | |
31 | * @author Benjamin Bentmann | |
32 | * @version $Id: CompileMojo.java 809429 2009-08-30 22:24:31Z bentmann $ | |
33 | */ | |
34 | 0 | public class CompileMojo |
35 | extends AbstractDependencyMojo | |
36 | { | |
37 | ||
38 | /** | |
39 | * The path to the output file for the project artifacts, relative to the project base directory. Each line of this | |
40 | * UTF-8 encoded file specifies an artifact identifier. If not specified, the artifact list will not be written to | |
41 | * disk. Unlike the compile artifacts, the collection of project artifacts additionally contains those artifacts | |
42 | * that do not contribute to the class path. | |
43 | * | |
44 | * @parameter expression="${depres.projectArtifacts}" | |
45 | */ | |
46 | private String projectArtifacts; | |
47 | ||
48 | /** | |
49 | * The path to the output file for the compile artifacts, relative to the project base directory. Each line of this | |
50 | * UTF-8 encoded file specifies an artifact identifier. If not specified, the artifact list will not be written to | |
51 | * disk. | |
52 | * | |
53 | * @parameter expression="${depres.compileArtifacts}" | |
54 | */ | |
55 | private String compileArtifacts; | |
56 | ||
57 | /** | |
58 | * Runs this mojo. | |
59 | * | |
60 | * @throws MojoExecutionException If the output file could not be created or any dependency could not be resolved. | |
61 | */ | |
62 | public void execute() | |
63 | throws MojoExecutionException | |
64 | { | |
65 | try | |
66 | { | |
67 | 0 | writeArtifacts( projectArtifacts, project.getArtifacts() ); |
68 | 0 | writeArtifacts( compileArtifacts, project.getCompileArtifacts() ); |
69 | ||
70 | // NOTE: We can't make any assumptions about the class path but as a minimum it must not cause an exception | |
71 | 0 | project.getCompileClasspathElements(); |
72 | } | |
73 | 0 | catch ( DependencyResolutionRequiredException e ) |
74 | { | |
75 | 0 | throw new MojoExecutionException( "Failed to resolve dependencies", e ); |
76 | 0 | } |
77 | 0 | } |
78 | ||
79 | } |