Quick follow-up.  Consider if I have this use case:

For project A, do mvn assembly:assembly to make uber-jar, and deploy
it so someone can use it.  For each execution that they run it, I want
it to log programmatically the list of jars it used for that
execution.  If I developed a plugin to get this info, then it would
also require maven being installed where the assembly jar is
installed, since the plugin would try to resolve each jar.  I'm
assuming that it does not resolve from the classpath but only from the
mvn remote or local repos.

Thus, perhaps it is better to use the dependency plugin to dump a text
file list of dependencies that gets deployed with the assembly jar,
since this won't require any other maven dependencies to get at the
same information?

Any thoughts?

Thanks in advance,
Davis

On Tue, Mar 25, 2008 at 10:40 AM, Brian E. Fox <[EMAIL PROTECTED]> wrote:
> Generally bad things happen when you use plugins as dependencies. The
>  project.getArtifacts() is part of the plugin api, not just the
>  dependency plugin. If you use the M2Eclipse plugin for eclipse, you can
>  quickly create a plugin by using the maven-archetype-mojo archetype.
>
>
>  -----Original Message-----
>  From: Davis Ford [mailto:[EMAIL PROTECTED]
>
>
> Sent: Tuesday, March 25, 2008 10:31 AM
>  To: Maven Users List
>  Subject: Re: maven-dependency-plugin
>
>  Brian,
>
>  Maybe a dumb question, but is there a way I can just use the
>  maven-dependency-plugin programatically to accomplish what I'm trying
>  to do?
>
>  Can I just pull the plugin jar in so it is on the classpath like any
>  other dependency and use its API to get project.getArtifacts() ?
>
>  On Wed, Mar 19, 2008 at 6:02 PM, Brian E. Fox <[EMAIL PROTECTED]>
>  wrote:
>  > Actually getting the list via a plugin is trivial. Just set a
>  parameter
>  >  like this:
>  >
>  >     /**
>  >      * POM
>  >      *
>  >      * @parameter expression="${project}"
>  >      * @readonly
>  >      * @required
>  >      */
>  >     protected MavenProject project;
>  >
>  >  And then project.getArtifacts() will be all (including transitive)
>  >  dependencies. You'll also need to specify
>  @requiresDependencyResolution
>  >  [scope] in the mojo annotations.
>  >
>  >  There is also a tree component that you could use to get the output
>  used
>  >  to generate dependency:tree
>  >
>  >
>  >  -----Original Message-----
>  >  From: Davis Ford [mailto:[EMAIL PROTECTED]
>  >
>  > Sent: Wednesday, March 19, 2008 5:57 PM
>  >  To: Maven Users List
>  >
>  >
>  > Subject: Re: maven-dependency-plugin
>  >
>  >  Hi Brian,
>  >
>  >  Indeed -- total goof-up on my part.  I had multiple project pom.xml
>  >  files and was editing the wrong one.  It works like a charm.
>  >
>  >  Quick related question...the whole purpose of me dumping this to a
>  >  text file was because I could not see an easy way to programmatically
>  >  get a list of all project dependencies....so I figured I'd create the
>  >  .txt file and parse it myself.
>  >
>  >  The reason I want this list is as part of reporting framework we
>  have.
>  >   We run a long-running set of quality checks on some data, and I need
>  >  to be able to store with the final report the list of all things like
>  >  .jar versions, database versions, etc., etc.
>  >
>  >  Is there somewhere an API that would let me retrieve this same
>  >  information in the code?
>  >
>  >  Regards,
>  >  Davis
>  >
>  >  On Wed, Mar 19, 2008 at 4:50 PM, Brian E. Fox
>  <[EMAIL PROTECTED]>
>  >  wrote:
>  >  > I just double checked the code and this should work. Is it
>  displaying
>  >  >  the list to the output? If not, then it's going to a file
>  somewhere.
>  >  It
>  >  >  would be better to use ${project.build.directory}/output.txt
>  instead
>  >  so
>  >  >  it goes to /target/output.txt
>  >  >
>  >  >
>  >  >
>  >  >  -----Original Message-----
>  >  >  From: Davis Ford [mailto:[EMAIL PROTECTED]
>  >  >  Sent: Wednesday, March 19, 2008 4:46 PM
>  >  >  To: Maven Users List
>  >  >  Subject: maven-dependency-plugin
>  >  >
>  >  >  Hi, I'm trying to use the maven-dependency-plugin to dump a list
>  of
>  >  >  the project's dependencies out to a text file, but I can not seem
>  to
>  >  >  get it to do anything.
>  >  >
>  >  >  relevant configuration:
>  >  >
>  >  >                           <plugin>
>  >  >
>  >  >  <groupId>org.apache.maven.plugins</groupId>
>  >  >
>  >  >  <artifactId>maven-dependency-plugin</artifactId>
>  >  >                                 <version>2.0</version>
>  >  >                                 <executions>
>  >  >                                         <execution>
>  >  >
>  >  >  <id>write-dependencies</id>
>  >  >
>  <phase>compile</phase>
>  >  >                                                 <goals>
>  >  >
>  >  >  <goal>list</goal>
>  >  >                                                 </goals>
>  >  >                                                 <configuration>
>  >  >
>  >  >  <outputFile>dependencies.txt</outputFile>
>  >  >                                                 </configuration>
>  >  >                                         </execution>
>  >  >                                 </executions>
>  >  >                         </plugin>
>  >  >                 </plugins>
>  >  >         </build>
>  >  >
>  >  >  I would expect that if I do "mvn compile" it would create
>  >  >  dependencies.txt but it does not.  Anyone have an idea what I'm
>  doing
>  >  >  wrong here?
>  >  >
>  >  >  Thanks in advance,
>  >  >  Davis
>  >  >
>  >  >
>  ---------------------------------------------------------------------
>  >  >  To unsubscribe, e-mail: [EMAIL PROTECTED]
>  >  >  For additional commands, e-mail: [EMAIL PROTECTED]
>  >  >
>  >  >
>  >  >
>  ---------------------------------------------------------------------
>  >  >  To unsubscribe, e-mail: [EMAIL PROTECTED]
>  >  >  For additional commands, e-mail: [EMAIL PROTECTED]
>  >  >
>  >
>
>  ---------------------------------------------------------------------
>  To unsubscribe, e-mail: [EMAIL PROTECTED]
>  For additional commands, e-mail: [EMAIL PROTECTED]
>
>
>  ---------------------------------------------------------------------
>  To unsubscribe, e-mail: [EMAIL PROTECTED]
>  For additional commands, e-mail: [EMAIL PROTECTED]
>
>



-- 
Zeno Consulting, Inc.
http://www.zenoconsulting.biz
248.894.4922 phone
313.884.2977 fax

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to