mirror of
https://gitee.com/dcren/initializr.git
synced 2025-07-16 16:50:42 +08:00
Add parentheses for method invocations with no argument
Closes gh-907
This commit is contained in:
parent
fd8ebf728c
commit
75228ba4a3
@ -189,8 +189,9 @@ public class GroovyDslGradleBuildWriter extends GradleBuildWriter {
|
||||
@Override
|
||||
protected String invocationAsString(
|
||||
GradleBuild.TaskCustomization.Invocation invocation) {
|
||||
return invocation.getTarget() + " "
|
||||
+ String.join(", ", invocation.getArguments());
|
||||
String arguments = (invocation.getArguments().isEmpty()) ? "()"
|
||||
: " " + String.join(", ", invocation.getArguments());
|
||||
return invocation.getTarget() + arguments;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -183,6 +183,14 @@ class GroovyDslGradleBuildWriterTests {
|
||||
" dependsOn test", "}");
|
||||
}
|
||||
|
||||
@Test
|
||||
void gradleBuildWithTaskCustomizedWithInvocationAndNoArgument() throws IOException {
|
||||
GradleBuild build = new GradleBuild();
|
||||
build.customizeTask("test", (task) -> task.invoke("myMethod"));
|
||||
List<String> lines = generateBuild(build);
|
||||
assertThat(lines).containsSequence("test {", " myMethod()", "}");
|
||||
}
|
||||
|
||||
@Test
|
||||
void gradleBuildWithTaskCustomizedWithAssignments() throws IOException {
|
||||
GradleBuild build = new GradleBuild();
|
||||
|
Loading…
Reference in New Issue
Block a user