|
21 | 21 |
|
22 | 22 |
|
23 | 23 | // TODO should it be BuildWorkspace or something like that?
|
| 24 | +/** |
| 25 | + * <p>BuildContext interface.</p> |
| 26 | + */ |
24 | 27 | public interface BuildContext {
|
| 28 | + /** Constant <code>SEVERITY_WARNING=1</code> */ |
25 | 29 | int SEVERITY_WARNING = 1;
|
26 | 30 |
|
| 31 | + /** Constant <code>SEVERITY_ERROR=2</code> */ |
27 | 32 | int SEVERITY_ERROR = 2;
|
28 | 33 |
|
29 | 34 | // TODO should we add File getBasedir()?
|
30 | 35 |
|
31 | 36 | /**
|
32 |
| - * Returns <code>true</code> if file or folder identified by <code>relpath</code> has |
33 |
| - * changed since last build. |
34 |
| - * |
| 37 | + * Returns <code>true</code> if file or folder identified by <code>relpath</code> has |
| 38 | + * changed since last build. |
| 39 | + * |
35 | 40 | * @param relpath is path relative to build context basedir
|
| 41 | + * @return a boolean. |
36 | 42 | */
|
37 | 43 | boolean hasDelta(String relpath);
|
38 | 44 |
|
39 | 45 | /**
|
40 | 46 | * Returns <code>true</code> if the file has changed since last build or is not
|
41 | 47 | * under basedir.
|
42 |
| - * |
| 48 | + * |
43 | 49 | * @since 0.0.5
|
| 50 | + * @param file a {@link java.io.File} object. |
| 51 | + * @return a boolean. |
44 | 52 | */
|
45 | 53 | boolean hasDelta(File file);
|
46 | 54 |
|
47 | 55 | /**
|
48 |
| - * Returns <code>true</code> if any file or folder identified by <code>relpaths</code> has |
| 56 | + * Returns <code>true</code> if any file or folder identified by <code>relpaths</code> has |
49 | 57 | * changed since last build.
|
50 |
| - * |
51 |
| - * @param relpaths List<String> are paths relative to build context basedir |
| 58 | + * |
| 59 | + * @param relpaths paths relative to build context basedir |
| 60 | + * @return a boolean. |
52 | 61 | */
|
53 | 62 | boolean hasDelta(List<String> relpaths);
|
54 | 63 |
|
55 | 64 | /**
|
56 | 65 | * Indicates that the file or folder content has been modified during the build.
|
57 |
| - * |
| 66 | + * |
58 | 67 | * @see #newFileOutputStream(File)
|
| 68 | + * @param file a {@link java.io.File} object. |
59 | 69 | */
|
60 | 70 | void refresh(File file);
|
61 | 71 |
|
62 | 72 | /**
|
63 | 73 | * Returns new OutputStream that writes to the <code>file</code>.
|
64 |
| - * |
| 74 | + * |
65 | 75 | * Files changed using OutputStream returned by this method do not need to be
|
66 | 76 | * explicitly refreshed using {@link #refresh(File)}.
|
67 | 77 | *
|
68 |
| - * As an optional optimisation, OutputStreams created by incremental build |
69 |
| - * context will attempt to avoid writing to the file if file content |
| 78 | + * As an optional optimisation, OutputStreams created by incremental build |
| 79 | + * context will attempt to avoid writing to the file if file content |
70 | 80 | * has not changed.
|
| 81 | + * |
| 82 | + * @param file a {@link java.io.File} object. |
| 83 | + * @return a {@link java.io.OutputStream} object. |
| 84 | + * @throws java.io.IOException if any. |
71 | 85 | */
|
72 | 86 | OutputStream newFileOutputStream(File file) throws IOException;
|
73 | 87 |
|
74 | 88 | /**
|
75 | 89 | * Convenience method, fully equal to newScanner(basedir, false)
|
| 90 | + * |
| 91 | + * @param basedir a {@link java.io.File} object. |
| 92 | + * @return a {@link org.codehaus.plexus.util.Scanner} object. |
76 | 93 | */
|
77 | 94 | Scanner newScanner(File basedir);
|
78 | 95 |
|
79 | 96 | /**
|
80 |
| - * Returned Scanner scans <code>basedir</code> for files and directories |
| 97 | + * Returned Scanner scans <code>basedir</code> for files and directories |
81 | 98 | * deleted since last build. Returns empty Scanner if <code>basedir</code>
|
82 | 99 | * is not under this build context basedir.
|
| 100 | + * |
| 101 | + * @param basedir a {@link java.io.File} object. |
| 102 | + * @return a {@link org.codehaus.plexus.util.Scanner} object. |
83 | 103 | */
|
84 | 104 | Scanner newDeleteScanner(File basedir);
|
85 | 105 |
|
86 | 106 | /**
|
87 | 107 | * Returned Scanner scans files and folders under <code>basedir</code>.
|
88 |
| - * |
89 |
| - * If this is an incremental build context and <code>ignoreDelta</code> |
90 |
| - * is <code>false</code>, the scanner will only "see" files and folders with |
91 |
| - * content changes since last build. |
92 |
| - * |
| 108 | + * |
| 109 | + * If this is an incremental build context and <code>ignoreDelta</code> |
| 110 | + * is <code>false</code>, the scanner will only "see" files and folders with |
| 111 | + * content changes since last build. |
| 112 | + * |
93 | 113 | * If <code>ignoreDelta</code> is <code>true</code>, the scanner will "see" all
|
94 |
| - * files and folders. |
95 |
| - * |
| 114 | + * files and folders. |
| 115 | + * |
96 | 116 | * Please beware that ignoreDelta=false does NOT work reliably for operations
|
97 | 117 | * that copy resources from source to target locations. Returned Scanner
|
98 | 118 | * only scans changed source resources and it does not consider changed or deleted
|
99 | 119 | * target resources. This results in missing or stale target resources.
|
100 | 120 | * Starting with 0.5.0, recommended way to process resources is to use
|
101 | 121 | * #newScanner(basedir,true) to locate all source resources and {@link #isUptodate(File, File)}
|
102 |
| - * to optimized processing of uptodate target resources. |
103 |
| - * |
| 122 | + * to optimized processing of uptodate target resources. |
| 123 | + * |
104 | 124 | * Returns empty Scanner if <code>basedir</code> is not under this build context basedir.
|
105 |
| - * |
| 125 | + * |
106 | 126 | * https://issues.apache.org/jira/browse/MSHARED-125
|
| 127 | + * |
| 128 | + * @param basedir a {@link java.io.File} object. |
| 129 | + * @param ignoreDelta a boolean. |
| 130 | + * @return a {@link org.codehaus.plexus.util.Scanner} object. |
107 | 131 | */
|
108 | 132 | Scanner newScanner(File basedir, boolean ignoreDelta);
|
109 | 133 |
|
110 | 134 | /**
|
111 |
| - * Returns <code>true</code> if this build context is incremental. |
112 |
| - * |
| 135 | + * Returns <code>true</code> if this build context is incremental. |
| 136 | + * |
113 | 137 | * Scanners created by {@link #newScanner(File)} of an incremental build context
|
114 |
| - * will ignore files and folders that were not changed since last build. |
| 138 | + * will ignore files and folders that were not changed since last build. |
115 | 139 | * Additionally, {@link #newDeleteScanner(File)} will scan files and directories
|
116 | 140 | * deleted since last build.
|
| 141 | + * |
| 142 | + * @return a boolean. |
117 | 143 | */
|
118 | 144 | boolean isIncremental();
|
119 | 145 |
|
120 | 146 | /**
|
121 | 147 | * Associate specified <code>key</code> with specified <code>value</code>
|
122 | 148 | * in the build context.
|
123 |
| - * |
124 |
| - * Primary (and the only) purpose of this method is to allow preservation of |
125 |
| - * state needed for proper incremental behaviour between consecutive executions |
126 |
| - * of the same mojo needed to. |
127 |
| - * |
| 149 | + * |
| 150 | + * Primary (and the only) purpose of this method is to allow preservation of |
| 151 | + * state needed for proper incremental behaviour between consecutive executions |
| 152 | + * of the same mojo needed to. |
| 153 | + * |
128 | 154 | * For example, maven-plugin-plugin:descriptor mojo
|
129 | 155 | * can store collection of extracted MojoDescritpor during first invocation. Then
|
130 | 156 | * on each consecutive execution maven-plugin-plugin:descriptor will only need
|
131 | 157 | * to extract MojoDescriptors for changed files.
|
132 | 158 | *
|
133 | 159 | * @see #getValue(String)
|
| 160 | + * @param key a {@link java.lang.String} object. |
| 161 | + * @param value a {@link java.lang.Object} object. |
134 | 162 | */
|
135 | 163 | void setValue(String key, Object value);
|
136 | 164 |
|
137 | 165 | /**
|
138 | 166 | * Returns value associated with <code>key</code> during previous mojo execution.
|
139 |
| - * |
| 167 | + * |
140 | 168 | * This method always returns <code>null</code> for non-incremental builds
|
141 |
| - * (i.e., {@link #isIncremental()} returns <code>false</code>) and mojos are |
| 169 | + * (i.e., {@link #isIncremental()} returns <code>false</code>) and mojos are |
142 | 170 | * expected to fall back to full, non-incremental behaviour.
|
143 |
| - * |
| 171 | + * |
144 | 172 | * @see #setValue(String, Object)
|
145 | 173 | * @see #isIncremental()
|
| 174 | + * @param key a {@link java.lang.String} object. |
| 175 | + * @return a {@link java.lang.Object} object. |
146 | 176 | */
|
147 | 177 | Object getValue(String key);
|
148 | 178 |
|
149 | 179 | /**
|
| 180 | + * <p>addWarning.</p> |
| 181 | + * |
150 | 182 | * @deprecated Use addMessage with severity=SEVERITY_ERROR instead
|
151 | 183 | * @since 0.0.5
|
| 184 | + * @param file a {@link java.io.File} object. |
| 185 | + * @param line a int. |
| 186 | + * @param column a int. |
| 187 | + * @param message a {@link java.lang.String} object. |
| 188 | + * @param cause a {@link java.lang.Throwable} object. |
152 | 189 | */
|
153 | 190 | void addWarning(File file, int line, int column, String message, Throwable cause);
|
154 | 191 |
|
155 | 192 | /**
|
| 193 | + * <p>addError.</p> |
| 194 | + * |
156 | 195 | * @deprecated Use addMessage with severity=SEVERITY_WARNING instead
|
157 | 196 | * @since 0.0.5
|
| 197 | + * @param file a {@link java.io.File} object. |
| 198 | + * @param line a int. |
| 199 | + * @param column a int. |
| 200 | + * @param message a {@link java.lang.String} object. |
| 201 | + * @param cause a {@link java.lang.Throwable} object. |
158 | 202 | */
|
159 | 203 | void addError(File file, int line, int column, String message, Throwable cause);
|
160 | 204 |
|
161 | 205 | /**
|
162 | 206 | * Adds a message to the build context. The message is associated with a file and a location inside that file.
|
163 |
| - * |
| 207 | + * |
164 | 208 | * @param file The file or folder with which the message is associated. Should not be null and it is recommended to be
|
165 | 209 | * an absolute path.
|
166 | 210 | * @param line The line number inside the file. Use 1 (not 0) for the first line. Use 0 for unknown/unspecified.
|
167 | 211 | * @param column The column number inside the file. Use 1 (not 0) for the first column. Use 0 for unknown/unspecified.
|
168 | 212 | * @param severity The severity of the message: SEVERITY_WARNING or SEVERITY_ERROR.
|
169 | 213 | * @param cause A Throwable object associated with the message. Can be null.
|
170 | 214 | * @since 0.0.7
|
| 215 | + * @param message a {@link java.lang.String} object. |
171 | 216 | */
|
172 | 217 | void addMessage(File file, int line, int column, String message, int severity, Throwable cause);
|
173 | 218 |
|
174 | 219 | /**
|
175 | 220 | * Removes all messages associated with a file or folder during a previous build. It does not affect the messages
|
176 | 221 | * added during the current build.
|
177 |
| - * |
| 222 | + * |
178 | 223 | * @since 0.0.7
|
| 224 | + * @param file a {@link java.io.File} object. |
179 | 225 | */
|
180 | 226 | void removeMessages(File file);
|
181 | 227 |
|
182 | 228 | /**
|
183 | 229 | * Returns true, if the target file exists and is uptodate compared to the source file.
|
184 |
| - * |
| 230 | + * |
185 | 231 | * More specifically, this method returns true when both target and source files exist,
|
186 | 232 | * do not have changes since last incremental build and the target file was last modified
|
187 | 233 | * later than the source file. Returns false in all other cases.
|
188 |
| - * |
| 234 | + * |
189 | 235 | * @since 0.0.5
|
| 236 | + * @param target a {@link java.io.File} object. |
| 237 | + * @param source a {@link java.io.File} object. |
| 238 | + * @return a boolean. |
190 | 239 | */
|
191 | 240 | boolean isUptodate(File target, File source);
|
192 | 241 | }
|
0 commit comments