-
Notifications
You must be signed in to change notification settings - Fork 4.6k
/
CopyProcessingSpec.java
190 lines (173 loc) · 7.01 KB
/
CopyProcessingSpec.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
/*
* Copyright 2009 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.gradle.api.file;
import groovy.lang.Closure;
import groovy.lang.DelegatesTo;
import org.gradle.api.Action;
import org.gradle.api.Incubating;
import org.gradle.api.Transformer;
import org.gradle.api.provider.Property;
import javax.annotation.Nullable;
import java.util.regex.Pattern;
/**
* Specifies the destination of a copy.
*/
public interface CopyProcessingSpec extends ContentFilterable {
/**
* Specifies the destination directory for a copy. The destination is evaluated as per {@link
* org.gradle.api.Project#file(Object)}.
*
* @param destPath Path to the destination directory for a Copy
* @return this
*/
CopyProcessingSpec into(Object destPath);
/**
* Renames a source file. The closure will be called with a single parameter, the name of the file.
* The closure should return a String object with a new target name. The closure may return null,
* in which case the original name will be used.
*
* @param closure rename closure
* @return this
*/
CopyProcessingSpec rename(Closure closure);
/**
* Renames a source file. The function will be called with a single parameter, the name of the file.
* The function should return a new target name. The function may return null,
* in which case the original name will be used.
*
* @param renamer rename function
* @return this
*/
CopyProcessingSpec rename(Transformer<@org.jetbrains.annotations.Nullable String, String> renamer);
/**
* Renames files based on a regular expression. Uses java.util.regex type of regular expressions. Note that the
* replace string should use the '$1' syntax to refer to capture groups in the source regular expression. Files
* that do not match the source regular expression will be copied with the original name.
*
* <p> Example:
* <pre>
* rename '(.*)_OEM_BLUE_(.*)', '$1$2'
* </pre>
* would map the file 'style_OEM_BLUE_.css' to 'style.css'
*
* @param sourceRegEx Source regular expression
* @param replaceWith Replacement string (use $ syntax for capture groups)
* @return this
*/
CopyProcessingSpec rename(String sourceRegEx, String replaceWith);
/**
* Renames files based on a regular expression. See {@link #rename(String, String)}.
*
* @param sourceRegEx Source regular expression
* @param replaceWith Replacement string (use $ syntax for capture groups)
* @return this
*/
CopyProcessingSpec rename(Pattern sourceRegEx, String replaceWith);
/**
* Returns the Unix permissions to use for the target files. {@code null} means that existing
* permissions are preserved. It is dependent on the copy action implementation whether these permissions
* will actually be applied.
*
* @return The file permissions, or {@code null} if existing permissions should be preserved.
*
* @apiNote Consider using {@link #getFilePermissions()} instead.
*/
@Nullable
Integer getFileMode();
/**
* Sets the Unix permissions to use for the target files. {@code null} means that existing
* permissions are preserved. It is dependent on the copy action implementation whether these permissions
* will actually be applied.
*
* @param mode The file permissions.
* @return this
*
* @apiNote Consider using {@link #filePermissions(Action)} instead.
*/
CopyProcessingSpec setFileMode(@Nullable Integer mode);
/**
* Returns the Unix permissions to use for the target directories. {@code null} means that existing
* permissions are preserved. It is dependent on the copy action implementation whether these permissions
* will actually be applied.
*
* @return The directory permissions, or {@code null} if existing permissions should be preserved.
*
* @apiNote Consider using {@link #getDirPermissions()} instead.
*/
@Nullable
Integer getDirMode();
/**
* Sets the Unix permissions to use for the target directories. {@code null} means that existing
* permissions are preserved. It is dependent on the copy action implementation whether these permissions
* will actually be applied.
*
* @param mode The directory permissions.
* @return this
*
* @apiNote Consider using {@link #dirPermissions(Action)} instead.
*/
CopyProcessingSpec setDirMode(@Nullable Integer mode);
/**
* Property for configuring file access permissions.
* For details see {@link ConfigurableFilePermissions}.
*
* @since 8.3
*/
@Incubating
Property<ConfigurableFilePermissions> getFilePermissions();
/**
* Configuration action for specifying file access permissions.
* For details see {@link ConfigurableFilePermissions}.
*
* @since 8.3
*/
@Incubating
CopyProcessingSpec filePermissions(Action<? super ConfigurableFilePermissions> configureAction);
/**
* Property for configuring directory access permissions.
* For details see {@link ConfigurableFilePermissions}.
*
* @since 8.3
*/
@Incubating
Property<ConfigurableFilePermissions> getDirPermissions();
/**
* Configuration action for specifying directory access permissions.
* For details see {@link ConfigurableFilePermissions}.
*
* @since 8.3
*/
@Incubating
CopyProcessingSpec dirPermissions(Action<? super ConfigurableFilePermissions> configureAction);
/**
* Adds an action to be applied to each file as it is about to be copied into its destination. The action can change
* the destination path of the file, filter the contents of the file, or exclude the file from the result entirely.
* Actions are executed in the order added, and are inherited from the parent spec.
*
* @param action The action to execute.
* @return this
*/
CopyProcessingSpec eachFile(Action<? super FileCopyDetails> action);
/**
* Adds an action to be applied to each file as it about to be copied into its destination. The given closure is
* called with a {@link org.gradle.api.file.FileCopyDetails} as its parameter. Actions are executed in the order
* added, and are inherited from the parent spec.
*
* @param closure The action to execute.
* @return this
*/
CopyProcessingSpec eachFile(@DelegatesTo(value=FileCopyDetails.class, strategy = Closure.DELEGATE_FIRST) Closure closure);
}