payara / ecosystem-support

Placeholder repository to handle community requests for the Payara Platform ecosystem tools
4 stars 2 forks source link

Enhancement: Improved support for Jacoco Code Coverage / FISH-1447 #10

Open tofflos opened 3 years ago

tofflos commented 3 years ago

I'm running the Jacoco Maven plugin for code coverage which involves instrumenting my application by pointing out the location of the Jacoco agent runtime as a VM argument. The runtime location is system dependent so Jacoco comes with goals named prepare-agent and prepare-agent-integration that figures out where the runtime is located and binds that location to property called argLine. The argLine property is later picked up by Surefire and Failsafe using a feature called Late Property Evaluation. See https://www.eclemma.org/jacoco/trunk/doc/prepare-agent-mojo.html.

Unfortunately Late Property Evaluation is implemented as a feature in Surefire and Failsafe and not as a global feature in Maven so the argLine property isn't populated under Payara Micro -> Start -> JCommandLineOptions. See https://www.devwithimagination.com/2019/09/03/integration-testing-with-payara-micro to get an idea of the hoops you have to jump through to get Jacoco to work with Payara Micro.

Could you add something similar to Late Property Evaluation to the Start goal so that all you have to do is:

<plugin>
    <groupId>org.jacoco</groupId>
    <artifactId>jacoco-maven-plugin</artifactId>
    <version>0.8.6</version>
    <executions>
        <execution>
            <goals>
                <goal>prepare-agent-integration</goal>
            </goals>
        </execution>
    </executions>
</plugin>

<plugin>
    <groupId>fish.payara.maven.plugins</groupId>
    <artifactId>payara-micro-maven-plugin</artifactId>
    <version>1.3.0</version>
    <executions>
        <execution>
            <id>start-payara-micro</id>
            <phase>pre-integration-test</phase>
            <goals>
                <goal>start</goal>
            </goals>
        </execution>
        <execution>
            <id>stop-payara-micro</id>
            <phase>post-integration-test</phase>
            <goals>
                <goal>stop</goal>
            </goals>
        </execution>
    </executions>
    <configuration>
        <daemon>true</daemon>
        <contextRoot>/</contextRoot>
        <javaCommandLineOptions>
            <option>
                <value>@{argLine}</value>
            </option>
        </javaCommandLineOptions>
    </configuration>
</plugin>