获取源误差建设Groovy项目使用Maven(Getting a source error buil

2019-08-08 06:37发布

我试图建立我使用Maven第一常规项目,但我从行家收到以下错误..其源错误的somettype但Idont明白为什么我得到它。

[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3.186s
[INFO] Finished at: Fri Jan 25 15:36:09 EST 2013
[INFO] Final Memory: 15M/163M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.codehaus.gmaven:gmaven-plugin:1.3:execute (default) on project groovyhello: org.codehaus.groovy.runtime.metaclass.MissingPropertyExceptionNoStack: No such property: project for class: org.smith.Example -> [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

Process finished with exit code 1

下面是我的源代码:

package org.smith

/**
 * Example Groovy class.
 */
class Example
{
    def show() {
        println 'Hello World'
    }
}

这里是我的pom.xml文件:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">

<modelVersion>4.0.0</modelVersion>

<groupId>org.smith</groupId>
<artifactId>groovyhello</artifactId>
<name>Example Project</name>
<version>1.0-SNAPSHOT</version>

<dependencies>
    <dependency>
        <groupId>org.codehaus.groovy.maven.runtime</groupId>
        <artifactId>gmaven-runtime-1.6</artifactId>
        <version>1.0</version>
    </dependency>

    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>3.8.1</version>
        <scope>test</scope>
    </dependency>
</dependencies>

<build>
    <plugins>


        <plugin>
            <groupId>org.codehaus.gmaven</groupId>
            <artifactId>gmaven-plugin</artifactId>
            <version>1.3</version>
            <executions>
                <execution>
                    <phase>generate-resources</phase>
                    <goals>
                        <goal>execute</goal>
                    </goals>
                    <configuration>
                        <source>${pom.basedir}/src/main/groovy/org/smith/Example.groovy</source>
                    </configuration>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

Answer 1:

你的第一个线索是错误: No such property: project for class: org.jsmith.Example道歉重申你的错误作为你的答案,但让我解释一下。 它说,在某处你的源必须将一个变量的引用project 。 (可能的来源,你有没有在源发布的或可能之前你inadvertnly改变它,你发布之前?)

我想你可能曾在包名或类定义后,一些额外的测试代码一个错字? 对于EG。 这样的事情可能会产生这样的错误:

package org.smith

/**
 * Example Groovy class.
 */
class Example
{
    def show() {
        println 'Hello World'
    }
}
println project.path

再次,你应该张贴无论是在错误的时间更新的代码和匹配的代码确切的错误。 很难根据你上面有你的地方问题出什么来确定。



Answer 2:

您必须确定项目,如果您使用的脚本,而不是在线绑定到mavenProject。

def project = ${project}; // this will bind to the Maven Project property.

同样

def session = ${session} //will bind to MavenSession

来源 -寻找自定义属性



文章来源: Getting a source error building Groovy project with Maven