Why isn't clover generating JSON from my pom.xml config?

217 views Asked by At

I have this bit in my pom.xml

<pluginManagement>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-release-plugin</artifactId>
            <version>2.3.2</version>
        </plugin>
        <plugin>
            <groupId>com.atlassian.maven.plugins</groupId>
            <artifactId>clover-maven-plugin</artifactId>
            <version>4.1.2</version>
            <configuration>
                <generateJson>true</generateJson>
                <generateXml>true</generateXml>
                <generateHtml>true</generateHtml>
                <generatePdf>true</generatePdf>
            </configuration>
        </plugin>
    </plugins>
</pluginManagement>

I know PDF & JSON default to false. The others default to true.

Somehow when I do this, I generate HTML, XML, and even the PDF. JSON is nowhere to be found. It even says Generating JSON report to: /example/myrepo/target/site/clover, as it does for the XML. When I go to that folder I see clover.pdf and clover.xml. No clover.json.

If I do the following, it strangely says No report being generated for this module. and then Generating JSON report to: /example/myrepo/target/site/clover.

<configuration>
    <generateJson>true</generateJson>
    <generateXml>false</generateXml>
    <generateHtml>false</generateHtml>
    <generatePdf>false</generatePdf>
</configuration>

If I do this, it goes back to generating reports just "fine" (this example will just create the XML, no HTML). Still no JSON

<configuration>
    <generateJson>true</generateJson>
    <generateXml>true</generateXml>
    <generateHtml>false</generateHtml>
    <generatePdf>false</generatePdf>
</configuration>

Full config (with some things swapped to stay anon)

<?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>
    <dependencies>
        <dependency>
            <groupId>org.apache.httpcomponents</groupId>
            <artifactId>httpclient</artifactId>
            <version>4.5</version>
        </dependency>
        <dependency>
            <groupId>org.yaml</groupId>
            <artifactId>snakeyaml</artifactId>
            <version>1.18</version>
        </dependency>
        <dependency>
            <groupId>org.mockito</groupId>
            <artifactId>mockito-core</artifactId>
            <version>1.10.19</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.hamcrest</groupId>
            <artifactId>hamcrest-all</artifactId>
            <version>1.3</version>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <parent>
        <groupId>org.jenkins-ci.plugins</groupId>
        <artifactId>plugin</artifactId>
        <version>1.583</version>
        <relativePath />
    </parent>
    <groupId>com.mynamespace</groupId>
    <artifactId>myartifactid</artifactId>
    <version>1.1.3</version>
    <packaging>hpi</packaging>

    <name>Test</name>
    <description>Test</description>
    <url>https://wiki.jenkins-ci.org/display/JENKINS/TODO+Plugin</url>
    <licenses>
        <license>
            <name>MIT License</name>
            <url>http://opensource.org/licenses/MIT</url>
        </license>
    </licenses>
    <build>
        <testSourceDirectory>src/test/java</testSourceDirectory>
        <testOutputDirectory>${project.build.directory}/test-classes</testOutputDirectory>
        <testResources>
            <testResource>
                <directory>src/test/resources</directory>
            </testResource>
        </testResources>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-release-plugin</artifactId>
                    <version>2.3.2</version>
                </plugin>
                <plugin>
                    <groupId>com.atlassian.maven.plugins</groupId>
                    <artifactId>clover-maven-plugin</artifactId>
                    <version>4.1.2</version>
                    <configuration>
                        <generateJson>true</generateJson>
                        <generateXml>true</generateXml>
                        <generateHtml>false</generateHtml>
                        <generatePdf>false</generatePdf>
                    </configuration>
                </plugin>
            </plugins>
        </pluginManagement>
    </build>

    <repositories>
        <repository>
            <id>repo.jenkins-ci.org</id>
            <url>http://repo.jenkins-ci.org/public/</url>
        </repository>
    </repositories>
    <pluginRepositories>
        <pluginRepository>
            <id>repo.jenkins-ci.org</id>
            <url>http://repo.jenkins-ci.org/public/</url>
        </pluginRepository>
    </pluginRepositories>

</project>

Update I ran java -Dclover.license.path=/Users/dstein/Desktop/clover.lic -cp "/Users/dstein/.m2/repository/com/atlassian/clover/clover/4.1.2/*" com.atlassian.clover.reporters.json.JSONReporter -i target/clover/clover.db -o clover_json -d

It generated my folder and threw a lot of JS files in it. Those files sometimes have JSON... but are wrapped in what looks like JSONP cause it will be like processClover({}). Is this expected behavior? Is the fact they call it JSON a misnomer?

1

There are 1 answers

0
Dave Stein On BEST ANSWER

It would seem that this feature should have been called JSONP.

The docs show that it is meant to output all those JS files to be consumed by a callback on a webpage. It's not meant to be used for parsing, as you can do with the XML.