You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Lin Ma <li...@gmail.com> on 2015/03/23 06:24:19 UTC
java import package and maven dependencies
Hi Maven masters,
It is magic when we add dependencies in Maven pom.xml, IDE like IntelliJ
could resolve it for java import package statement at the beginning of each
.java file.
Want to learn a bit more how Maven or IDE will use dependencies in Maven
pom.xml file to resolve import package in .java file automatically? Does it
on the backend download and put the jar in dependencies in class path, and
treat it the same as manually add an external jar file?
Any good articles are appreciated.
thanks in advance,
Lin
Re: java import package and maven dependencies
Posted by Bernd Eckenfels <ec...@zusammenkunft.net>.
Hello,
if you found it in the Gui the file does not add any more information.
But if you want to have a look at it, it is in the root folder of the
project. The package explorer by default does not show .* resources.
You can either use windows explorer, the Eclipse navigator or enable .*
resources (in the package explorer, there is a down arrow, if you
click it there is a menu entry filters, and in the list the first
entry is .* resources.).
Gruss
Bernd
Am Tue, 24
Mar 2015 17:52:23 -0700 schrieb Lin Ma <li...@gmail.com>:
> Thanks Gruss,
>
> Following your guidance I found the maven dependencies, and where is
> the .classpath file you are referring to? I do not find it in
> workspace of the project. I created a new maven project in Eclipse.
>
> [image: Inline image 2]
>
> regards,
> Lin
>
> On Tue, Mar 24, 2015 at 4:38 PM, Bernd Eckenfels
> <ec...@zusammenkunft.net> wrote:
>
> > Am Tue, 24 Mar 2015 16:23:23 -0700
> > schrieb Lin Ma <li...@gmail.com>:
> >
> > > How to find Maven updated Classpath and its priority over existing
> > > Classpath in Eclipse? I use both and Eclipse is less. :)
> >
> > Not sure I understand the question, but in Eclipse you can see in
> > the (Right click -> Project settings -> Java Build Path ->
> > Libraries in what sequence manual/eclipse/maven libs are searched.
> > (Same is true for source and generated-source folders). 'You also
> > see this in the .classpath file (it must contain:)
> >
> > <classpathentry kind="con"
> > path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
> > ... <attribute name="maven.pomderived"
> > value="true"/>
> >
> > And when you open "Maven Dependencies" in the Package Explorer you
> > see the dependencies on your build path (inserted by maven). With
> > Alt+F5 they get refreshed. (It will use eclipse internal
> > maven+settings to populate this list).
> >
> > Note that there is no 100% match between compile dependencies,
> > pluigins and stuff between Eclipse and M2e (but for normal projects
> > its not an issue).
> >
> > Gruss
> > Bernd
> >
> > ---------------------------------------------------------------------
> > 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: java import package and maven dependencies
Posted by Mirko Friedenhagen <mf...@gmail.com>.
Hello Lin,
maybe while struggling with this you could ask for help at the
m2-users@eclipse.org mailing list.
Gruss
Mirko
--
Sent from my mobile
On Mar 25, 2015 1:52 AM, "Lin Ma" <li...@gmail.com> wrote:
> Thanks Gruss,
>
> Following your guidance I found the maven dependencies, and where is the
> .classpath file you are referring to? I do not find it in workspace of the
> project. I created a new maven project in Eclipse.
>
> [image: Inline image 2]
>
> regards,
> Lin
>
> On Tue, Mar 24, 2015 at 4:38 PM, Bernd Eckenfels <ec...@zusammenkunft.net>
> wrote:
>
>> Am Tue, 24 Mar 2015 16:23:23 -0700
>> schrieb Lin Ma <li...@gmail.com>:
>>
>> > How to find Maven updated Classpath and its priority over existing
>> > Classpath in Eclipse? I use both and Eclipse is less. :)
>>
>> Not sure I understand the question, but in Eclipse you can see in the
>> (Right click -> Project settings -> Java Build Path -> Libraries in what
>> sequence manual/eclipse/maven libs are searched. (Same is true for
>> source and generated-source folders). 'You also see this in
>> the .classpath file (it must contain:)
>>
>> <classpathentry kind="con"
>> path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
>> ... <attribute name="maven.pomderived"
>> value="true"/>
>>
>> And when you open "Maven Dependencies" in the Package Explorer you see
>> the dependencies on your build path (inserted by maven). With Alt+F5
>> they get refreshed. (It will use eclipse internal maven+settings to
>> populate this list).
>>
>> Note that there is no 100% match between compile dependencies, pluigins
>> and stuff between Eclipse and M2e (but for normal projects its not an
>> issue).
>>
>> Gruss
>> Bernd
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
>> For additional commands, e-mail: users-help@maven.apache.org
>>
>>
>
Re: java import package and maven dependencies
Posted by Lin Ma <li...@gmail.com>.
Thanks Gruss,
Following your guidance I found the maven dependencies, and where is the
.classpath file you are referring to? I do not find it in workspace of the
project. I created a new maven project in Eclipse.
[image: Inline image 2]
regards,
Lin
On Tue, Mar 24, 2015 at 4:38 PM, Bernd Eckenfels <ec...@zusammenkunft.net>
wrote:
> Am Tue, 24 Mar 2015 16:23:23 -0700
> schrieb Lin Ma <li...@gmail.com>:
>
> > How to find Maven updated Classpath and its priority over existing
> > Classpath in Eclipse? I use both and Eclipse is less. :)
>
> Not sure I understand the question, but in Eclipse you can see in the
> (Right click -> Project settings -> Java Build Path -> Libraries in what
> sequence manual/eclipse/maven libs are searched. (Same is true for
> source and generated-source folders). 'You also see this in
> the .classpath file (it must contain:)
>
> <classpathentry kind="con"
> path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
> ... <attribute name="maven.pomderived"
> value="true"/>
>
> And when you open "Maven Dependencies" in the Package Explorer you see
> the dependencies on your build path (inserted by maven). With Alt+F5
> they get refreshed. (It will use eclipse internal maven+settings to
> populate this list).
>
> Note that there is no 100% match between compile dependencies, pluigins
> and stuff between Eclipse and M2e (but for normal projects its not an
> issue).
>
> Gruss
> Bernd
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>
Re: java import package and maven dependencies
Posted by Bernd Eckenfels <ec...@zusammenkunft.net>.
Am Tue, 24 Mar 2015 16:23:23 -0700
schrieb Lin Ma <li...@gmail.com>:
> How to find Maven updated Classpath and its priority over existing
> Classpath in Eclipse? I use both and Eclipse is less. :)
Not sure I understand the question, but in Eclipse you can see in the
(Right click -> Project settings -> Java Build Path -> Libraries in what
sequence manual/eclipse/maven libs are searched. (Same is true for
source and generated-source folders). 'You also see this in
the .classpath file (it must contain:)
<classpathentry kind="con"
path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
... <attribute name="maven.pomderived"
value="true"/>
And when you open "Maven Dependencies" in the Package Explorer you see
the dependencies on your build path (inserted by maven). With Alt+F5
they get refreshed. (It will use eclipse internal maven+settings to
populate this list).
Note that there is no 100% match between compile dependencies, pluigins
and stuff between Eclipse and M2e (but for normal projects its not an
issue).
Gruss
Bernd
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
Re: java import package and maven dependencies
Posted by Lin Ma <li...@gmail.com>.
Thanks Markus,
How to find Maven updated Classpath and its priority over existing
Classpath in Eclipse? I use both and Eclipse is less. :)
regards,
Lin
On Tue, Mar 24, 2015 at 4:16 PM, Markus Karg <ka...@quipsy.de> wrote:
> Sorry I have no experience with IntelliJ, as I solely use Eclipse.
>
> -----Original Message-----
> From: Lin Ma [mailto:linlma@gmail.com]
> Sent: Montag, 23. März 2015 23:05
> To: Maven Users List
> Subject: Re: java import package and maven dependencies
>
> Thanks Markus,
>
> Do you know on IntelliJ, how to see Maven update Classpath and settings in
> IntelliJ how Classpath by Maven is prioritized among other Jars/paths on
> Classpath?
>
> regards,
> Lin
>
> On Mon, Mar 23, 2015 at 2:07 AM, Markus Karg <ka...@quipsy.de> wrote:
>
> > With "at runtime" I mean "when Eclipse is performing the 'organize
> import'
> > functionality" or its various variants.
> >
> > -----Ursprüngliche Nachricht-----
> > Von: Lin Ma [mailto:linlma@gmail.com]
> > Gesendet: Montag, 23. März 2015 08:59
> > An: Maven Users List
> > Betreff: Re: java import package and maven dependencies
> >
> > Thanks Markus,
> >
> > For "at runtime", I think you do not mean when running the Java
> > application, but when we add a new dependency in pom.xml, Maven will
> > download the dependency and add the JAR into Classpath which Eclipse
> > will recognize? -- so that the import package statements could be
> > recognized and resolved in IDE?
> >
> > regards,
> > Lin
> >
> > On Mon, Mar 23, 2015 at 12:29 AM, Markus Karg <ka...@quipsy.de> wrote:
> >
> > > Lin,
> > >
> > > there is no magic involved. Maven produces a Class Path at runtime
> > > made up from the declared dependencies in the effective POM (i. e.
> > > your explicit POM and any explicit and implicit parent POMs, and any
> > > implied POMs due to dependencies). Eclipse uses that Class Path as
> > > part of the one it constructs on its own, you even can tell Eclipse
> > > the rank where to put the Maven Classpath relatively to siblings.
> > > Eclipse just checks all Classes in the Classpath for name equality,
> > > picks the sole match automatically, or provides a list of possible
> > matches for the user to pick from. That's all.
> > > Pretty simple and straightforward, and everything but magic.
> > >
> > > Regards
> > > -Markus
> > >
> > > -----Ursprüngliche Nachricht-----
> > > Von: Lin Ma [mailto:linlma@gmail.com]
> > > Gesendet: Montag, 23. März 2015 06:24
> > > An: Maven Users List
> > > Betreff: java import package and maven dependencies
> > >
> > > Hi Maven masters,
> > >
> > > It is magic when we add dependencies in Maven pom.xml, IDE like
> > > IntelliJ could resolve it for java import package statement at the
> > > beginning of each .java file.
> > >
> > > Want to learn a bit more how Maven or IDE will use dependencies in
> > > Maven pom.xml file to resolve import package in .java file
> > > automatically? Does it on the backend download and put the jar in
> > > dependencies in class path, and treat it the same as manually add an
> > external jar file?
> > >
> > > Any good articles are appreciated.
> > >
> > > thanks in advance,
> > > Lin
> > >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
RE: java import package and maven dependencies
Posted by Markus Karg <ka...@quipsy.de>.
Sorry I have no experience with IntelliJ, as I solely use Eclipse.
-----Original Message-----
From: Lin Ma [mailto:linlma@gmail.com]
Sent: Montag, 23. März 2015 23:05
To: Maven Users List
Subject: Re: java import package and maven dependencies
Thanks Markus,
Do you know on IntelliJ, how to see Maven update Classpath and settings in IntelliJ how Classpath by Maven is prioritized among other Jars/paths on Classpath?
regards,
Lin
On Mon, Mar 23, 2015 at 2:07 AM, Markus Karg <ka...@quipsy.de> wrote:
> With "at runtime" I mean "when Eclipse is performing the 'organize import'
> functionality" or its various variants.
>
> -----Ursprüngliche Nachricht-----
> Von: Lin Ma [mailto:linlma@gmail.com]
> Gesendet: Montag, 23. März 2015 08:59
> An: Maven Users List
> Betreff: Re: java import package and maven dependencies
>
> Thanks Markus,
>
> For "at runtime", I think you do not mean when running the Java
> application, but when we add a new dependency in pom.xml, Maven will
> download the dependency and add the JAR into Classpath which Eclipse
> will recognize? -- so that the import package statements could be
> recognized and resolved in IDE?
>
> regards,
> Lin
>
> On Mon, Mar 23, 2015 at 12:29 AM, Markus Karg <ka...@quipsy.de> wrote:
>
> > Lin,
> >
> > there is no magic involved. Maven produces a Class Path at runtime
> > made up from the declared dependencies in the effective POM (i. e.
> > your explicit POM and any explicit and implicit parent POMs, and any
> > implied POMs due to dependencies). Eclipse uses that Class Path as
> > part of the one it constructs on its own, you even can tell Eclipse
> > the rank where to put the Maven Classpath relatively to siblings.
> > Eclipse just checks all Classes in the Classpath for name equality,
> > picks the sole match automatically, or provides a list of possible
> matches for the user to pick from. That's all.
> > Pretty simple and straightforward, and everything but magic.
> >
> > Regards
> > -Markus
> >
> > -----Ursprüngliche Nachricht-----
> > Von: Lin Ma [mailto:linlma@gmail.com]
> > Gesendet: Montag, 23. März 2015 06:24
> > An: Maven Users List
> > Betreff: java import package and maven dependencies
> >
> > Hi Maven masters,
> >
> > It is magic when we add dependencies in Maven pom.xml, IDE like
> > IntelliJ could resolve it for java import package statement at the
> > beginning of each .java file.
> >
> > Want to learn a bit more how Maven or IDE will use dependencies in
> > Maven pom.xml file to resolve import package in .java file
> > automatically? Does it on the backend download and put the jar in
> > dependencies in class path, and treat it the same as manually add an
> external jar file?
> >
> > Any good articles are appreciated.
> >
> > thanks in advance,
> > Lin
> >
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
Re: java import package and maven dependencies
Posted by Lin Ma <li...@gmail.com>.
Thanks Markus,
Do you know on IntelliJ, how to see Maven update Classpath and settings in
IntelliJ how Classpath by Maven is prioritized among other Jars/paths on
Classpath?
regards,
Lin
On Mon, Mar 23, 2015 at 2:07 AM, Markus Karg <ka...@quipsy.de> wrote:
> With "at runtime" I mean "when Eclipse is performing the 'organize import'
> functionality" or its various variants.
>
> -----Ursprüngliche Nachricht-----
> Von: Lin Ma [mailto:linlma@gmail.com]
> Gesendet: Montag, 23. März 2015 08:59
> An: Maven Users List
> Betreff: Re: java import package and maven dependencies
>
> Thanks Markus,
>
> For "at runtime", I think you do not mean when running the Java
> application, but when we add a new dependency in pom.xml, Maven will
> download the dependency and add the JAR into Classpath which Eclipse will
> recognize? -- so that the import package statements could be recognized and
> resolved in IDE?
>
> regards,
> Lin
>
> On Mon, Mar 23, 2015 at 12:29 AM, Markus Karg <ka...@quipsy.de> wrote:
>
> > Lin,
> >
> > there is no magic involved. Maven produces a Class Path at runtime
> > made up from the declared dependencies in the effective POM (i. e.
> > your explicit POM and any explicit and implicit parent POMs, and any
> > implied POMs due to dependencies). Eclipse uses that Class Path as
> > part of the one it constructs on its own, you even can tell Eclipse
> > the rank where to put the Maven Classpath relatively to siblings.
> > Eclipse just checks all Classes in the Classpath for name equality,
> > picks the sole match automatically, or provides a list of possible
> matches for the user to pick from. That's all.
> > Pretty simple and straightforward, and everything but magic.
> >
> > Regards
> > -Markus
> >
> > -----Ursprüngliche Nachricht-----
> > Von: Lin Ma [mailto:linlma@gmail.com]
> > Gesendet: Montag, 23. März 2015 06:24
> > An: Maven Users List
> > Betreff: java import package and maven dependencies
> >
> > Hi Maven masters,
> >
> > It is magic when we add dependencies in Maven pom.xml, IDE like
> > IntelliJ could resolve it for java import package statement at the
> > beginning of each .java file.
> >
> > Want to learn a bit more how Maven or IDE will use dependencies in
> > Maven pom.xml file to resolve import package in .java file
> > automatically? Does it on the backend download and put the jar in
> > dependencies in class path, and treat it the same as manually add an
> external jar file?
> >
> > Any good articles are appreciated.
> >
> > thanks in advance,
> > Lin
> >
>
AW: java import package and maven dependencies
Posted by Markus Karg <ka...@quipsy.de>.
With "at runtime" I mean "when Eclipse is performing the 'organize import' functionality" or its various variants.
-----Ursprüngliche Nachricht-----
Von: Lin Ma [mailto:linlma@gmail.com]
Gesendet: Montag, 23. März 2015 08:59
An: Maven Users List
Betreff: Re: java import package and maven dependencies
Thanks Markus,
For "at runtime", I think you do not mean when running the Java application, but when we add a new dependency in pom.xml, Maven will download the dependency and add the JAR into Classpath which Eclipse will recognize? -- so that the import package statements could be recognized and resolved in IDE?
regards,
Lin
On Mon, Mar 23, 2015 at 12:29 AM, Markus Karg <ka...@quipsy.de> wrote:
> Lin,
>
> there is no magic involved. Maven produces a Class Path at runtime
> made up from the declared dependencies in the effective POM (i. e.
> your explicit POM and any explicit and implicit parent POMs, and any
> implied POMs due to dependencies). Eclipse uses that Class Path as
> part of the one it constructs on its own, you even can tell Eclipse
> the rank where to put the Maven Classpath relatively to siblings.
> Eclipse just checks all Classes in the Classpath for name equality,
> picks the sole match automatically, or provides a list of possible matches for the user to pick from. That's all.
> Pretty simple and straightforward, and everything but magic.
>
> Regards
> -Markus
>
> -----Ursprüngliche Nachricht-----
> Von: Lin Ma [mailto:linlma@gmail.com]
> Gesendet: Montag, 23. März 2015 06:24
> An: Maven Users List
> Betreff: java import package and maven dependencies
>
> Hi Maven masters,
>
> It is magic when we add dependencies in Maven pom.xml, IDE like
> IntelliJ could resolve it for java import package statement at the
> beginning of each .java file.
>
> Want to learn a bit more how Maven or IDE will use dependencies in
> Maven pom.xml file to resolve import package in .java file
> automatically? Does it on the backend download and put the jar in
> dependencies in class path, and treat it the same as manually add an external jar file?
>
> Any good articles are appreciated.
>
> thanks in advance,
> Lin
>
Re: java import package and maven dependencies
Posted by Lin Ma <li...@gmail.com>.
Thanks Markus,
For "at runtime", I think you do not mean when running the Java
application, but when we add a new dependency in pom.xml, Maven will
download the dependency and add the JAR into Classpath which Eclipse will
recognize? -- so that the import package statements could be recognized and
resolved in IDE?
regards,
Lin
On Mon, Mar 23, 2015 at 12:29 AM, Markus Karg <ka...@quipsy.de> wrote:
> Lin,
>
> there is no magic involved. Maven produces a Class Path at runtime made up
> from the declared dependencies in the effective POM (i. e. your explicit
> POM and any explicit and implicit parent POMs, and any implied POMs due to
> dependencies). Eclipse uses that Class Path as part of the one it
> constructs on its own, you even can tell Eclipse the rank where to put the
> Maven Classpath relatively to siblings. Eclipse just checks all Classes in
> the Classpath for name equality, picks the sole match automatically, or
> provides a list of possible matches for the user to pick from. That's all.
> Pretty simple and straightforward, and everything but magic.
>
> Regards
> -Markus
>
> -----Ursprüngliche Nachricht-----
> Von: Lin Ma [mailto:linlma@gmail.com]
> Gesendet: Montag, 23. März 2015 06:24
> An: Maven Users List
> Betreff: java import package and maven dependencies
>
> Hi Maven masters,
>
> It is magic when we add dependencies in Maven pom.xml, IDE like IntelliJ
> could resolve it for java import package statement at the beginning of each
> .java file.
>
> Want to learn a bit more how Maven or IDE will use dependencies in Maven
> pom.xml file to resolve import package in .java file automatically? Does it
> on the backend download and put the jar in dependencies in class path, and
> treat it the same as manually add an external jar file?
>
> Any good articles are appreciated.
>
> thanks in advance,
> Lin
>
AW: java import package and maven dependencies
Posted by Markus Karg <ka...@quipsy.de>.
Lin,
there is no magic involved. Maven produces a Class Path at runtime made up from the declared dependencies in the effective POM (i. e. your explicit POM and any explicit and implicit parent POMs, and any implied POMs due to dependencies). Eclipse uses that Class Path as part of the one it constructs on its own, you even can tell Eclipse the rank where to put the Maven Classpath relatively to siblings. Eclipse just checks all Classes in the Classpath for name equality, picks the sole match automatically, or provides a list of possible matches for the user to pick from. That's all. Pretty simple and straightforward, and everything but magic.
Regards
-Markus
-----Ursprüngliche Nachricht-----
Von: Lin Ma [mailto:linlma@gmail.com]
Gesendet: Montag, 23. März 2015 06:24
An: Maven Users List
Betreff: java import package and maven dependencies
Hi Maven masters,
It is magic when we add dependencies in Maven pom.xml, IDE like IntelliJ could resolve it for java import package statement at the beginning of each .java file.
Want to learn a bit more how Maven or IDE will use dependencies in Maven pom.xml file to resolve import package in .java file automatically? Does it on the backend download and put the jar in dependencies in class path, and treat it the same as manually add an external jar file?
Any good articles are appreciated.
thanks in advance,
Lin