Code coverage in maven build - Skipping JaCoCo execution due to missing classes directory

I have managed to get a workaround of sorts going through trial and error.

It seems the jacoco plugin is happy to create the exec file without the classes but it will not create the report without them, I dont understand how jacoco is working internally so if someone knows could you please explain it?

I am also not sure if what I have done is reliable but it does seem to report the coverage of my selenium driven tests.

My (possible) solution which I have come up with myself is to use the maven resources plugin to copy the classes which have been exploded from the war file in my target\cargo.. directory into the directory target\classes:

 <plugin>
        <artifactId>maven-resources-plugin</artifactId>
        <version>2.7</version>
        <executions>
          <execution>
            <id>copy-resources</id>             
            <phase>pre-integration-test</phase>
            <goals>
              <goal>copy-resources</goal>
            </goals>
            <configuration>
              <outputDirectory>${basedir}/target/classes</outputDirectory>
              <resources>          
                <resource>
                  <directory>${basedir}/target/cargo/configurations/tomcat7x/webapps/calculator-api/WEB-INF/classes</directory>
                  <filtering>false</filtering>
                  <excludes>
                        <exclude>**/*Config*.*</exclude>
                        <exclude>**/*Initialiser*.*</exclude>
                  </excludes>
                </resource>
              </resources>              
            </configuration>            
          </execution>
        </executions>
    </plugin>

This seems to keep the jacoco plugin happy and I get my code coverage, although it seems the plugin ignores my exclude list now.

Does anybody know if this is actually a solution, it 'seems' to work but I cant find anywhere online where this is a recommended approach and I am also unsure of why the exclude option on the jacoco agent set up no longer seems to work.

I have managed to get around the jacoco plugin not excluding files by just not copying them with the resources plugin but I still dont understand exactly how jacoco is working.