未验证 提交 46c8f144 编写于 作者: J Jesse Glick

Deleting ancient cobertura profile, which was broken at least by Java 8 if not...

Deleting ancient cobertura profile, which was broken at least by Java 8 if not earlier. If we want code coverage we can use JaCoCo as plugin-pom does.
上级 9b419100
......@@ -870,41 +870,5 @@ THE SOFTWARE.
<findbugs.failOnError>true</findbugs.failOnError>
</properties>
</profile>
<profile>
<!-- Obtain code coverage report. This is done by running Unit tests on our own and suppressing surefire. -->
<id>cobertura</id>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.gmaven</groupId>
<artifactId>gmaven-plugin</artifactId>
<!-- version specified in grandparent pom -->
<executions>
<!-- run unit test -->
<execution>
<phase>test</phase>
<goals>
<goal>execute</goal>
</goals>
<configuration>
<scriptpath>
<element>${project.basedir}/src/build-script</element>
</scriptpath>
<source>${project.basedir}/src/build-script/unitTest.groovy</source>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<!-- unit tests are run by GMaven through Ant. -->
<artifactId>maven-surefire-plugin</artifactId>
<!-- version specified in grandparent pom -->
<configuration>
<skipTests>true</skipTests>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
import org.apache.maven.project.MavenProject;
/**
* Cobertura invoker.
*/
public class Cobertura {
private final MavenProject project;
// maven helper
private def maven;
// ant builder
private def ant;
/**
* Cobertura data file.
*/
private final File ser;
def Cobertura(project, maven, ant, ser) {
this.project = maven.project;
this.maven = maven;
this.ant = ant;
this.ser =ser;
// define cobertura tasks
ant.taskdef(resource:"tasks.properties")
}
// function that ensures that the given directory exists
private String dir(String dir) {
new File(project.basedir,dir).mkdirs();
return dir;
}
/**
* Instruments the given class dirs/jars by cobertura
*
* @param files
* List of jar files and class dirs to instrument.
*/
def instrument(files) {
ant."cobertura-instrument"(todir:dir("target/cobertura-classes"),datafile:ser) {
fileset(dir:"target/classes");
files.each{ fileset(file:it) }
}
}
def runTests() {
ant.junit(fork:true, forkMode:"once", failureproperty:"failed", printsummary:true) {
classpath {
junitClasspath()
}
batchtest(todir:dir("target/surefire-reports")) {
fileset(dir:"target/test-classes") {
include(name:"**/*Test.class")
}
formatter(type:"xml")
}
sysproperty(key:"net.sourceforge.cobertura.datafile",value:ser)
sysproperty(key:"hudson.ClassicPluginStrategy.useAntClassLoader",value:"true")
}
}
def junitClasspath() {
ant.pathelement(path: "target/cobertura-classes") // put the instrumented classes first
ant.fileset(dir:"target/cobertura-classes",includes:"*.jar") // instrumented jar files
ant.pathelement(path: maven.resolveArtifact("net.sourceforge.cobertura:cobertura:1.9")) // cobertura runtime
project.getTestClasspathElements().each { ant.pathelement(path: it) } // the rest of the dependencies
}
def report(dirs) {
maven.attachArtifact(ser,"ser","cobertura")
["html","xml"].each { format ->
ant."cobertura-report"(format:format,datafile:ser,destdir:dir("target/cobertura-reports"),srcdir:"src/main/java") {
dirs.each{ fileset(dir:it) }
}
}
}
def makeBuildFailIfTestFail() {
if(ant.project.getProperty("failed")!=null && !Boolean.getBoolean("testFailureIgnore"))
throw new Exception("Some unit tests failed");
}
}
Parts of the build scripts that are written in Groovy.
IntelliJ needs Groovy files to be in its source directory to provide completion and such,
so we need this to be in its own directory.
\ No newline at end of file
// run unit tests
ant.project.setBaseDir(project.basedir)
ser=new File(project.basedir,"target/cobertura.ser"); // store cobertura data file in a module-specific location
cob = new Cobertura(project,maven,ant,ser);
cob.instrument([])
cob.runTests()
cob.report([])
cob.makeBuildFailIfTestFail();
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册