mirror of
https://gitee.com/dcren/initializr.git
synced 2025-07-17 10:41:57 +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
|
@Override
|
||||||
protected String invocationAsString(
|
protected String invocationAsString(
|
||||||
GradleBuild.TaskCustomization.Invocation invocation) {
|
GradleBuild.TaskCustomization.Invocation invocation) {
|
||||||
return invocation.getTarget() + " "
|
String arguments = (invocation.getArguments().isEmpty()) ? "()"
|
||||||
+ String.join(", ", invocation.getArguments());
|
: " " + String.join(", ", invocation.getArguments());
|
||||||
|
return invocation.getTarget() + arguments;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -183,6 +183,14 @@ class GroovyDslGradleBuildWriterTests {
|
|||||||
" dependsOn test", "}");
|
" 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
|
@Test
|
||||||
void gradleBuildWithTaskCustomizedWithAssignments() throws IOException {
|
void gradleBuildWithTaskCustomizedWithAssignments() throws IOException {
|
||||||
GradleBuild build = new GradleBuild();
|
GradleBuild build = new GradleBuild();
|
||||||
|
Loading…
Reference in New Issue
Block a user