You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Martin Hoeller <ma...@xss.co.at> on 2014/02/07 10:33:10 UTC

Best practices for Java EE 7 dependencies

Hi!

I'm wondering what the best practices are for specifying Java EE 7
dependencies in my modules.

There is the so called BOM (bill of materials) POM: javax:javaee-api:7.0
which lists all API submodules required for JEE7. Specifying this in my
module as

  <dependency>
    <groupId>javax</groupId>
    <artifactId>javaee-api</artifactId>
    <version>7.0</version>
  </dependency>

works and is the least work for me. However, this way I got all JEE APIs
on the CLASSPATH even if I just need a few of them. Further on, the
actual dependencies are now transitive which is (IMHO) not fully correct.
Should I better specify the exact dependencies and investigate some more
work in POM maintainance? What would this gain me?

What do you think?

- martin

Re: Best practices for Java EE 7 dependencies

Posted by Wayne Fay <wa...@gmail.com>.
>> > Should I better specify the exact dependencies and investigate some
>> > more work in POM maintainance? What would this gain me?
>>
>> You answered your own question, congrats! :)
>
> Well, if I got you right, you mean it won't gain me anything. Right?

I made no such statement. I was simply agreeing that you should
"specify the exact dependencies."

> So using javaee-api instead of the finer grained POMs DOES CAUSE
> problems. Or am I doing something wrong here?

Probably you should just use the finer grained POMs. Or better, make a
parent project, use depMgmt, specify versions there, then only
<depend> on the correct things in your various modules. It is not
*that* much more work.

Wayne

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


Re: Best practices for Java EE 7 dependencies

Posted by Martin Hoeller <ma...@xss.co.at>.
Hi!

Thanks for your answers so far.

Am Fri, 7 Feb 2014 11:17:22 -0600 schrieb Wayne Fay <wa...@gmail.com>:

> > Should I better specify the exact dependencies and investigate some
> > more work in POM maintainance? What would this gain me?
> 
> You answered your own question, congrats! :)

Well, if I got you right, you mean it won't gain me anything. Right?

But I just found out a first problem that arises with the use
javaee-api: "mvn dependency:analyze" reports used undeclared
dependencies :(

It's totally clear why it reports these: annotation classes like
@Stateless are in the javax.ejb-api JAR and javaee-api declares a
dependency to it but my actual module does not.

So using javaee-api instead of the finer grained POMs DOES CAUSE
problems. Or am I doing something wrong here?

many thanks,
- martin

Re: Best practices for Java EE 7 dependencies

Posted by Wayne Fay <wa...@gmail.com>.
> Should I better specify the exact dependencies and investigate some more
> work in POM maintainance? What would this gain me?

You answered your own question, congrats! :)

Wayne

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


Re: Best practices for Java EE 7 dependencies

Posted by Thomas Broyer <t....@gmail.com>.
Because javax:javaee-api:7.0 doesn't use dependencyManagement, but declares
straight dependencies, I don't think <scope>import</scope> would work (or
be appropriate); however you should be able to declare javax:javaee-api:1.0
as a managed dependency (in <dependencyManagement>, but without any
specific scope, i.e. <scope>compile</scope> as it's the default) and then
declare needed dependencies; I'm not sure that'd work either though. So I
think the only real choice is to add it as a dependency, with
<scope>provided</scope>; you'll have all the JARs in the classpath at build
time, but only at build time.


On Fri, Feb 7, 2014 at 11:56 AM, Samuli Saarinen <samuli.saarinen@remion.com
> wrote:

> Hi,
>
> You could import the dependencies  in dependencyManagement as described in
> [1] and only declare needed dependencies in the project.
>
> Cheers
>
> Samuli
>
> [1]
> http://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html#Importing_Dependencies
>
> -----Original Message-----
> From: Martin Hoeller [mailto:martin@xss.co.at]
> Sent: 7. helmikuuta 2014 11:33
> To: Maven Users List
> Subject: Best practices for Java EE 7 dependencies
>
> Hi!
>
> I'm wondering what the best practices are for specifying Java EE 7
> dependencies in my modules.
>
> There is the so called BOM (bill of materials) POM: javax:javaee-api:7.0
> which lists all API submodules required for JEE7. Specifying this in my
> module as
>
>   <dependency>
>     <groupId>javax</groupId>
>     <artifactId>javaee-api</artifactId>
>     <version>7.0</version>
>   </dependency>
>
> works and is the least work for me. However, this way I got all JEE APIs
> on the CLASSPATH even if I just need a few of them. Further on, the
> actual dependencies are now transitive which is (IMHO) not fully correct.
> Should I better specify the exact dependencies and investigate some more
> work in POM maintainance? What would this gain me?
>
> What do you think?
>
> - martin
>



-- 
Thomas Broyer
/tɔ.ma.bʁwa.je/ <http://xn--nna.ma.xn--bwa-xxb.je/>

RE: Best practices for Java EE 7 dependencies

Posted by Samuli Saarinen <sa...@remion.com>.
Hi,

You could import the dependencies  in dependencyManagement as described in [1] and only declare needed dependencies in the project.

Cheers 

Samuli 

[1] http://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html#Importing_Dependencies

-----Original Message-----
From: Martin Hoeller [mailto:martin@xss.co.at] 
Sent: 7. helmikuuta 2014 11:33
To: Maven Users List
Subject: Best practices for Java EE 7 dependencies

Hi!

I'm wondering what the best practices are for specifying Java EE 7
dependencies in my modules.

There is the so called BOM (bill of materials) POM: javax:javaee-api:7.0
which lists all API submodules required for JEE7. Specifying this in my
module as

  <dependency>
    <groupId>javax</groupId>
    <artifactId>javaee-api</artifactId>
    <version>7.0</version>
  </dependency>

works and is the least work for me. However, this way I got all JEE APIs
on the CLASSPATH even if I just need a few of them. Further on, the
actual dependencies are now transitive which is (IMHO) not fully correct.
Should I better specify the exact dependencies and investigate some more
work in POM maintainance? What would this gain me?

What do you think?

- martin