Support simple @Grab annotations everywhere
Previously, simple @Grab annotations only worked on classes. This commit updates the simple @Grab support so that they can be used on anything that can be annotated with @Grab. The simplified @Grab support relies upon springcli.properties having been generated. This commit adds an M2E lifecycle mapping for the antrun plugin so that springcli.properties is generated as part of an Eclipse build, thereby making it easier to run tests in Eclipse that rely upon the simplified @Grab support.
This commit is contained in:
parent
0ec2d19e38
commit
97f93bfa64
|
|
@ -205,6 +205,36 @@
|
|||
</dependencies>
|
||||
</plugin>
|
||||
</plugins>
|
||||
<pluginManagement>
|
||||
<plugins>
|
||||
<!--This plugin's configuration is used to store Eclipse m2e settings only. It has no influence on the Maven build itself.-->
|
||||
<plugin>
|
||||
<groupId>org.eclipse.m2e</groupId>
|
||||
<artifactId>lifecycle-mapping</artifactId>
|
||||
<version>1.0.0</version>
|
||||
<configuration>
|
||||
<lifecycleMappingMetadata>
|
||||
<pluginExecutions>
|
||||
<pluginExecution>
|
||||
<pluginExecutionFilter>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-antrun-plugin
|
||||
</artifactId>
|
||||
<versionRange>[1.7,)</versionRange>
|
||||
<goals>
|
||||
<goal>run</goal>
|
||||
</goals>
|
||||
</pluginExecutionFilter>
|
||||
<action>
|
||||
<execute/>
|
||||
</action>
|
||||
</pluginExecution>
|
||||
</pluginExecutions>
|
||||
</lifecycleMappingMetadata>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</pluginManagement>
|
||||
</build>
|
||||
<pluginRepositories>
|
||||
<pluginRepository>
|
||||
|
|
|
|||
|
|
@ -1,8 +1,7 @@
|
|||
package org.test
|
||||
|
||||
@Grab("org.apache.activemq:activemq-all:5.4.0")
|
||||
@Grab("org.apache.activemq:activemq-pool:5.4.0")
|
||||
|
||||
@Grab("activemq-pool")
|
||||
import java.util.concurrent.CountDownLatch
|
||||
|
||||
@Log
|
||||
|
|
|
|||
|
|
@ -31,8 +31,11 @@ import java.util.List;
|
|||
import java.util.ServiceLoader;
|
||||
|
||||
import org.codehaus.groovy.ast.ASTNode;
|
||||
import org.codehaus.groovy.ast.AnnotatedNode;
|
||||
import org.codehaus.groovy.ast.AnnotationNode;
|
||||
import org.codehaus.groovy.ast.ClassCodeVisitorSupport;
|
||||
import org.codehaus.groovy.ast.ClassNode;
|
||||
import org.codehaus.groovy.ast.ImportNode;
|
||||
import org.codehaus.groovy.ast.ModuleNode;
|
||||
import org.codehaus.groovy.ast.expr.ConstantExpression;
|
||||
import org.codehaus.groovy.ast.expr.Expression;
|
||||
|
|
@ -263,13 +266,31 @@ public class GroovyCompiler {
|
|||
for (ASTNode node : nodes) {
|
||||
if (node instanceof ModuleNode) {
|
||||
ModuleNode module = (ModuleNode) node;
|
||||
for (ClassNode classNode : module.getClasses()) {
|
||||
for (AnnotationNode annotationNode : classNode.getAnnotations()) {
|
||||
if (isGrabAnnotation(annotationNode)) {
|
||||
transformGrabAnnotationIfNecessary(annotationNode);
|
||||
}
|
||||
}
|
||||
for (ImportNode importNode : module.getImports()) {
|
||||
visitAnnotatedNode(importNode);
|
||||
}
|
||||
for (ClassNode classNode : module.getClasses()) {
|
||||
visitAnnotatedNode(classNode);
|
||||
classNode.visitContents(new ClassCodeVisitorSupport() {
|
||||
@Override
|
||||
protected SourceUnit getSourceUnit() {
|
||||
return source;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitAnnotations(AnnotatedNode node) {
|
||||
visitAnnotatedNode(node);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void visitAnnotatedNode(AnnotatedNode annotatedNode) {
|
||||
for (AnnotationNode annotationNode : annotatedNode.getAnnotations()) {
|
||||
if (isGrabAnnotation(annotationNode)) {
|
||||
transformGrabAnnotationIfNecessary(annotationNode);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue