GNU ELPA - javaimp


Add and reorder Java import statements in Maven projects
javaimp-0.6.1.tar, 2019-Jan-28, 40.0 KiB
Filipp Gunbin <>
Home page
Browse repository
CGit or Gitweb

To install this package, run in Emacs:

M-x package-install RET javaimp RET

Full description

Allows to manage Java import statements in Maven projects.

  Quick start:

- customize `javaimp-import-group-alist'
- call `javaimp-maven-visit-project', giving it the top-level project
directory where pom.xml resides

Then in a Java buffer visiting a file under that project or one of its
submodules call `javaimp-organize-imports' or `javaimp-add-import'.

This module does not add all needed imports automatically!  It only helps
you to quickly add imports when stepping through compilation errors.

  Some details:

If Maven failed, you can see its output in the buffer named by
`javaimp-debug-buf-name' (default is "*javaimp-debug*").

Contents of jar files and Maven project structures (pom.xml) are cached,
so usually only the first command should take a considerable amount of
time to complete.  If a module's pom.xml or any of its parents' pom.xml
(within visited tree) was modified after information was loaded, `mvn
dependency:build-classpath' is re-run on the current module.  If a jar
file was changed, its contents are re-read.

Currently inner classes are filtered out from completion alternatives.
You can always import top-level class and use qualified name.

  Example of initialization:

(require 'javaimp)

(add-to-list 'javaimp-import-group-alist
  '("\\`\\(my\\.company\\.\\|my\\.company2\\.\\)" . 80))

(setq javaimp-additional-source-dirs '("generated-sources/thrift"))

(add-hook 'java-mode-hook
	  (lambda ()
	    (local-set-key "\C-ci" 'javaimp-add-import)
	    (local-set-key "\C-co" 'javaimp-organize-imports)))


- use functions `cygwin-convert-file-name-from-windows' and
`cygwin-convert-file-name-to-windows' when they are available instead of
calling `cygpath'.  See

- save/restore state, on restore check if a root exists and delete it if

- `javaimp-add-import': without prefix arg narrow alternatives by local name;
with prefix arg include all classes in alternatives

- :type for defcustom

Old versions

javaimp-0.6.tar2016-May-1940.0 KiB
javaimp-0.6.el2015-Oct-2927.5 KiB
javaimp-0.5.el2014-Oct-0121.3 KiB
javaimp-0.4.el2014-Jul-1120.6 KiB