I am encountering an incompatibility between the aspectj-maven-plugin and clover-maven-plugin
The symptom of the error, is that when I compile I get a message like:
[ERROR] Failed to execute goal org.codehaus.mojo:aspectj-maven-plugin:1.7:compile (default) on project ActiveMQCommon: The artifact veeva.ecm.common:solr-aspects referenced in aspectj plugin as an aspect library, is not found the project dependencies -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.codehaus.mojo:aspectj-maven-plugin:1.7:compile (default) on project ActiveMQCommon: The artifact veeva.ecm.common:solr-aspects referenced in aspectj plugin as an aspect library, is not found the project dependencies
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
Caused by: org.apache.maven.plugin.MojoExecutionException: The artifact veeva.ecm.common:solr-aspects referenced in aspectj plugin as an aspect library, is not found the project dependencies
... 20 more
I've been able to determine the issue.
We are using the aspectLibraries part of the aspectj-maven-plugin with something like this:
... lost of stuff here ...
Notice that there is an aspectLibrary declared there. As per the aspectj-maven-plugin documentation (http://www.mojohaus.org/aspectj-maven-plugin/examples/libraryJars.html) that aspect must also be included in the normal POM dependencies.
However, when the clover-maven-plugin runs, while the dependencies are resolving, it under the hood adds an extra maven classifier (http://stackoverflow.com/questions/20909634/what-is-the-purpose-of-classifier-tag-in-maven) tag on in the dependencies section. So the aspectLibrary and the dependency no longer match and the compile fails.
If I change the aspectLibrary to be
then compile succeeds. But then the regular compile fails.
Is there a recommended approach to dealing with this? I'm thinking about adding a new maven profile just for running clover. But I'm wondering if there is a better approach that is less invasive.
I assume that you are using the 'clover:instrument' goal to run Clover, am I correct?
The 'clover:instrument' goal forks a parallel build life cycle and adds the 'clover' classifier to all Maven artifacts generated. Could you please try to use the 'clover:setup' goal instead? This goal will also instrument code and at the same time will not add 'clover' classifier and will not fork a build life cycle.
Keep in mind to not run 'clover:setup' with the 'install' or 'deploy' phases (unless you want to install instrumented JARs in ~/.m2 directory or to deploy them to your Maven repository). We usually recommend to run Clover with "test" or "verify".
Could you please create a support ticket on support.atlassian.com, run your build with debug logging (mvn -X) and attach build log produced? Could you attach pom.xml as well (the one which contains configuration of aspectj-maven-plugin and clover-maven-plugin)? I'd like to investigate it further.
After analysis it turned out that Clover unnecessarily adds the "clover" classifier for some artifacts. In a normal build it works fine, but it fails with the aspectj-maven-plugin, which can have an artifact dependency declared the <aspectLibrary> tag.
Bug is reported here: https://jira.atlassian.com/browse/CLOV-1966.
In order to workaround this, set the following option for clover-maven-plugin:
This will trick Clover to see all artifacts with the "clover" classifier as outdated and Clover will not add them to a list of dependencies.
Clover prints a warning in such case:
[WARNING] Using [<artifact>], built on <date> even though a Clovered version exists but it's older (lastModified: <date> ) and could fail the build. Please consider running Clover again on that dependency's project.
but it can be ignored as long as the "clover:setup" is used and not "clover:instrument" (the latter one usually needs "clover" artifacts).
This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.Read more
As a Jira power user, I was at first doubtful that Trello could benefit my workflow. Jira already uses boards (ones you can customize!), so why would I even need to use Trello?! In this post you will...
Connect with like-minded Atlassian users at free events near you!Find a group
Connect with like-minded Atlassian users at free events near you!
Unfortunately there are no AUG chapters near you at the moment.Start an AUG
You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs