Skip to content

Commit 2870d06

Browse files
committed
Run spotlessApply
1 parent e868f63 commit 2870d06

File tree

5 files changed

+86
-38
lines changed

5 files changed

+86
-38
lines changed

plugin-maven/src/main/java/com/diffplug/spotless/maven/AbstractSpotlessMojo.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2016-2023 DiffPlug
2+
* Copyright 2016-2024 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.
@@ -38,7 +38,6 @@
3838
import java.util.stream.Stream;
3939
import java.util.stream.StreamSupport;
4040

41-
import com.diffplug.spotless.maven.go.Go;
4241
import org.apache.maven.plugin.AbstractMojo;
4342
import org.apache.maven.plugin.MojoExecutionException;
4443
import org.apache.maven.plugins.annotations.Component;
@@ -63,6 +62,7 @@
6362
import com.diffplug.spotless.maven.generic.Format;
6463
import com.diffplug.spotless.maven.generic.LicenseHeader;
6564
import com.diffplug.spotless.maven.gherkin.Gherkin;
65+
import com.diffplug.spotless.maven.go.Go;
6666
import com.diffplug.spotless.maven.groovy.Groovy;
6767
import com.diffplug.spotless.maven.incremental.UpToDateChecker;
6868
import com.diffplug.spotless.maven.incremental.UpToDateChecking;
Lines changed: 30 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,39 @@
1+
/*
2+
* Copyright 2024 DiffPlug
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
116
package com.diffplug.spotless.maven.go;
217

3-
import com.diffplug.spotless.maven.FormatterFactory;
4-
import org.apache.maven.project.MavenProject;
5-
618
import java.util.Collections;
719
import java.util.Set;
820

21+
import org.apache.maven.project.MavenProject;
22+
23+
import com.diffplug.spotless.maven.FormatterFactory;
24+
925
public class Go extends FormatterFactory {
10-
@Override
11-
public Set<String> defaultIncludes(MavenProject project) {
12-
return Collections.emptySet();
13-
}
26+
@Override
27+
public Set<String> defaultIncludes(MavenProject project) {
28+
return Collections.emptySet();
29+
}
1430

15-
@Override
16-
public String licenseHeaderDelimiter() {
17-
return null;
18-
}
31+
@Override
32+
public String licenseHeaderDelimiter() {
33+
return null;
34+
}
1935

20-
public void addGofmt(Gofmt gofmt) {
21-
addStepFactory(gofmt);
22-
}
36+
public void addGofmt(Gofmt gofmt) {
37+
addStepFactory(gofmt);
38+
}
2339
}
Lines changed: 29 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,41 @@
1+
/*
2+
* Copyright 2024 DiffPlug
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
116
package com.diffplug.spotless.maven.go;
217

18+
import org.apache.maven.plugins.annotations.Parameter;
19+
320
import com.diffplug.spotless.FormatterStep;
421
import com.diffplug.spotless.go.GofmtFormatStep;
522
import com.diffplug.spotless.maven.FormatterStepConfig;
623
import com.diffplug.spotless.maven.FormatterStepFactory;
7-
import org.apache.maven.plugins.annotations.Parameter;
824

925
public class Gofmt implements FormatterStepFactory {
1026

11-
@Parameter
12-
private String version;
27+
@Parameter
28+
private String version;
1329

14-
@Parameter
15-
private String goExecutablePath;
30+
@Parameter
31+
private String goExecutablePath;
1632

17-
@Override
18-
public FormatterStep newFormatterStep(FormatterStepConfig config) {
19-
GofmtFormatStep step = GofmtFormatStep.withVersion(version == null ? GofmtFormatStep.defaultVersion() : version);
20-
if (goExecutablePath != null) {
21-
step = step.withGoExecutable(goExecutablePath);
22-
}
23-
return step.create();
24-
}
33+
@Override
34+
public FormatterStep newFormatterStep(FormatterStepConfig config) {
35+
GofmtFormatStep step = GofmtFormatStep.withVersion(version == null ? GofmtFormatStep.defaultVersion() : version);
36+
if (goExecutablePath != null) {
37+
step = step.withGoExecutable(goExecutablePath);
38+
}
39+
return step.create();
40+
}
2541
}

plugin-maven/src/test/java/com/diffplug/spotless/maven/MavenIntegrationHarness.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2016-2023 DiffPlug
2+
* Copyright 2016-2024 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.
Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,32 @@
1+
/*
2+
* Copyright 2024 DiffPlug
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
116
package com.diffplug.spotless.maven.go;
217

3-
import com.diffplug.spotless.maven.MavenIntegrationHarness;
418
import org.junit.jupiter.api.Test;
519

20+
import com.diffplug.spotless.maven.MavenIntegrationHarness;
21+
622
@com.diffplug.spotless.tag.GofmtTest
723
public class GofmtTest extends MavenIntegrationHarness {
8-
@Test
9-
void testGofmt() throws Exception {
10-
writePomWithGoSteps("<gofmt><version>go1.21.5</version></gofmt>");
24+
@Test
25+
void testGofmt() throws Exception {
26+
writePomWithGoSteps("<gofmt><version>go1.21.5</version></gofmt>");
1127

12-
setFile("src/main/go/example.go").toResource("go/gofmt/go.dirty");
13-
mavenRunner().withArguments("spotless:apply").runNoError();
14-
assertFile("src/main/go/example.go").sameAsResource("go/gofmt/go.clean");
15-
}
28+
setFile("src/main/go/example.go").toResource("go/gofmt/go.dirty");
29+
mavenRunner().withArguments("spotless:apply").runNoError();
30+
assertFile("src/main/go/example.go").sameAsResource("go/gofmt/go.clean");
31+
}
1632
}

0 commit comments

Comments
 (0)