我想在mule项目的maven构建中使用groovy。因此,我开始使用pom.xml中的gmaven插件
,并在/src/main/resources下添加了test.groovy
。
< code>test.groovy的内容
println "Hello, world Maven with Groovy***********************************************!"
println "Entry****"
println "Exit****"
pom. xml
中的插件
<plugin>
<groupId>org.codehaus.groovy.maven</groupId>
<artifactId>gmaven-plugin</artifactId>
<version>1.0</version>
<executions>
<execution>
<id>call-groovy</id>
<!-- <phase>prepare-package</phase> -->
<phase>compile</phase>
<goals>
<goal>execute</goal>
</goals>
<configuration>
<source>src/main/resources/test.groovy</source>
</configuration>
</execution>
</executions>
<configuration>
<source>src/main/resources/test.groovy</source>
<!-- This to call the source without using execution id in mvn command-->
</configuration>
</plugin>
当我从项目的根文件夹运行以下任何 mvn 命令时,脚本已成功执行并在命令提示符下显示消息。
MVN org.codehaus.groovy.maven:gmaven-plugin:execute
插件execute@call-groovy
mvn清洁包
但是当我在Anypoint studio(一个基于eclipse的集成工具)中运行相同的项目时,我收到以下错误。我已经检查了窗户
我想知道为什么会发生此错误或我做错了什么?帮助!!!
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building sys-kitty 1.0.5-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:3.0.0:clean (default-clean-1) @ sys-kitty ---
[INFO] Deleting D:\Heisenberg\sys-kitty\target
[INFO]
[INFO] --- maven-clean-plugin:3.0.0:clean (default-clean) @ sys-kitty ---
[INFO]
[INFO] --- mule-maven-plugin:3.3.5:clean (default-clean) @ sys-kitty ---
[INFO]
[INFO] --- mule-maven-plugin:3.3.5:validate (default-validate) @ sys-kitty ---
[INFO]
[INFO] --- mule-maven-plugin:3.3.5:initialize (default-initialize) @ sys-kitty ---
[INFO]
[INFO] --- mule-maven-plugin:3.3.5:generate-sources (default-generate-sources) @ sys-kitty ---
[INFO]
[INFO] --- mule-maven-plugin:3.3.5:process-sources (default-process-sources) @ sys-kitty ---
[INFO] About to fetch required dependencies for artifact: 9f62fda4-113d-407f-96eb-ef93fb78a31d:sys-kitty:pom:1.0.5-SNAPSHOT. This may take a while...
[INFO]
[INFO] --- maven-resources-plugin:3.0.2:resources (default-resources) @ sys-kitty ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 3 resources
[INFO]
[INFO] --- mule-maven-plugin:3.3.5:process-resources (default-process-resources) @ sys-kitty ---
[INFO]
[INFO] --- maven-compiler-plugin:3.8.0:compile (default-compile) @ sys-kitty ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- mule-maven-plugin:3.3.5:compile (default-compile) @ sys-kitty ---
[INFO]
[INFO] --- gmaven-plugin:1.0:execute (call-groovy) @ sys-kitty ---
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 11.556 s
[INFO] Finished at: 2021-06-11T18:21:45+05:30
[INFO] Final Memory: 273M/872M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.codehaus.groovy.maven:gmaven-plugin:1.0:execute (call-groovy) on project sys-kitty: groovy.lang.MissingPropertyException: No such property: src for class: script1623415903180 -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
它似乎可以与当前Anypoint Studio的最后一个版本Studio 7.9.0一起工作。你应该下载上一个版本试试。
我建议将插件升级到最新版本,因为提到的那个版本非常旧。
例子:
<groupId>org.codehaus.gmaven</groupId>
<artifactId>groovy-maven-plugin</artifactId>
<version>2.1.1</version>