1 /**
2 * Copyright (C) 2011-2012 Indiana University
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16 package edu.iu.ul.maven.plugins.fileweaver;
17
18 import java.util.HashMap;
19 import java.util.List;
20 import java.util.Map;
21
22 import org.apache.maven.plugin.AbstractMojo;
23 import org.apache.maven.plugin.MojoExecutionException;
24 import org.apache.maven.plugin.logging.Log;
25
26 /**
27 * Build files from external and literal portions, with filtering.
28 * <p>
29 * Any number of output files may be generated.
30 *
31 * @author Mark H. Wood, IUPUI University Library
32 *
33 * @goal weave
34 *
35 * @phase generate-sources
36 */
37 public class Weave
38 extends AbstractMojo
39 {
40 /**
41 * Where to write files, unless a <part> specifies otherwise.
42 * @parameter expression="${project.build.directory}"
43 * @required
44 */
45 private java.io.File outputPath;
46
47 /**
48 * Files to be woven.
49 * @parameter
50 * @required
51 */
52 private List<Output> outputs;
53
54 /**
55 * Common properties for filtering all outputs.
56 * @parameter
57 */
58 private Map<String, String> properties;
59
60 @Override
61 public void execute()
62 throws MojoExecutionException
63 {
64 final Log log = getLog();
65
66 Map<Object, Object> executionProps = new HashMap<Object, Object>();
67 if (null != properties)
68 executionProps.putAll(properties);
69
70 int nFiles = 0;
71 for (Output file : outputs)
72 {
73 file.build(outputPath, executionProps, log);
74 nFiles++;
75 }
76 log.info(String.format("%d files woven.", nFiles));
77 }
78 }