File tree Expand file tree Collapse file tree 6 files changed +52
-0
lines changed
spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler Expand file tree Collapse file tree 6 files changed +52
-0
lines changed Original file line number Diff line number Diff line change 2424import org .codehaus .groovy .control .SourceUnit ;
2525import org .codehaus .groovy .transform .ASTTransformation ;
2626import org .springframework .boot .cli .compiler .grape .DependencyResolutionContext ;
27+ import org .springframework .core .annotation .Order ;
2728
2829/**
2930 * {@link ASTTransformation} to apply
3435 * @author Dave Syer
3536 * @author Andy Wilkinson
3637 */
38+ @ Order (DependencyAutoConfigurationTransformation .ORDER )
3739public class DependencyAutoConfigurationTransformation implements ASTTransformation {
3840
41+ public static final int ORDER = GrabMetadataTransformation .ORDER + 100 ;
42+
3943 private final GroovyClassLoader loader ;
4044
4145 private final DependencyResolutionContext dependencyResolutionContext ;
Original file line number Diff line number Diff line change 4343import org .springframework .boot .dependency .tools .ManagedDependencies ;
4444import org .springframework .boot .dependency .tools .PropertiesFileDependencies ;
4545import org .springframework .boot .groovy .GrabMetadata ;
46+ import org .springframework .core .Ordered ;
47+ import org .springframework .core .annotation .Order ;
4648
4749/**
4850 * {@link ASTTransformation} for processing {@link GrabMetadata @GrabMetadata}
4951 *
5052 * @author Andy Wilkinson
5153 * @since 1.1.0
5254 */
55+ @ Order (GrabMetadataTransformation .ORDER )
5356public class GrabMetadataTransformation extends AnnotatedNodeASTTransformation {
5457
58+ public static final int ORDER = Ordered .HIGHEST_PRECEDENCE ;
59+
5560 private static final Set <String > GRAB_METADATA_ANNOTATION_NAMES = Collections
5661 .unmodifiableSet (new HashSet <String >(Arrays .asList (
5762 GrabMetadata .class .getName (), GrabMetadata .class .getSimpleName ())));
Original file line number Diff line number Diff line change 2929import org .codehaus .groovy .ast .stmt .BlockStatement ;
3030import org .codehaus .groovy .control .SourceUnit ;
3131import org .codehaus .groovy .transform .ASTTransformation ;
32+ import org .springframework .core .annotation .Order ;
3233
3334/**
3435 * {@link ASTTransformation} to resolve beans declarations inside application source
3839 *
3940 * @author Dave Syer
4041 */
42+ @ Order (GroovyBeansTransformation .ORDER )
4143public class GroovyBeansTransformation implements ASTTransformation {
4244
45+ public static final int ORDER = GrabMetadataTransformation .ORDER + 200 ;
46+
4347 @ Override
4448 public void visit (ASTNode [] nodes , SourceUnit source ) {
4549 for (ASTNode node : nodes ) {
Original file line number Diff line number Diff line change 4747import org .springframework .boot .cli .compiler .grape .DependencyResolutionContext ;
4848import org .springframework .boot .cli .compiler .grape .GrapeEngineInstaller ;
4949import org .springframework .boot .cli .util .ResourceUtils ;
50+ import org .springframework .core .annotation .AnnotationAwareOrderComparator ;
5051
5152/**
5253 * Compiler for Groovy sources. Primarily a simple Facade for
@@ -112,6 +113,11 @@ public GroovyCompiler(final GroovyCompilerConfiguration configuration) {
112113 this .transformations .add (new ResolveDependencyCoordinatesTransformation (
113114 resolutionContext ));
114115 }
116+ for (ASTTransformation transformation : ServiceLoader
117+ .load (SpringBootAstTransformation .class )) {
118+ this .transformations .add (transformation );
119+ }
120+ Collections .sort (this .transformations , AnnotationAwareOrderComparator .INSTANCE );
115121 }
116122
117123 /**
Original file line number Diff line number Diff line change 2929import org .codehaus .groovy .ast .expr .Expression ;
3030import org .codehaus .groovy .transform .ASTTransformation ;
3131import org .springframework .boot .cli .compiler .grape .DependencyResolutionContext ;
32+ import org .springframework .core .annotation .Order ;
3233
3334/**
3435 * {@link ASTTransformation} to resolve {@link Grab} artifact coordinates.
3536 *
3637 * @author Andy Wilkinson
3738 * @author Phillip Webb
3839 */
40+ @ Order (ResolveDependencyCoordinatesTransformation .ORDER )
3941public class ResolveDependencyCoordinatesTransformation extends
4042 AnnotatedNodeASTTransformation {
4143
44+ public static final int ORDER = GrabMetadataTransformation .ORDER + 300 ;
45+
4246 private static final Set <String > GRAB_ANNOTATION_NAMES = Collections
4347 .unmodifiableSet (new HashSet <String >(Arrays .asList (Grab .class .getName (),
4448 Grab .class .getSimpleName ())));
Original file line number Diff line number Diff line change 1+ /*
2+ * Copyright 2012-2014 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+ * 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+ */
16+
17+ package org .springframework .boot .cli .compiler ;
18+
19+ import org .codehaus .groovy .transform .ASTTransformation ;
20+
21+ /**
22+ * Marker interface for AST transformations that should be installed automatically from
23+ * META-INF/services
24+ *
25+ * @author Dave Syer
26+ */
27+ public interface SpringBootAstTransformation extends ASTTransformation {
28+
29+ }
You can’t perform that action at this time.
0 commit comments