Debugging Liferay: Adding module classpaths in Eclipse using

Importing in eclipse all java classes from osgi modules

Up to Liferay 6.2, when you opened Liferay project in eclipse, you had all classes imported in project classpath, so you was able to debug Liferay code and execute classes and method searchs.

Since Liferay 7.0, there is a big problem: Liferay project classpaths only includes the core classes and all osgi modules are missing, so you have to (option 1) manually import them or (option 2) create one eclipse project for each module and import the generated 500 projects in your workspace

My workaround: In order to be able to continue working as Liferay 6.2 and previous versions, I have created a unix script that adds all osgi modules classpath to Liferay eclipse project, returning to the monolitic way.
Perhaps it is a bit ugly approach, but it works fine and you are able to debug all portal modules.

You can download my script from git:


Just download and copy the sh files to your system.

You can also add following line to your system aliases:

alias generate_modules_classpath='curl | bash'

(thanks to Cleydyr de Albuquerque for this idea)

For windows users: you can launch the script using git bash, cygwin or mingw


  1. Important: Before using the script, execute ant all in order to download all jar dependencies
  2. Execute /path/ [project-directory]
    • project-directory: directory where eclipse project is located. (optional parameter, the current directory by default)
  3. You can also use the "curl" approach explained above:
    • execute previous defined alias: generate_modules_classpath
    • or execute full command: curl | bash
  4. The script will make a backup of original eclipse .classpath in .classpath_backup and .classpath will be populated with all src and jar files from osgi modules
  5. Open eclipse and execute a refresh+clean of the project

In case you also want to add tests classes to classpath, use


You will see all src modules and you will be able to find any liferay class from modules

 Screenshot eclipse

That script is part of my everyday job. Pretty fast, simple and extremely useful. Thanks, Jorge!
sorry, ant all don't work for me, build.xml not found, can you tell me please where i execute this cmd ?
Hey, Hamza. You have to have a copy of the Liferay Portal source to be able to compile it. You can download it from Once you have it downloaded, you can execute ant all from the liferay-portal folder.

I downloaded latest Liferay Portal source from to my windows machine and trying to execute "ant all" and  ran into below error .  ant 1.7.1 is the version that was set in the environment variables .  What am I missing? Thanks for the help !


C:\Liferay Source\Liferay-portal-master>ant all Buildfile: build.xml   [typedef] Could not load definitions from resource org/apache/maven/artifact/ant/antlib.xml. It could not be found.   [taskdef] Could not load definitions from resource org/jacoco/ant/antlib.xml. It could not be found.

BUILD FAILED C:\Liferay Source\Liferay-portal-master\build.xml:4: The following error occurred while executing this line: C:\Liferay Source\Liferay-portal-master\build-common.xml:126: java.lang.ExceptionInInitializerError



As of Jan 16 hash 3570b6efea23 of liferay-portal, this script is working for me also.


Welcome back to debugging Liferay in eclipse!