1

我有以下用于 spock 的 Maven 配置。

<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.test</groupId>
<artifactId>spock</artifactId>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<name>spock</name>
<url>http://maven.apache.org</url>

<properties>
    <!-- <maven.test.search.classdir>true</maven.test.search.classdir> -->
    <targetJdk>1.6</targetJdk>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <spring.version>3.2.1.RELEASE</spring.version>
</properties>

<dependencies>
    <!-- testing with spock -->
    <dependency>
        <groupId>org.spockframework</groupId>
        <artifactId>spock-core</artifactId>
        <version>0.6-groovy-1.8</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.codehaus.groovy</groupId>
        <artifactId>groovy</artifactId>
        <version>2.1.1</version>
        <scope>test</scope>
    </dependency>

    <!-- spring -->
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-core</artifactId>
        <version>${spring.version}</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-context</artifactId>
        <version>${spring.version}</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-beans</artifactId>
        <version>${spring.version}</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-test</artifactId>
        <version>${spring.version}</version>
        <scope>test</scope>
    </dependency>

    <dependency>
        <groupId>javax.inject</groupId>
        <artifactId>javax.inject</artifactId>
        <version>1</version>
    </dependency>


</dependencies>

<build>
    <plugins>
        <plugin>
            <groupId>org.codehaus.gmaven</groupId>
            <artifactId>gmaven-plugin</artifactId>
            <version>1.3</version>
            <configuration>
                <providerSelection>1.7</providerSelection>
            </configuration>
            <executions>
                <execution>
                    <goals>
                        <goal>testCompile</goal>
                    </goals>
                </execution>
            </executions>
            <dependencies>
                <dependency>
                    <groupId>org.codehaus.gmaven.runtime</groupId>
                    <artifactId>gmaven-runtime-1.7</artifactId>
                    <version>1.3</version>
                    <exclusions>
                        <exclusion>
                            <groupId>org.codehaus.groovy</groupId>
                            <artifactId>groovy-all</artifactId>
                        </exclusion>
                    </exclusions>
                </dependency>
                <dependency>
                    <groupId>org.codehaus.groovy</groupId>
                    <artifactId>groovy-all</artifactId>
                    <version>1.8.6</version>
                </dependency>
            </dependencies>
        </plugin>

    </plugins>
</build>

它在终端中运行良好,但在 STS/Eclipse 中,IDE 向我显示以下错误:

Plugin execution not covered by lifecycle configuration: org.codehaus.gmaven:gmaven-plugin:1.3:testCompile (execution: default, phase: test-compile)

我不确定要添加什么。

4

1 回答 1

0

你可以试试,

 <plugin>
        <groupId>org.codehaus.gmavenplus</groupId>
        <artifactId>gmavenplus-plugin</artifactId>
        <version>1.5</version>
        <executions>
            <execution>
                <goals>
                    <!-- Adds Groovy tests source to project's test source -->
                    <goal>addTestSources</goal>
                    <!-- Compiles spock tests -->
                    <goal>testCompile</goal>
                </goals>
            </execution>``
        </executions>
    </plugin>

并且还切换到 IntelliJ。这是一个非常好的IDE。

于 2016-07-01T17:53:19.077 回答