|
10 | 10 | import java.util.HashMap;
|
11 | 11 | import java.util.List;
|
12 | 12 | import java.util.Map;
|
| 13 | +import javax.annotation.Nullable; |
13 | 14 | import org.gradle.execution.commandline.TaskConfigurationException;
|
14 | 15 |
|
15 | 16 | @Data
|
16 | 17 | public class JcpPreprocessExtension {
|
17 | 18 |
|
| 19 | + public static final String ID = "preprocessSettings"; |
| 20 | + |
18 | 21 | /**
|
19 | 22 | * Source root folders for preprocessing, if it is empty then project provided
|
20 | 23 | * folders will be used.
|
@@ -72,7 +75,7 @@ public class JcpPreprocessExtension {
|
72 | 75 | private boolean unknownVarAsFalse = false;
|
73 | 76 |
|
74 | 77 | /**
|
75 |
| - * Dry run, making preprocessing but without output |
| 78 | + * Dry run, making pre-processing but without output |
76 | 79 | */
|
77 | 80 | private boolean dryRun = false;
|
78 | 81 |
|
@@ -155,38 +158,38 @@ public class JcpPreprocessExtension {
|
155 | 158 | public JcpPreprocessExtension(final Project project) {
|
156 | 159 | if (this.baseDir == null) {
|
157 | 160 | this.baseDir = project.getProjectDir();
|
158 |
| - project.getLogger().debug("Got basedir from project: " + this.baseDir); |
| 161 | + project.getLogger().debug("Basedir of the project: " + this.baseDir); |
159 | 162 | }
|
160 | 163 | }
|
161 | 164 |
|
162 |
| - private void assertCharSet(final String name) { |
163 |
| - if (!Charset.isSupported(name)) { |
164 |
| - throw new TaskConfigurationException("preprocess", "Unsupported charset: " + name, null); |
| 165 | + private void assertCharSet(@Nullable final String name) { |
| 166 | + if (name == null || !Charset.isSupported(name)) { |
| 167 | + throw new TaskConfigurationException(JcpPreprocessTask.ID, "Unsupported charset: " + name, null); |
165 | 168 | }
|
166 | 169 | }
|
167 | 170 |
|
168 | 171 | public void validate(final Project project) {
|
169 | 172 | if (this.baseDir == null) {
|
170 |
| - throw new TaskConfigurationException("preprocess", "Basedir must be defined", null); |
| 173 | + throw new TaskConfigurationException(JcpPreprocessTask.ID, "Basedir must be defined", null); |
171 | 174 | }
|
172 | 175 |
|
173 | 176 | if (!this.baseDir.isDirectory()) {
|
174 |
| - throw new TaskConfigurationException("preprocess", "Basedir doesn't exist: " + this.baseDir, null); |
| 177 | + throw new TaskConfigurationException(JcpPreprocessTask.ID, "Basedir doesn't exist: " + this.baseDir, null); |
175 | 178 | }
|
176 | 179 |
|
177 | 180 | assertCharSet(this.sourceEncoding);
|
178 | 181 | assertCharSet(this.targetEncoding);
|
179 | 182 |
|
180 | 183 | if (this.sources == null) {
|
181 |
| - throw new TaskConfigurationException("preprocess", "Source folders are not deined in 'sources'", null); |
| 184 | + throw new TaskConfigurationException(JcpPreprocessTask.ID, "Source folders are not deined in 'sources'", null); |
182 | 185 | }
|
183 | 186 |
|
184 | 187 | if (this.sources.isEmpty()) {
|
185 |
| - throw new TaskConfigurationException("preprocess", "Source folders are empty", null); |
| 188 | + throw new TaskConfigurationException(JcpPreprocessTask.ID, "Source folder list is empty", null); |
186 | 189 | }
|
187 | 190 |
|
188 | 191 | if (this.target == null) {
|
189 |
| - throw new TaskConfigurationException("preprocess", "Target folder is not deined in 'target'", null); |
| 192 | + throw new TaskConfigurationException(JcpPreprocessTask.ID, "Target folder is not deined in 'target'", null); |
190 | 193 | }
|
191 | 194 | }
|
192 | 195 |
|
|
0 commit comments