Auto detect jar added in pom

53 views
Skip to first unread message

rlewi...@yahoo.co.uk

unread,
Jun 2, 2013, 2:05:59 AM6/2/13
to eclim...@googlegroups.com
I want to be able to import class automatically when editing source with vim once a new jar is added to maven pom. 

So the following parameter is added to .vimrc

    let g:EclimMavenPomClasspathUpdate = 1

as stated at http://eclim.org/vim/java/classpath.html#classpath-maven for auto updating .classpath 

However, whether setting g:EclimMavenPomClasspathUpdate or not in .vimrc, I still can't get the new class displayed when pressing C-x C-u. For example, in pom.xml a dependency called curator

    <dependency>
      <groupId>org.apache.curator</groupId>
      <artifactId>curator-framework</artifactId>
      <version>2.0.1-incubating</version>
      </dependency>
    <dependency>

is added. 

Then when editing a java class, typing 

    import org.apache.<C-x><C-u>

curator package doesn't appear in popped up menu. 

What is the right way to get newly added package auto detected (added to .classpath) by eclim?

Thanks





Eric Van Dewoestine

unread,
Jun 4, 2013, 9:34:46 AM6/4/13
to eclim...@googlegroups.com
On 2013-06-01 23:05:59, rlewi...@yahoo.co.uk wrote:
> I want to be able to import class automatically when editing source with
> vim once a new jar is added to maven pom.
>
> So the following parameter is added to .vimrc
>
> let g:EclimMavenPomClasspathUpdate = 1

This is the default setting, so you don't need to add that to your
vimrc.

> as stated at http://eclim.org/vim/java/classpath.html#classpath-maven for
> auto updating .classpath
>
> However, whether setting g:EclimMavenPomClasspathUpdate or not in .vimrc, I
> still can't get the new class displayed when pressing C-x C-u. For example,
> in pom.xml a dependency called curator
>
> <dependency>
> <groupId>org.apache.curator</groupId>
> <artifactId>curator-framework</artifactId>
> <version>2.0.1-incubating</version>
> </dependency>
> <dependency>
>
> is added.
>
> Then when editing a java class, typing
>
> import org.apache.<C-x><C-u>
>
> curator package doesn't appear in popped up menu.
>
> What is the right way to get newly added package auto detected (added to
> .classpath) by eclim?

First off, make sure you've run :MvnRepo from within vim if you
haven't already. This will set the required classpath variable needed
to support updating of your .classpath file when saving your pom.xml.

The next step would be to open up your project's .classpath file in
vim to see if the new maven dependencies were auto added there. If
not, then try enabling eclim debug logging in vim:

:let g:EclimLogLevel = 10

and then trying saving your pom.xml again to see if any errors are
reported. If the new dependencies are in your .classpath file, then
you can try writing that file to see if any validation errors are
reported. You can use :lopen to view the full list of errors if there
were any.

It is probably also worth noting that eclim's support for auto
updating your project's .classpath file upon saving of your pom.xml,
does not download any newly added jars. It simply keeps your
.classpath file in sync with your pom.xml so that you don't have to
manage both manually. So when added a new dependency to your pom.xml,
although an appropriate entry will be added to your .classpath file,
there won't actually be a jar at the entry's specified path until you
have maven download those new jars using either:

$ mvn dependency:resolve

or within Vim:

:Mvn dependency:resolve

This aspect isn't clear from the eclim docs, so I'll update those
accordingly.

--
eric
Reply all
Reply to author
Forward
0 new messages