@@ -31,7 +31,7 @@ public interface BuildContext {
31
31
boolean hasDelta (List relpaths );
32
32
33
33
/**
34
- * Indicates that the file content has been modified during the build.
34
+ * Indicates that the file or folder content has been modified during the build.
35
35
*
36
36
* @see #newFileOutputStream(File)
37
37
*/
@@ -42,6 +42,10 @@ public interface BuildContext {
42
42
*
43
43
* Files changed using OutputStream returned by this method do not need to be
44
44
* explicitly refreshed using {@link #refresh(File)}.
45
+ *
46
+ * As an optional optimisation, OutputStreams created by incremental build
47
+ * context will attempt to avoid writing to the file if file content
48
+ * has not changed.
45
49
*/
46
50
OutputStream newFileOutputStream (File file ) throws IOException ;
47
51
@@ -59,11 +63,55 @@ public interface BuildContext {
59
63
60
64
/**
61
65
* Returned Scanner scans files and folders under <code>basedir</code>.
62
- * If <code>ignoreDelta</code> is <code>false</code>, the scanner will only
63
- * "see" files and folders with content changes since last build. If
64
- * <code>ignoreDelta</code> is <code>true</code>, the scanner will "see" all
65
- * files and folders. Returns empty Scanner if <code>basedir</code>
66
- * is not under this build context basedir.
66
+ *
67
+ * If this is an incremental build context and <code>ignoreDelta</code>
68
+ * is <code>false</code>, the scanner will only "see" files and folders with
69
+ * content changes since last build.
70
+ *
71
+ * If <code>ignoreDelta</code> is <code>true</code>, the scanner will "see" all
72
+ * files and folders.
73
+ *
74
+ * Returns empty Scanner if <code>basedir</code> is not under this build context basedir.
67
75
*/
68
76
Scanner newScanner (File basedir , boolean ignoreDelta );
77
+
78
+ /**
79
+ * Returns <code>true</code> if this build context is incremental.
80
+ *
81
+ * Scanners created by {@link #newScanner(File)} of an incremental build context
82
+ * will ignore files and folders that were not changed since last build.
83
+ * Additionally, {@link #newDeleteScanner(File)} will scan files and directories
84
+ * deleted since last build.
85
+ */
86
+ boolean isIncremental ();
87
+
88
+ /**
89
+ * Associate specified <code>key</code> with specified <code>value</code>
90
+ * in the build context.
91
+ *
92
+ * Primary (and the only) purpose of this method is to allow preservation of
93
+ * state needed for proper incremental behaviour between consecutive executions
94
+ * of the same mojo needed to.
95
+ *
96
+ * For example, maven-plugin-plugin:descriptor mojo
97
+ * can store collection of extracted MojoDescritpor during first invocation. Then
98
+ * on each consecutive execution maven-plugin-plugin:descriptor will only need
99
+ * to extract MojoDescriptors for changed files.
100
+ *
101
+ * @see #getValue(String)
102
+ */
103
+ public void setValue (String key , Object value );
104
+
105
+ /**
106
+ * Returns value associated with <code>key</code> during previous mojo execution.
107
+ *
108
+ * This method always returns <code>null</code> for non-incremental builds
109
+ * (i.e., {@link #isIncremental()} returns <code>false</code>) and mojos are
110
+ * expected to fall back to full, non-incremental behaviour.
111
+ *
112
+ * @see #setValue(String, Object)
113
+ * @see #isIncremental()
114
+ */
115
+ public Object getValue (String key );
116
+
69
117
}
0 commit comments