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 24
24
import org .codehaus .groovy .control .SourceUnit ;
25
25
import org .codehaus .groovy .transform .ASTTransformation ;
26
26
import org .springframework .boot .cli .compiler .grape .DependencyResolutionContext ;
27
+ import org .springframework .core .annotation .Order ;
27
28
28
29
/**
29
30
* {@link ASTTransformation} to apply
34
35
* @author Dave Syer
35
36
* @author Andy Wilkinson
36
37
*/
38
+ @ Order (DependencyAutoConfigurationTransformation .ORDER )
37
39
public class DependencyAutoConfigurationTransformation implements ASTTransformation {
38
40
41
+ public static final int ORDER = GrabMetadataTransformation .ORDER + 100 ;
42
+
39
43
private final GroovyClassLoader loader ;
40
44
41
45
private final DependencyResolutionContext dependencyResolutionContext ;
Original file line number Diff line number Diff line change 43
43
import org .springframework .boot .dependency .tools .ManagedDependencies ;
44
44
import org .springframework .boot .dependency .tools .PropertiesFileDependencies ;
45
45
import org .springframework .boot .groovy .GrabMetadata ;
46
+ import org .springframework .core .Ordered ;
47
+ import org .springframework .core .annotation .Order ;
46
48
47
49
/**
48
50
* {@link ASTTransformation} for processing {@link GrabMetadata @GrabMetadata}
49
51
*
50
52
* @author Andy Wilkinson
51
53
* @since 1.1.0
52
54
*/
55
+ @ Order (GrabMetadataTransformation .ORDER )
53
56
public class GrabMetadataTransformation extends AnnotatedNodeASTTransformation {
54
57
58
+ public static final int ORDER = Ordered .HIGHEST_PRECEDENCE ;
59
+
55
60
private static final Set <String > GRAB_METADATA_ANNOTATION_NAMES = Collections
56
61
.unmodifiableSet (new HashSet <String >(Arrays .asList (
57
62
GrabMetadata .class .getName (), GrabMetadata .class .getSimpleName ())));
Original file line number Diff line number Diff line change 29
29
import org .codehaus .groovy .ast .stmt .BlockStatement ;
30
30
import org .codehaus .groovy .control .SourceUnit ;
31
31
import org .codehaus .groovy .transform .ASTTransformation ;
32
+ import org .springframework .core .annotation .Order ;
32
33
33
34
/**
34
35
* {@link ASTTransformation} to resolve beans declarations inside application source
38
39
*
39
40
* @author Dave Syer
40
41
*/
42
+ @ Order (GroovyBeansTransformation .ORDER )
41
43
public class GroovyBeansTransformation implements ASTTransformation {
42
44
45
+ public static final int ORDER = GrabMetadataTransformation .ORDER + 200 ;
46
+
43
47
@ Override
44
48
public void visit (ASTNode [] nodes , SourceUnit source ) {
45
49
for (ASTNode node : nodes ) {
Original file line number Diff line number Diff line change 47
47
import org .springframework .boot .cli .compiler .grape .DependencyResolutionContext ;
48
48
import org .springframework .boot .cli .compiler .grape .GrapeEngineInstaller ;
49
49
import org .springframework .boot .cli .util .ResourceUtils ;
50
+ import org .springframework .core .annotation .AnnotationAwareOrderComparator ;
50
51
51
52
/**
52
53
* Compiler for Groovy sources. Primarily a simple Facade for
@@ -112,6 +113,11 @@ public GroovyCompiler(final GroovyCompilerConfiguration configuration) {
112
113
this .transformations .add (new ResolveDependencyCoordinatesTransformation (
113
114
resolutionContext ));
114
115
}
116
+ for (ASTTransformation transformation : ServiceLoader
117
+ .load (SpringBootAstTransformation .class )) {
118
+ this .transformations .add (transformation );
119
+ }
120
+ Collections .sort (this .transformations , AnnotationAwareOrderComparator .INSTANCE );
115
121
}
116
122
117
123
/**
Original file line number Diff line number Diff line change 29
29
import org .codehaus .groovy .ast .expr .Expression ;
30
30
import org .codehaus .groovy .transform .ASTTransformation ;
31
31
import org .springframework .boot .cli .compiler .grape .DependencyResolutionContext ;
32
+ import org .springframework .core .annotation .Order ;
32
33
33
34
/**
34
35
* {@link ASTTransformation} to resolve {@link Grab} artifact coordinates.
35
36
*
36
37
* @author Andy Wilkinson
37
38
* @author Phillip Webb
38
39
*/
40
+ @ Order (ResolveDependencyCoordinatesTransformation .ORDER )
39
41
public class ResolveDependencyCoordinatesTransformation extends
40
42
AnnotatedNodeASTTransformation {
41
43
44
+ public static final int ORDER = GrabMetadataTransformation .ORDER + 300 ;
45
+
42
46
private static final Set <String > GRAB_ANNOTATION_NAMES = Collections
43
47
.unmodifiableSet (new HashSet <String >(Arrays .asList (Grab .class .getName (),
44
48
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