File tree Expand file tree Collapse file tree 2 files changed +14
-10
lines changed
plugin-maven/src/main/java/com/diffplug/spotless/maven/generic Expand file tree Collapse file tree 2 files changed +14
-10
lines changed Original file line number Diff line number Diff line change 1
1
/*
2
- * Copyright 2016 DiffPlug
2
+ * Copyright 2016-2022 DiffPlug
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
@@ -35,10 +35,12 @@ public class Replace implements FormatterStepFactory {
35
35
36
36
@ Override
37
37
public FormatterStep newFormatterStep (FormatterStepConfig config ) {
38
- if (name == null || search == null || replacement == null ) {
39
- throw new IllegalArgumentException ("Must specify 'name', 'search' and 'replacement '." );
38
+ if (name == null || search == null ) {
39
+ throw new IllegalArgumentException ("Must specify 'name' and 'search '." );
40
40
}
41
-
42
- return ReplaceStep .create (name , search , replacement );
41
+ // Use empty string if replacement is not provided. In pom.xml there is no way to specify
42
+ // an empty string as a property value as maven will always trim the value and if it is
43
+ // empty, maven will consider the property as not provided.
44
+ return ReplaceStep .create (name , search , replacement != null ? replacement : "" );
43
45
}
44
46
}
Original file line number Diff line number Diff line change 1
1
/*
2
- * Copyright 2016 DiffPlug
2
+ * Copyright 2016-2022 DiffPlug
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
@@ -35,10 +35,12 @@ public class ReplaceRegex implements FormatterStepFactory {
35
35
36
36
@ Override
37
37
public FormatterStep newFormatterStep (FormatterStepConfig config ) {
38
- if (name == null || searchRegex == null || replacement == null ) {
39
- throw new IllegalArgumentException ("Must specify 'name', 'searchRegex' and 'replacement '." );
38
+ if (name == null || searchRegex == null ) {
39
+ throw new IllegalArgumentException ("Must specify 'name' and 'searchRegex '." );
40
40
}
41
-
42
- return ReplaceRegexStep .create (name , searchRegex , replacement );
41
+ // Use empty string if replacement is not provided. In pom.xml there is no way to specify
42
+ // an empty string as a property value as maven will always trim the value and if it is
43
+ // empty, maven will consider the property as not provided.
44
+ return ReplaceRegexStep .create (name , searchRegex , replacement != null ? replacement : "" );
43
45
}
44
46
}
You can’t perform that action at this time.
0 commit comments