groovy目录在更新项目配置后被删除

groovy目录在更新项目配置后被删除

本文介绍了Eclipse + Maven + Groovy:src / test / groovy目录在更新项目配置后被删除的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在Eclipse中开发一个Java Web项目(STS版本2.8.1.RELEASE)和Maven(2.2.1版本)和用Groovy编写的单元测试。单元测试位于 src / test / groovy 下。此外,我使用的m2eclipse插件为Eclipse(版本1.0)和Gmaven插件在Maven(版本1.3)。



Maven中的构建工作没有问题:groovy文件被编译并作为测试执行。为了在Eclipse中进行单元测试,我将Groovy性质添加到项目中,在配置构建路径下添加文件夹src / test / groovy,并将输出文件夹设置为 target /测试的类



这个工作,直到我在Maven - >更新项目配置... 下更新项目配置。每当我从Eclipse中的源文件夹中删除目录 src / test / groovy 之后,我再次添加它并设置输出目录。



有没有我缺少的东西,或者为什么每当我更新项目配置时,Eclipse会删除我的源文件夹配置?



我的GMaven配置看起来如下:

 < plugin> 
< groupId> org.codehaus.gmaven< / groupId>
< artifactId> gmaven-plugin< / artifactId>
< version> 1.3< / version>
< configuration>
< providerSelection> 1.7< / providerSelection>
< / configuration>
<执行>
< execution>
< goals>
< goal> compile< / goal>
< goal> testCompile< / goal>
< / goals>
< / execution>
< / executions>
< / plugin>


解决方案

使用builder-helper-maven-plugin帮助。 Eclipse添加源文件夹并正确设置输出文件夹。我使用以下配置:

 < plugin> 
< groupId> org.codehaus.mojo< / groupId>
< artifactId> build-helper-maven-plugin< / artifactId>
< version> 1.7< / version>
<执行>
< execution>
< id> add-test-source< / id>
< phase> generate-test-sources< / phase>
< goals>
< goal> add-test-source< / goal>
< / goals>
< configuration>
< sources>
< source> src / test / groovy< / source>
< / sources>
< / configuration>
< / execution>
< / executions>
< / plugin>


I'm developing a Java web project in Eclipse (STS version 2.8.1.RELEASE) with Maven (version 2.2.1) and unit tests written in Groovy. The unit tests are located under src/test/groovy. Furthermore I'm using the m2eclipse plugin for Eclipse (version 1.0) and the Gmaven plugin in Maven (version 1.3).

Building in Maven works without problems: the groovy files are compiled and executed as tests. For the unit tests to work in Eclipse I added the Groovy nature to the project, added the folder src/test/groovy under Configure Build Path... and set the output folder to target/test-classes.

This works until I do an update of the project configuration under Maven -> Update Project Configuration.... After I do this every time the directory src/test/groovy gets removed from the source folders in Eclipse and I have to add it again and set the output directory.

Is there something I am missing or why is Eclipse deleting my source folder configuration every time I do an update of the project configuration?

My GMaven configuration looks as follows:

<plugin>
    <groupId>org.codehaus.gmaven</groupId>
    <artifactId>gmaven-plugin</artifactId>
    <version>1.3</version>
    <configuration>
        <providerSelection>1.7</providerSelection>
    </configuration>
    <executions>
        <execution>
            <goals>
                <goal>compile</goal>
                <goal>testCompile</goal>
            </goals>
        </execution>
    </executions>
</plugin>
解决方案

Using the builder-helper-maven-plugin helped. Eclipse adds the source folder and sets the output folder correctly. I used the following configuration:

        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>build-helper-maven-plugin</artifactId>
            <version>1.7</version>
            <executions>
                <execution>
                    <id>add-test-source</id>
                    <phase>generate-test-sources</phase>
                    <goals>
                        <goal>add-test-source</goal>
                    </goals>
                    <configuration>
                        <sources>
                            <source>src/test/groovy</source>
                        </sources>
                    </configuration>
                </execution>
            </executions>
        </plugin>

这篇关于Eclipse + Maven + Groovy:src / test / groovy目录在更新项目配置后被删除的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-28 17:39