You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by marcelo <d2...@gmail.com> on 2010/08/31 18:59:37 UTC

Install project with dependencies

Hi,

I'd like to be able to install my maven project which generates a jar file
and execute the main class. 
How to I add the jar dependencies to the project , so that I can execute the
jar ?
-- 
View this message in context: http://maven.40175.n5.nabble.com/Install-project-with-dependencies-tp2798374p2798374.html
Sent from the Maven - Users mailing list archive at Nabble.com.

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


Re: Install project with dependencies

Posted by Wendy Smoak <ws...@gmail.com>.
On Tue, Aug 31, 2010 at 3:35 PM, marcelo <d2...@gmail.com> wrote:

> Is there a way to have maven create a jar file and point to the
> /.m2/repository for the dependencies ??

What are you actually trying to do with this code?  (Not 'create a jar
file' ... what problem are you trying to solve?)

You've said your maven project generates a jar file and you want to
execute it.  Now you want it to pull dependencies from the Maven repo
for execution.  That starts sounding like you'd want to write a Maven
plugin.

Otherwise, maybe you'd want to hook into the parts of Maven that
resolve and download dependencies so that your project can use them?

It's hard to say with only the info we have so far.

-- 
Wendy

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


RE: Install project with dependencies

Posted by "Adkins, Michael J." <MI...@saic.com>.
Actually Marcelo, what you want is fairly simple. Use either
appassembler:assemble (which autopackages everything and includes a .bat
to run it with), or if you want more control, use
dependencies:copy-dependencies to copy the dependencies to the location
of your choice. You could then use dependencies:copy to copy the main
jar file to the location of your choice. 

Granted that's likely not the most efficient way to do it but it works
for me and my uses.

Example of the dependency copy:
<plugin>
   <groupId>org.apache.maven.plugins</groupId>
   <artifactId>maven-dependency-plugin</artifactId>
   <executions>
      <execution>
         <id>install-copydependencies</id>
         <phase>install</phase>
         <goals>
            <goal>copy-dependencies</goal>
         </goals>
         <configuration>
 
<outputDirectory>${project.build.directory}/${project.build.finalName}/l
ib</outputDirectory>
         </configuration>
      </execution>
   </executions>
</plugin>

If you wanted to get bonus points and the chance for a one-up, try using
assembly:single with the descriptorRef set to "project" and point the
archiveBaseDirectory to the directory the main jar and the dependencies
are in (in this case:
"${project.build.directory}/${project.build.finalName") to produce 3
archived versions of it.

Links of varying degrees of importance:
http://maven.apache.org/plugins/maven-dependency-plugin/copy-dependencie
s-mojo.html
http://maven.apache.org/plugins/maven-dependency-plugin/copy-mojo.html
http://maven.apache.org/plugins/maven-assembly-plugin/plugin-info.html
http://mojo.codehaus.org/appassembler/appassembler-maven-plugin/

-Michael J.

========================================================================
========================

Assembly and Shade putz all the source code into the jar file. 

Is there a way to have maven create a jar file and point to the
/.m2/repository for the dependencies ??
-- 
View this message in context:
http://maven.40175.n5.nabble.com/Install-project-with-dependencies-tp279
8374p2798583.html
Sent from the Maven - Users mailing list archive at Nabble.com.

---------------------------------------------------------------------
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


Re: Install project with dependencies

Posted by marcelo <d2...@gmail.com>.
Assembly and Shade putz all the source code into the jar file. 

Is there a way to have maven create a jar file and point to the
/.m2/repository for the dependencies ??
-- 
View this message in context: http://maven.40175.n5.nabble.com/Install-project-with-dependencies-tp2798374p2798583.html
Sent from the Maven - Users mailing list archive at Nabble.com.

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


Re: Install project with dependencies

Posted by Anders Hammar <an...@hammar.net>.
http://www.sonatype.com/people/2009/08/how-to-make-an-executable-jar-in-maven/

/Anders

On Tue, Aug 31, 2010 at 20:18, Wayne Fay <wa...@gmail.com> wrote:

> > How to I add the jar dependencies to the project , so that I can execute
> the
> > jar ?
>
> Assembly or shade plugins should be able to handle what you're asking for.
>
> Wayne
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>

Re: Install project with dependencies

Posted by Wayne Fay <wa...@gmail.com>.
> How to I add the jar dependencies to the project , so that I can execute the
> jar ?

Assembly or shade plugins should be able to handle what you're asking for.

Wayne

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