Skip to content
Skip to breadcrumbs
Skip to header menu
Skip to action menu
Skip to quick search
Quick Search
Browse
Pages
Blog
Labels
Attachments
Mail
Advanced
What’s New
Space Directory
Feed Builder
Keyboard Shortcuts
Confluence Gadgets
Log In
Sign Up
Dashboard
Maven User
Copy Page
You are not logged in. Any changes you make will be marked as
anonymous
. You may want to
Log In
if you already have an account. You can also
Sign Up
for a new account.
This page is being edited by
.
Paragraph
Paragraph
Heading 1
Heading 2
Heading 3
Heading 4
Heading 5
Heading 6
Preformatted
Quote
Bold
Italic
Underline
More colours
Strikethrough
Subscript
Superscript
Monospace
Clear Formatting
Bullet list
Numbered list
Outdent
Indent
Align left
Align center
Align right
Link
Table
Insert
Insert Content
Image
Link
Attachment
Symbol
Emoticon
Wiki Markup
Horizontal rule
tinymce.confluence.insert_menu.macro_desc
Info
JIRA Issue
Status
Gallery
Tasklist
Table of Contents
Other Macros
Page Layout
No Layout
Two column (simple)
Two column (simple, left sidebar)
Two column (simple, right sidebar)
Three column (simple)
Two column
Two column (left sidebar)
Two column (right sidebar)
Three column
Three column (left and right sidebars)
Undo
Redo
Find/Replace
Keyboard Shortcuts Help
<p>This is a dicussion of the <a href="http://jira.codehaus.org/browse/MNG-4039" title="JIRA issue">proposal</a> to define a contract for Mojos to be able to contribute dependencies to the project to which they are attached. Here is an example (intended only for illustration) of what this means: <br class="atl-forced-newline" /></p> <p>Consider a project using the <a href="http://antlr.org/" title="Antlr website">Antlr</a> parser generator library. Since version 3.0, Antlr has split its artifacts into org.antlr:antlr (buildtime stuff) and org.antlr:antlr-runtime (the Antlr runtime). As a project utilizing Antlr, the only real transitive dependency you have is org.antlr:antlr-runtime: <br class="atl-forced-newline" /></p> <table class="wysiwyg-macro" data-macro-name="code" data-macro-default-parameter="xml" style="background-image: url(/plugins/servlet/confluence/placeholder/macro-heading?definition=e2NvZGU6eG1sfQ&locale=en_GB&version=2); background-repeat: no-repeat;" data-macro-body-type="PLAIN_TEXT"><tr><td class="wysiwyg-macro-body"><pre> <dependencies> <dependency> <groupId>org.antlr</groupId> <artifactId>antlr-runtime</artifactId> <version>3.1.1</version> </dependency> </dependencies> </pre></td></tr></table> <p>Now, lets say that you've just read about this incredible Antlr v3 tool named <a href="http://www.antlr.org/wiki/display/ANTLR3/gUnit+-+Grammar+Unit+Testing" title="gUnit wiki page">gUnit</a> and decide that you want to utilize grammar testing into your build cycle. Luckily I happen to currently be working on some mojos for gUnit, so you are in luck <img class="emoticon emoticon-smile" data-emoticon-name="smile" border="0" src="/s/en_GB/3278/15/_/images/icons/emoticons/smile.png" alt="(smile)" title="(smile)" /><br class="atl-forced-newline" /></p> <table class="wysiwyg-macro" data-macro-name="code" data-macro-default-parameter="xml" style="background-image: url(/plugins/servlet/confluence/placeholder/macro-heading?definition=e2NvZGU6eG1sfQ&locale=en_GB&version=2); background-repeat: no-repeat;" data-macro-body-type="PLAIN_TEXT"><tr><td class="wysiwyg-macro-body"><pre> <dependencies> <dependency> <groupId>org.antlr</groupId> <artifactId>antlr-runtime</artifactId> <version>3.1.1</version> </dependency> </dependencies> <build> <plugins> <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>gunit-maven-plugin</artifactId> <version>1.0.0-SNAPSHOT</version> <executions> <execution> <goals> <goal>generate</goal> </goals> </execution> </executions> </plugin> </plugins> </build> </pre></td></tr></table> <p>The 'generate' goal here is performing the gUnit JUnitCodeGen tool which generates JUnit test classes. So the plugin generates the JUnit .java files into an output directory and adds that directory to the project as a 'test compile source root' (so that compile-test and surefire can find them later). The generation bit works here initially, except that later we will get compilation erros from the test-compile mojo. The reason being that t turns out that when gUnit generates the JUnit classes, they actually contain references back to gUnit classes. However, as we said at the beginning gunit is contained in the org.antlr:antlr artifact since it is a build-time requirement; but since our project itself does not define a dependency on org.antlr:antlr, the gUnit classes are not on the classpath used by the test compiler (and even if we hacked it such that we immediately compiled the classes after generating them using our 'expanded' classpath, execution (surefire) of the tests would still fail for the same reasons.</p> <p> So we are left with a few choices:</p> <ol> <li>Have the gunit-maven-plugin 'hack' the project test-scoped classpath to append org.antlr:antlr so the gUnit classes are found during test-compile and surefire executions.</li> <li>Define org.antlr:antlr as a separate dependency *in the project*</li> </ol> <p>Maven developers actively frown upon option #1 (rightfully so) and it is expected that the ability to even do this will be removed in 3.x. But imo #2 is not any better. The dependency on org.antlr:antlr is clearly an implementation detail of the gunit-maven-plugin that has now bled out into the project pom: <br class="atl-forced-newline" /></p> <table class="wysiwyg-macro" data-macro-name="code" data-macro-default-parameter="xml" style="background-image: url(/plugins/servlet/confluence/placeholder/macro-heading?definition=e2NvZGU6eG1sfQ&locale=en_GB&version=2); background-repeat: no-repeat;" data-macro-body-type="PLAIN_TEXT"><tr><td class="wysiwyg-macro-body"><pre> <dependencies> <dependency> <groupId>org.antlr</groupId> <artifactId>antlr-runtime</artifactId> <version>3.1.1</version> </dependency> <!-- Here is the 'extra' dep --> <dependency> <groupId>org.antlr</groupId> <artifactId>antlr</artifactId> <version>3.1.1</version> <!-- we try to use scope to hide it from transitivity --> <scope>test</scope> <!-- or perhaps 'provided' (see later discussion) or 'import' (maven >= 2.0.9) --> </dependency> </dependencies> <build> <plugins> <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>gunit-maven-plugin</artifactId> <version>1.0.0-SNAPSHOT</version> <executions> <execution> <goals> <goal>generate</goal> </goals> </execution> </executions> </plugin> </plugins> </build> </pre></td></tr></table> <p>What I propose intsead is a well-defined contract for allowing plugin mojos to contribute *build-time only* dependencies to the project, preferably in a distinct, discrete, early phase of building the MavenProject reference for the project. I assume this is the intent of the term 'resolution phase' from the email I reference in my <a href="http://jira.codehaus.org/browse/MNG-4039" title="JIRA issue">proposal</a>. The main idea being that </p>
Please type the word appearing in the picture.
Attachments
Labels
Location
Watch this page
< Edit
Preview >
Loading…
Save
Cancel
Next hint
search
attachments
weblink
advanced