JPS: return modules and libraries from dependencies in proper order (IDEA-122154) [rev by Peter]