Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
BuildLocalPomMojo |
|
| 4.0;4 |
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.repository.ArtifactRepository; | |
23 | import org.apache.maven.plugin.MojoExecutionException; | |
24 | import org.apache.maven.project.MavenProject; | |
25 | ||
26 | import java.io.File; | |
27 | import java.util.Properties; | |
28 | ||
29 | /** | |
30 | * Builds the local POMs. | |
31 | * | |
32 | * @goal local-pom | |
33 | * @author Benjamin Bentmann | |
34 | */ | |
35 | 0 | public class BuildLocalPomMojo |
36 | extends AbstractPomMojo | |
37 | { | |
38 | ||
39 | /** | |
40 | * The properties file to dump the POM info to. | |
41 | * | |
42 | * @parameter default-value="target/pom.properties" | |
43 | */ | |
44 | private File propertiesFile; | |
45 | ||
46 | /** | |
47 | * The local repository. | |
48 | * | |
49 | * @parameter default-value="${localRepository}" | |
50 | * @readonly | |
51 | * @required | |
52 | */ | |
53 | private ArtifactRepository localRepository; | |
54 | ||
55 | /** | |
56 | * The POM files to build. | |
57 | * | |
58 | * @parameter | |
59 | */ | |
60 | private File[] files; | |
61 | ||
62 | /** | |
63 | * Runs this mojo. | |
64 | * | |
65 | * @throws MojoFailureException If the artifact file has not been set. | |
66 | */ | |
67 | public void execute() | |
68 | throws MojoExecutionException | |
69 | { | |
70 | 0 | Properties props = new Properties(); |
71 | ||
72 | 0 | getLog().info( "[MAVEN-CORE-IT-LOG] Building local POMs" ); |
73 | ||
74 | 0 | if ( files != null ) |
75 | { | |
76 | 0 | for ( int i = 0; i < files.length; i++ ) |
77 | { | |
78 | 0 | File file = files[i]; |
79 | ||
80 | 0 | getLog().info( "[MAVEN-CORE-IT-LOG] Building " + file ); |
81 | ||
82 | try | |
83 | { | |
84 | 0 | MavenProject project = builder.build( file, localRepository, null ); |
85 | ||
86 | 0 | dump( props, file.getName() + ".", project ); |
87 | } | |
88 | 0 | catch ( Exception e ) |
89 | { | |
90 | 0 | getLog().warn( "Failed to build local POM for " + file, e ); |
91 | 0 | } |
92 | } | |
93 | } | |
94 | ||
95 | 0 | store( props, propertiesFile ); |
96 | 0 | } |
97 | ||
98 | } |