Get dependencies written on Java

Hi all

How can get dependencies of current project, using Java ?
I try this code in Java class but result is empty:

class Example implements Plugin<Project> {
    void apply(Project project) {
             project.getConfigurations().getByName("runtime").getAllDependencies();        
        }
    }