-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Accessing "META-INF/maven/plugin.xml" files during tests #76
Comments
Hey @jmini thank you for the report. I remember trying to do this but but there is a fundamental issue here that I'm not sure how to work around: The Maven plugin tools need to consume both the source files (to scan JavaDoc) and the compiled classes (to find annotations). For that reason the generate task consumes both the sources and the sourceset output as an inputs. Because of that it can not add something to the sourceset because that would result in a cycle. I can review this again and try to work around it, but I'm not sure it's possible. As a workaround I think it should be possible to make the test tasks consume the jar instead of the classes folder. I can't tell how to do that from the top of my head, but I think it should be possible. |
This would be great. I have a dependency to the Currently my workaround is to add Following code has to find the MOJO xml file: Enumeration<URL> resources = getClass().getClassLoader().getResources("META-INF/maven/plugin.xml"); Source in Maven30xRuntime.java Otherwise the tests are failing with:
|
If I can't make this work by adding it to the source set I think it's possible to add it to the testRuntimeClasspath from my plugin. I will look into it after I'm done with #73. |
If I got this right, a maven plugin is nothing more than a regular jar with some additional metadata files in
META-INF/maven/
.A jar built with the
de.benediktritter.maven-plugin-development
contains those file:Screenshot of a jar corresponding to the example-maven-plugin project.
The files are generated in the
$buildDir/mavenPlugin/descriptor
folder.Usually when I have a task that generates files that needs to be present in the jar, I modify the source set to add the generated folder like this:
While I was working on having functional tests for my maven plugin (see #41 - I will share the results soon) I noticed that the
META-INF/maven/plugin.xml
are not available during the test.Adding this code to a test shows the problem:
During the
test
task the jar is not present on the classpath, only the folder containing the*.class
files.Output:
I was wondering if this is intended?
The text was updated successfully, but these errors were encountered: