You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Ch...@emc.com on 2012/01/20 17:45:26 UTC

Difference between compile and provided scope for jar artifacts

When I build a jar file, the compile dependencies are not packaged into the jar.  So, this means that they are expected to be provided somewhere else in the run time environment, doesn't it?  Which means that it doesn't seem like there's a difference between compile and provided . . . am I missing something?

RE: Difference between compile and provided scope for jar artifacts

Posted by Matt Walsh <mw...@chartwelltechnology.com>.
Makes more sense in terms of a WAR. Compile scope jars are copied to
WEB-INF/lib. Provided scope jars aren't. For example, the servlet-api
would be "provided" by the servlet container.

Matt

> -----Original Message-----
> From: Chad.Davis@emc.com [mailto:Chad.Davis@emc.com]
> Sent: Friday, January 20, 2012 9:45 AM
> To: users@maven.apache.org
> Subject: Difference between compile and provided scope for jar
> artifacts
> 
> When I build a jar file, the compile dependencies are not packaged
into
> the jar.  So, this means that they are expected to be provided
> somewhere else in the run time environment, doesn't it?  Which means
> that it doesn't seem like there's a difference between compile and
> provided . . . am I missing something?

______________________________________________________________________
This message, including any attachments, is confidential and contains information intended only for the person(s) named above. Any other distribution, copying or disclosure is strictly prohibited. If you are not the intended recipient or have received this message in error, please notify us immediately by reply email and permanently delete the original transmission from all of your systems and hard drives, including any attachments, without making a copy.

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


Re: Difference between compile and provided scope for jar artifacts

Posted by Martin Schayna <ma...@abra.eu>.
If you want to include all dependencies into jar, you can use maven 
assembly plugin. You can integrate it to build process, see:

http://stackoverflow.com/a/589111/121143

I have done this for creating full-blown jar with test which can be 
easily uploaded to Amazon micro instance for load testing.

Martin Schayna


On 01/20/2012 05:45 PM, Chad.Davis@emc.com wrote:
> When I build a jar file, the compile dependencies are not packaged into the jar.  So, this means that they are expected to be provided somewhere else in the run time environment, doesn't it?  Which means that it doesn't seem like there's a difference between compile and provided . . . am I missing something?
>

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


RE: Difference between compile and provided scope for jar artifacts

Posted by Ansgar Konermann <an...@googlemail.com>.
Yay, mixed it up.

provided scope breaks up transitivity, so direct dependencies are on
compile classpath, transitive ones are not.

Best regards

Ansgar
 Am 20.01.2012 18:04 schrieb "Matt Walsh" <mw...@chartwelltechnology.com>:

> Are you sure about that? I believe provided go on the compile classpath
> as well.
>
> To quote the maven docs:
>
> Provided
> This is much like compile, but indicates you expect the JDK or a
> container to provide the dependency at runtime. For example, when
> building a web application for the Java Enterprise Edition, you would
> set the dependency on the Servlet API and related Java EE APIs to scope
> provided because the web container provides those classes. This scope is
> only available on the compilation and test classpath, and is not
> transitive.
>
> > -----Original Message-----
> > From: Ansgar Konermann [mailto:ansgar.konermann@googlemail.com]
> > Sent: Friday, January 20, 2012 9:57 AM
> > To: Maven Users List
> > Subject: Re: Difference between compile and provided scope for jar
> > artifacts
> >
> > Am 20.01.2012 17:44 schrieb <Ch...@emc.com>:
> > >
> > > When I build a jar file, the compile dependencies are not packaged
> > into
> > the jar.  So, this means that they are expected to be provided
> > somewhere
> > else in the run time environment, doesn't it?  Which means that it
> > doesn't
> > seem like there's a difference between compile and provided . . . am I
> > missing something?
> >
> > Yes. Dependency management capabilities of Maven.
> >
> > Maven will put compile-scoped dependencies on the compile classpath
> > automatically, whereas for provided it does not.
> >
> > Regards
> >
> > Ansgar
>
> ______________________________________________________________________
> This message, including any attachments, is confidential and contains
> information intended only for the person(s) named above. Any other
> distribution, copying or disclosure is strictly prohibited. If you are not
> the intended recipient or have received this message in error, please
> notify us immediately by reply email and permanently delete the original
> transmission from all of your systems and hard drives, including any
> attachments, without making a copy.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>

RE: Difference between compile and provided scope for jar artifacts

Posted by Matt Walsh <mw...@chartwelltechnology.com>.
Are you sure about that? I believe provided go on the compile classpath
as well. 

To quote the maven docs:

Provided
This is much like compile, but indicates you expect the JDK or a
container to provide the dependency at runtime. For example, when
building a web application for the Java Enterprise Edition, you would
set the dependency on the Servlet API and related Java EE APIs to scope
provided because the web container provides those classes. This scope is
only available on the compilation and test classpath, and is not
transitive.

> -----Original Message-----
> From: Ansgar Konermann [mailto:ansgar.konermann@googlemail.com]
> Sent: Friday, January 20, 2012 9:57 AM
> To: Maven Users List
> Subject: Re: Difference between compile and provided scope for jar
> artifacts
> 
> Am 20.01.2012 17:44 schrieb <Ch...@emc.com>:
> >
> > When I build a jar file, the compile dependencies are not packaged
> into
> the jar.  So, this means that they are expected to be provided
> somewhere
> else in the run time environment, doesn't it?  Which means that it
> doesn't
> seem like there's a difference between compile and provided . . . am I
> missing something?
> 
> Yes. Dependency management capabilities of Maven.
> 
> Maven will put compile-scoped dependencies on the compile classpath
> automatically, whereas for provided it does not.
> 
> Regards
> 
> Ansgar

______________________________________________________________________
This message, including any attachments, is confidential and contains information intended only for the person(s) named above. Any other distribution, copying or disclosure is strictly prohibited. If you are not the intended recipient or have received this message in error, please notify us immediately by reply email and permanently delete the original transmission from all of your systems and hard drives, including any attachments, without making a copy.

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


Re: Difference between compile and provided scope for jar artifacts

Posted by Ansgar Konermann <an...@googlemail.com>.
Am 20.01.2012 17:44 schrieb <Ch...@emc.com>:
>
> When I build a jar file, the compile dependencies are not packaged into
the jar.  So, this means that they are expected to be provided somewhere
else in the run time environment, doesn't it?  Which means that it doesn't
seem like there's a difference between compile and provided . . . am I
missing something?

Yes. Dependency management capabilities of Maven.

Maven will put compile-scoped dependencies on the compile classpath
automatically, whereas for provided it does not.

Regards

Ansgar