Build maven dependencies automatically before build

Hi! Your approach almost works.
But if I add mavenProject("") to dependencies several times, dependency added several times.
So, I have a lot of DefaultSelfResolvingDependency_Decorated@433edba9 items in my configurations.compile.allDependencies
How can I fix it? Maybe by setting identifier?