Get with java (using toolingApi) gradle dependencies without transitivity

Hello ,
I m using toolingApi to manage gradle from java code , i wanna get my dependencies declared in my build.gradle without giving me the transitive dependencies ,

For example ;
for (ExternalDependency externalDependency : project.getClasspath())
here i have all my dependencies even which are not declared in my build.gradle .
if i have:
dependencies {
compile group: ‘group.X’, name: ‘DependencyX’ , version: “11”
even if DependencyX have other dependencies i don’t wanna get it i just wanna get DependencyX.
Any idea how can i get the first level of dependencies from java using toolingApi
Thank you