File tree Expand file tree Collapse file tree 11 files changed +173
-5
lines changed
sbm-core/src/main/java/org/springframework/sbm
sbm-support-boot/src/main/resources/recipes Expand file tree Collapse file tree 11 files changed +173
-5
lines changed Original file line number Diff line number Diff line change 15
15
*/
16
16
package org .springframework .sbm .build .migration .actions ;
17
17
18
- import org .springframework .sbm .build .api .BuildFile ;
19
18
import org .springframework .sbm .build .api .Dependency ;
20
19
import org .springframework .sbm .engine .recipe .AbstractAction ;
21
20
import org .springframework .sbm .engine .context .ProjectContext ;
@@ -39,7 +38,7 @@ public class AddDependencies extends AbstractAction {
39
38
40
39
@ Override
41
40
public void apply (ProjectContext context ) {
42
- BuildFile buildFile = context .getBuildFile ();
43
- buildFile .addDependencies (dependencies );
41
+ dependencies .forEach (d -> context .getBuildFile ().addDependency (d ));
44
42
}
43
+
45
44
}
Original file line number Diff line number Diff line change
1
+ /*
2
+ * Copyright 2021 - 2022 the original author or authors.
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
+ * https://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
+ */
16
+
17
+ package org .springframework .sbm .build .migration .actions ;
18
+
19
+ import org .springframework .sbm .build .api .ApplicationModules ;
20
+ import org .springframework .sbm .build .api .Dependency ;
21
+ import org .springframework .sbm .engine .context .ProjectContext ;
22
+
23
+ public interface AddDependenciesMultiModuleHandler {
24
+ void handle (ProjectContext context , Dependency d );
25
+ }
Original file line number Diff line number Diff line change
1
+ /*
2
+ * Copyright 2021 - 2022 the original author or authors.
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
+ * https://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
+ */
16
+
17
+ package org .springframework .sbm .build .migration .actions ;
18
+
19
+ import org .springframework .sbm .build .api .Dependency ;
20
+ import org .springframework .sbm .engine .context .ProjectContext ;
21
+
22
+ public class AddDependenciesToApplicationModules implements AddDependenciesMultiModuleHandler {
23
+ @ Override
24
+ public void handle (ProjectContext context , Dependency d ) {
25
+ if (!context .getApplicationModules ().isSingleModuleApplication ()) {
26
+ context .getApplicationModules ().getTopmostApplicationModules ().forEach (m -> m .getBuildFile ().addDependency (d ));
27
+ }
28
+ }
29
+ }
Original file line number Diff line number Diff line change 20
20
import org .springframework .sbm .engine .context .ProjectContext ;
21
21
import lombok .Getter ;
22
22
import lombok .Setter ;
23
+ import org .springframework .sbm .engine .recipe .MultiModuleAwareAction ;
23
24
24
25
import javax .validation .Valid ;
25
26
26
27
@ Getter
27
- public class AddMavenPlugin extends AbstractAction {
28
+ public class AddMavenPlugin extends MultiModuleAwareAction {
28
29
29
30
@ Setter
30
31
@ Valid
Original file line number Diff line number Diff line change
1
+ /*
2
+ * Copyright 2021 - 2022 the original author or authors.
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
+ * https://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
+ */
16
+
17
+ package org .springframework .sbm .build .migration .actions ;
18
+
19
+ public class AddMavenPluginToApplicationModules implements AddMavenPluginToMultiModuleHandler {
20
+ }
Original file line number Diff line number Diff line change
1
+ /*
2
+ * Copyright 2021 - 2022 the original author or authors.
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
+ * https://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
+ */
16
+
17
+ package org .springframework .sbm .build .migration .actions ;
18
+
19
+ public interface AddMavenPluginToMultiModuleHandler {
20
+ }
Original file line number Diff line number Diff line change 23
23
import lombok .experimental .SuperBuilder ;
24
24
import org .springframework .beans .factory .annotation .Autowired ;
25
25
import org .springframework .context .ApplicationEventPublisher ;
26
+ import org .springframework .sbm .engine .context .ProjectContext ;
26
27
27
28
import javax .validation .constraints .NotBlank ;
28
29
@@ -52,6 +53,11 @@ public String getDetailedDescription() {
52
53
return conditionDescription + getDescription ();
53
54
}
54
55
56
+ @ Override
57
+ public void applyInternal (ProjectContext context ) {
58
+ apply (context );
59
+ }
60
+
55
61
@ Override
56
62
public boolean isAutomated () {
57
63
return !this .getClass ().isAssignableFrom (DisplayDescription .class );
Original file line number Diff line number Diff line change @@ -34,7 +34,7 @@ default void applyWithStatusEvent(ProjectContext context) {
34
34
eventPublisher .publishEvent (new ActionStartedEvent (getDescription ()));
35
35
}
36
36
try {
37
- apply (context );
37
+ applyInternal (context );
38
38
} catch (Exception e ) {
39
39
throw new ActionFailedException ("'" +this .getDescription ()+"' failed: " + e .getMessage (), e );
40
40
}
@@ -43,6 +43,8 @@ default void applyWithStatusEvent(ProjectContext context) {
43
43
}
44
44
}
45
45
46
+ void applyInternal (ProjectContext context );
47
+
46
48
ApplicationEventPublisher getEventPublisher ();
47
49
48
50
boolean isAutomated ();
Original file line number Diff line number Diff line change
1
+ /*
2
+ * Copyright 2021 - 2022 the original author or authors.
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
+ * https://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
+ */
16
+
17
+ package org .springframework .sbm .engine .recipe ;
18
+
19
+ import lombok .Setter ;
20
+ import org .springframework .beans .factory .annotation .Autowired ;
21
+ import org .springframework .sbm .build .api .ApplicationModule ;
22
+ import org .springframework .sbm .build .migration .actions .AddDependenciesToApplicationModules ;
23
+ import org .springframework .sbm .engine .context .ProjectContext ;
24
+
25
+ public abstract class MultiModuleAwareAction extends AbstractAction {
26
+
27
+ @ Autowired
28
+ @ Setter
29
+ private MultiModuleHandler multiModuleHandler ;
30
+
31
+ @ Override
32
+ public void applyInternal (ProjectContext context ) {
33
+ if (context .getApplicationModules ().isSingleModuleApplication ()) {
34
+ apply (context );
35
+ } else {
36
+ multiModuleHandler .handle (context );
37
+ }
38
+ }
39
+ }
Original file line number Diff line number Diff line change
1
+ /*
2
+ * Copyright 2021 - 2022 the original author or authors.
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
+ * https://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
+ */
16
+
17
+ package org .springframework .sbm .engine .recipe ;
18
+
19
+ import org .springframework .sbm .engine .context .ProjectContext ;
20
+
21
+ public interface MultiModuleHandler {
22
+ void handle (ProjectContext context );
23
+ }
Original file line number Diff line number Diff line change 53
53
artifactId : spring-boot-starter-test
54
54
version : 2.6.3
55
55
scope : test
56
+ multiModuleHandler :
57
+ type : org.springframework.sbm.build.migration.actions.AddDependenciesToApplicationModules
56
58
description : Add spring dependencies 'spring-boot-starter' and 'spring-boot-starter-test'.
57
59
detailedDescription : |-
58
60
This code snippet is going to be added to the <dependencies> section in pom.xml
92
94
plugin :
93
95
groupId : org.springframework.boot
94
96
artifactId : spring-boot-maven-plugin
97
+ multiModuleHandler :
98
+ type : org.springframework.sbm.build.migration.actions.AddMavenPluginToApplicationModules
95
99
description : Add Spring Boot Maven plugin.
96
100
detailedDescription : |
97
101
You can’t perform that action at this time.
0 commit comments