Skip to content

Commit ad69a06

Browse files
authored
Merge pull request #2 from ethauvin/main
Added File argument alternatives with Path and String.
2 parents 2bc3319 + f37a626 commit ad69a06

File tree

2 files changed

+153
-7
lines changed

2 files changed

+153
-7
lines changed

src/bld/java/rife/bld/extension/Antlr4Build.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ public Antlr4Build() {
3232
.include(dependency("com.uwyn.rife2", "bld", version(2,0,1)))
3333
.include(dependency("org.antlr", "antlr4", version(4,11,1)));
3434
scope(test)
35-
.include(dependency("org.junit.jupiter", "junit-jupiter", version(5,10,3)))
36-
.include(dependency("org.junit.platform", "junit-platform-console-standalone", version(1,10,3)));
35+
.include(dependency("org.junit.jupiter", "junit-jupiter", version(5,11,0)))
36+
.include(dependency("org.junit.platform", "junit-platform-console-standalone", version(1,11,0)));
3737

3838
javadocOperation()
3939
.javadocOptions()

src/main/java/rife/bld/extension/Antlr4Operation.java

Lines changed: 151 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@
99
import rife.bld.operations.exceptions.ExitStatusException;
1010

1111
import java.io.File;
12-
import java.util.*;
12+
import java.nio.file.Path;
13+
import java.util.ArrayList;
14+
import java.util.List;
1315

1416
/**
1517
* Generates Java sources from ANTLR grammars.
@@ -115,7 +117,7 @@ public void execute()
115117
* @since 1.0
116118
*/
117119
public Antlr4Operation arguments(String... arguments) {
118-
arguments_.addAll(Arrays.asList(arguments));
120+
arguments_.addAll(List.of(arguments));
119121
return this;
120122
}
121123

@@ -138,47 +140,147 @@ public Antlr4Operation arguments(List<String> arguments) {
138140
*
139141
* @param directories the source directories
140142
* @return this operation instance
143+
* @see #sourceDirectories(List)
141144
* @since 1.0
142145
*/
143146
public Antlr4Operation sourceDirectories(File... directories) {
144-
return sourceDirectories(Arrays.asList(directories));
147+
return sourceDirectories(List.of(directories));
145148
}
146149

147150
/**
148151
* Provides the source directories that will be used for the antlr operation.
149152
*
150153
* @param directories the source directories
151154
* @return this operation instance
155+
* @see #sourceDirectoriesPaths(List)
156+
* @since 1.4
157+
*/
158+
public Antlr4Operation sourceDirectories(Path... directories) {
159+
return sourceDirectoriesPaths(List.of(directories));
160+
}
161+
162+
/**
163+
* Provides the source directories that will be used for the antlr operation.
164+
*
165+
* @param directories the source directories
166+
* @return this operation instance
167+
* @see #sourceDirectoriesStrings(List)
168+
* @since 1.4
169+
*/
170+
public Antlr4Operation sourceDirectories(String... directories) {
171+
return sourceDirectoriesStrings(List.of(directories));
172+
}
173+
174+
/**
175+
* Provides the source directories that will be used for the antlr operation.
176+
*
177+
* @param directories the source directories
178+
* @return this operation instance
179+
* @see #sourceDirectories(File...)
152180
* @since 1.0
153181
*/
154182
public Antlr4Operation sourceDirectories(List<File> directories) {
155183
sourceDirectories_.addAll(directories);
156184
return this;
157185
}
158186

187+
/**
188+
* Provides the source directories that will be used for the antlr operation.
189+
*
190+
* @param directories the source directories
191+
* @return this operation instance
192+
* @see #sourceDirectories(Path...)
193+
* @since 1.0
194+
*/
195+
public Antlr4Operation sourceDirectoriesPaths(List<Path> directories) {
196+
return sourceDirectories(directories.stream().map(Path::toFile).toList());
197+
}
198+
199+
/**
200+
* Provides the source directories that will be used for the antlr operation.
201+
*
202+
* @param directories the source directories
203+
* @return this operation instance
204+
* @see #sourceDirectories(File...)
205+
* @since 1.0
206+
*/
207+
public Antlr4Operation sourceDirectoriesStrings(List<String> directories) {
208+
return sourceDirectories(directories.stream().map(File::new).toList());
209+
}
210+
159211
/**
160212
* Provides the source files that will be used for the antlr operation.
161213
*
162214
* @param files the source files
163215
* @return this operation instance
216+
* @see #sourceFiles(List)
164217
* @since 1.0
165218
*/
166219
public Antlr4Operation sourceFiles(File... files) {
167-
return sourceFiles(Arrays.asList(files));
220+
return sourceFiles(List.of(files));
221+
}
222+
223+
/**
224+
* Provides the source files that will be used for the antlr operation.
225+
*
226+
* @param files the source files
227+
* @return this operation instance
228+
* @see #sourceFilesPaths(List)
229+
* @since 1.4
230+
*/
231+
public Antlr4Operation sourceFiles(Path... files) {
232+
return sourceFilesPaths(List.of(files));
233+
}
234+
235+
/**
236+
* Provides the source files that will be used for the antlr operation.
237+
*
238+
* @param files the source files
239+
* @return this operation instance
240+
* @see #sourceFilesStrings(List)
241+
* @since 1.4
242+
*/
243+
public Antlr4Operation sourceFiles(String... files) {
244+
return sourceFilesStrings(List.of(files));
168245
}
169246

170247
/**
171248
* Provides the source files that will be used for the antlr operation.
172249
*
173250
* @param files the source files
174251
* @return this operation instance
252+
* @see #sourceFiles(File...)
175253
* @since 1.0
176254
*/
177255
public Antlr4Operation sourceFiles(List<File> files) {
178256
sourceFiles_.addAll(files);
179257
return this;
180258
}
181259

260+
/**
261+
* Provides the source files that will be used for the antlr operation.
262+
*
263+
* @param files the source files
264+
* @return this operation instance
265+
* @see #sourceFiles(Path...)
266+
* @since 1.4
267+
*/
268+
public Antlr4Operation sourceFilesPaths(List<Path> files) {
269+
return sourceFiles(files.stream().map(Path::toFile).toList());
270+
}
271+
272+
/**
273+
* Provides the source files that will be used for the antlr operation.
274+
*
275+
* @param files the source files
276+
* @return this operation instance
277+
* @see #sourceFiles(String...)
278+
* @since 1.4
279+
*/
280+
public Antlr4Operation sourceFilesStrings(List<String> files) {
281+
return sourceFiles(files.stream().map(File::new).toList());
282+
}
283+
182284
/**
183285
* Provides the output directory where all output is generated.
184286
*
@@ -191,6 +293,28 @@ public Antlr4Operation outputDirectory(File directory) {
191293
return this;
192294
}
193295

296+
/**
297+
* Provides the output directory where all output is generated.
298+
*
299+
* @param directory the output directory
300+
* @return this operation instance
301+
* @since 1.4
302+
*/
303+
public Antlr4Operation outputDirectory(Path directory) {
304+
return outputDirectory(directory.toFile());
305+
}
306+
307+
/**
308+
* Provides the output directory where all output is generated.
309+
*
310+
* @param directory the output directory
311+
* @return this operation instance
312+
* @since 1.4
313+
*/
314+
public Antlr4Operation outputDirectory(String directory) {
315+
return outputDirectory(new File(directory));
316+
}
317+
194318
/**
195319
* Provides the location of grammars and tokens files.
196320
*
@@ -203,6 +327,28 @@ public Antlr4Operation libDirectory(File directory) {
203327
return this;
204328
}
205329

330+
/**
331+
* Provides the location of grammars and tokens files.
332+
*
333+
* @param directory the lib directory
334+
* @return this operation instance
335+
* @since 1.4
336+
*/
337+
public Antlr4Operation libDirectory(Path directory) {
338+
return libDirectory(directory.toFile());
339+
}
340+
341+
/**
342+
* Provides the location of grammars and tokens files.
343+
*
344+
* @param directory the lib directory
345+
* @return this operation instance
346+
* @since 1.4
347+
*/
348+
public Antlr4Operation libDirectory(String directory) {
349+
return libDirectory(new File(directory));
350+
}
351+
206352
/**
207353
* Provides grammar file encoding; e.g., euc-jp.
208354
*
@@ -365,4 +511,4 @@ public File outputDirectory() {
365511
public File libDirectory() {
366512
return libDirectory_;
367513
}
368-
}
514+
}

0 commit comments

Comments
 (0)