【发布时间】:2021-06-11 22:54:30
【问题描述】:
我想在我的 mule 项目的 maven 构建中使用 groovy。所以,我继续使用下面 pom.xml 中给出的gmaven plugin,我还在 /src/main/resources 下添加了test.groovy。
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
mvn org.codehaus.groovy.maven:gmaven-plugin:execute@call-groovy
mvn clean package
但是当我在基于 Eclipse 的集成工具 Anypoint studio 中运行相同的项目时,我收到以下错误。我已经检查了windows > preferences > maven,并尝试使用上述所有 maven 命令作为程序的一部分运行。
我想知道为什么会发生这个错误或者我做错了什么?救命!!!
错误如下
[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
【问题讨论】: