48
48
49
49
public final class IdeaStep {
50
50
51
+ private static final Logger LOGGER = LoggerFactory .getLogger (IdeaStep .class );
52
+
51
53
public static final String NAME = "IDEA" ;
52
54
53
55
public static final String IDEA_EXECUTABLE_DEFAULT = "idea" ;
54
56
55
- private static final Logger LOGGER = LoggerFactory .getLogger (IdeaStep .class );
56
57
public static final String IDEA_CONFIG_PATH_PROPERTY = "idea.config.path" ;
57
58
public static final String IDEA_SYSTEM_PATH_PROPERTY = "idea.system.path" ;
59
+ @ Nonnull
60
+ private final IdeaStepBuilder builder ;
58
61
59
- private IdeaStep () {}
62
+ private IdeaStep (@ Nonnull IdeaStepBuilder builder ) {
63
+ this .builder = builder ;
64
+ }
60
65
61
- public static IdeaStepBuilder create (@ Nonnull File buildDir ) {
66
+ public static IdeaStepBuilder newBuilder (@ Nonnull File buildDir ) {
62
67
return new IdeaStepBuilder (Objects .requireNonNull (buildDir ));
63
68
}
64
69
65
- private static FormatterStep create (@ Nonnull IdeaStepBuilder builder ) {
66
- Objects .requireNonNull (builder );
67
- return FormatterStep .createLazy (NAME ,
68
- () -> createState (builder ), State ::toFunc );
70
+ private static FormatterStep create (IdeaStepBuilder builder ) {
71
+ return new IdeaStep (builder ).createFormatterStep ();
69
72
}
70
73
71
- private static State createState (@ Nonnull IdeaStepBuilder builder ) {
74
+ private FormatterStep createFormatterStep () {
75
+ return FormatterStep .createLazy (NAME , this ::createState , State ::toFunc );
76
+ }
77
+
78
+ private State createState () {
72
79
return new State (Objects .requireNonNull (builder ));
73
80
}
74
81
@@ -114,6 +121,17 @@ public IdeaStepBuilder setIdeaProperties(@Nonnull Map<String, String> ideaProper
114
121
public FormatterStep build () {
115
122
return create (this );
116
123
}
124
+
125
+ @ Override
126
+ public String toString () {
127
+ return String .format (
128
+ "IdeaStepBuilder[useDefaults=%s, binaryPath=%s, codeStyleSettingsPath=%s, ideaProperties=%s, buildDir=%s]" ,
129
+ this .useDefaults ,
130
+ this .binaryPath ,
131
+ this .codeStyleSettingsPath ,
132
+ this .ideaProperties ,
133
+ this .buildDir );
134
+ }
117
135
}
118
136
119
137
private static class State implements Serializable {
@@ -128,6 +146,7 @@ private static class State implements Serializable {
128
146
private final TreeMap <String , String > ideaProperties ;
129
147
130
148
private State (@ Nonnull IdeaStepBuilder builder ) {
149
+ LOGGER .debug ("Creating {} state with configuration {}" , NAME , builder );
131
150
this .uniqueBuildFolder = new File (builder .buildDir , UUID .randomUUID ().toString ());
132
151
this .withDefaults = builder .useDefaults ;
133
152
this .codeStyleSettingsPath = builder .codeStyleSettingsPath ;
@@ -203,7 +222,9 @@ private String format(IdeaStepFormatterCleanupResources ideaStepFormatterCleanup
203
222
List <String > params = getParams (tempFile );
204
223
205
224
Map <String , String > env = createEnv ();
225
+ LOGGER .info ("Launching IDEA formatter for orig file {} with params: {} and env: {}" , file , params , env );
206
226
var result = ideaStepFormatterCleanupResources .runner .exec (null , env , null , params );
227
+ LOGGER .debug ("command finished with exit code: {}" , result .exitCode ());
207
228
LOGGER .debug ("command finished with stdout: {}" ,
208
229
result .assertExitZero (StandardCharsets .UTF_8 ));
209
230
return Files .readString (tempFile .toPath (), StandardCharsets .UTF_8 );
@@ -236,6 +257,7 @@ private File createIdeaPropertiesFile() {
236
257
properties .put (IDEA_CONFIG_PATH_PROPERTY , ThrowingEx .get (configPath .toFile ()::getCanonicalPath ));
237
258
properties .put (IDEA_SYSTEM_PATH_PROPERTY , ThrowingEx .get (systemPath .toFile ()::getCanonicalPath ));
238
259
260
+ LOGGER .debug ("Creating IDEA properties file at {} with content: {}" , ideaProps , properties );
239
261
try (FileOutputStream out = new FileOutputStream (ideaProps .toFile ())) {
240
262
properties .store (out , "Generated by spotless" );
241
263
} catch (IOException e ) {
0 commit comments