maven-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Davis Ford" <davisf...@gmail.com>
Subject Re: maven-dependency-plugin
Date Tue, 25 Mar 2008 15:39:08 GMT
It is slightly more complex.

The assembly jar's purpose loads geodata from a database, and then
does quality checks on that data, and stores any violations it found
in a separate repository.

Every time I run the jar, I want to store with the list of violations
the list of all versions of jars it used....for analysis (if number of
violations changes, I want to understand why...perhaps a new jar was
released that caused it).

I could scan this info at runtime by looking in the lib dir inside the
assembly jar, true.  This doesn't help me, though when I'm developing
/ testing, since I run tests either via mvn or w/in eclipse, and I
want to know the same info during that phase.

So, I guess what I'm looking for is a universal solution to always
being able to obtain this information at runtime despite what phase
I'm in (as a deployed assembly jar, or running in eclipse).  I'm
coming to the conclusion that the best way to do this is probably to
just get the classpath system property, and parse that.

Regards,
Davis

On Tue, Mar 25, 2008 at 11:25 AM, Brian E. Fox <brianf@reply.infinity.nu> wrote:
> So it sounds like you might be trying to do a form of code coverage for
>  your dependencies?
>
>  To answer your question, yes I would dump the file when you are making
>  the assembly and then use that at runtime. Just curious though, if the
>  dependencies are in the assembly, why do you need a list of them?
>  Couldn't you just enumerate the lib folder?
>
>
>  -----Original Message-----
>  From: Davis Ford [mailto:davisford@gmail.com]
>
>
> Sent: Tuesday, March 25, 2008 11:17 AM
>  To: Maven Users List
>  Subject: Re: maven-dependency-plugin
>
>  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
>  <brianf@reply.infinity.nu> 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:davisford@gmail.com]
>  >
>  >
>  > 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
>  <brianf@reply.infinity.nu>
>  >  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:davisford@gmail.com]
>  >  >
>  >  > 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
>  >  <brianf@reply.infinity.nu>
>  >  >  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:davisford@gmail.com]
>  >  >  >  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: users-unsubscribe@maven.apache.org
>  >  >  >  For additional commands, e-mail: users-help@maven.apache.org
>  >  >  >
>  >  >  >
>  >  >  >
>  >  ---------------------------------------------------------------------
>  >  >  >  To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
>  >  >  >  For additional commands, e-mail: users-help@maven.apache.org
>  >  >  >
>  >  >
>  >
>  >  ---------------------------------------------------------------------
>  >  To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
>  >  For additional commands, e-mail: users-help@maven.apache.org
>  >
>  >
>  >  ---------------------------------------------------------------------
>  >  To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
>  >  For additional commands, e-mail: users-help@maven.apache.org
>  >
>  >
>
>
>
>  --
>  Zeno Consulting, Inc.
>  http://www.zenoconsulting.biz
>  248.894.4922 phone
>  313.884.2977 fax
>
>  ---------------------------------------------------------------------
>  To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
>  For additional commands, e-mail: users-help@maven.apache.org
>
>
>  ---------------------------------------------------------------------
>  To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
>  For additional commands, e-mail: users-help@maven.apache.org
>
>



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

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Mime
View raw message