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 11/*
2- * Copyright 2016 DiffPlug
2+ * Copyright 2016-2022 DiffPlug
33 *
44 * Licensed under the Apache License, Version 2.0 (the "License");
55 * you may not use this file except in compliance with the License.
@@ -35,10 +35,12 @@ public class Replace implements FormatterStepFactory {
3535
3636 @ Override
3737 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 '." );
4040 }
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 : "" );
4345 }
4446}
Original file line number Diff line number Diff line change 11/*
2- * Copyright 2016 DiffPlug
2+ * Copyright 2016-2022 DiffPlug
33 *
44 * Licensed under the Apache License, Version 2.0 (the "License");
55 * you may not use this file except in compliance with the License.
@@ -35,10 +35,12 @@ public class ReplaceRegex implements FormatterStepFactory {
3535
3636 @ Override
3737 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 '." );
4040 }
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 : "" );
4345 }
4446}
You can’t perform that action at this time.
0 commit comments