Blogs
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: https://github.com/jorgediaz-lr/generate-modules-classpath
Installation
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 https://raw.githubusercontent.com/jorgediaz-lr/generate-modules-classpath/master/generate_modules_classpath.sh | bash'
(thanks to Cleydyr de Albuquerque for this idea)
For windows users: you can launch the script using git bash, cygwin or mingw
Usage
- Important: Before using the script, execute ant all in order to download all jar dependencies
- Execute /path/generate_modules_classpath.sh [project-directory]
- project-directory: directory where eclipse project is located. (optional parameter, the current directory by default)
- You can also use the "curl" approach explained above:
- execute previous defined alias: generate_modules_classpath
- or execute full command: curl https://raw.githubusercontent.com/jorgediaz-lr/generate-modules-classpath/master/generate_modules_classpath.sh | bash
- 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
- Open eclipse and execute a refresh+clean of the project
In case you also want to add tests classes to classpath, use generate_modules_classpath_with_tests.sh
Result
You will see all src modules and you will be able to find any liferay class from modules