我使用的方法是將GMavenPlus納入該項目。第一步包括對pom.xml
進行必要的更改。因此,添加以下到<plugins>
部分:
<plugin>
<groupId>org.codehaus.gmavenplus</groupId>
<artifactId>gmavenplus-plugin</artifactId>
<version>1.5</version>
<executions>
<execution>
<goals>
<goal>addSources</goal>
<goal>addTestSources</goal>
<goal>compile</goal>
<goal>testCompile</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
</plugin>
<plugin>
<!-- if including source jars, use the no-fork goals
otherwise both the Groovy sources and Java stub sources will get included in your jar -->
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<!-- source plugin \> = 2.1 is required to use the no-fork goals -->
<version>2.4</version>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar-no-fork</goal>
<goal>test-jar-no-fork</goal>
</goals>
</execution>
</executions>
</plugin>
下一頁添加以下到<dependencies>
部分:
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-all</artifactId>
<version>2.4.3</version>
</dependency>
下一頁所有創建相應的測試目錄和測試類:
mkdir src/test/groovy
mkdir -p src/test/groovy/org/jsoup/integration
touch src/test/groovy/org/jsoup/integration/GroovyTest.groovy
然後我將測試添加到GroovyTest.groovy
,並且我能夠執行測試。