Deterministic ordering of dependencies on the classpath

Hi there,

I have noticed that if you add the dependency programmatically, i.e. project.dependencies.add(‘compile’, ‘my.group:my-artifact’) order is not preserved.

Not only that but although it evaluates to the same thing across invocations, it’s not the same on different machines. Do you have any ideas / recommendations how to deal with this apart from sorting the compileClasspath and setting it explicitly on each compile task?

The reason i have to do the programmatic dependency addition is that i am migrating a very old build that uses maven2 + ant still and in order to keep exactly the same resolution rules while migration is in progress i still read dependencies from pom (via ant-maven plugin) and set them to gradle not as files but gradle managed ones to be able to pull sources etc.

Thanks

1 Like