Compilation issue upgrading from 2.4 to 2.5

After upgrading a project of mine to Gradle 2.5, I’m running into some kind of bug with the javac classpath resolution order. The project compiles in Gradle 2.4, but fails in 2.5. I have a project where I’m including these dependencies:

dependencies {
    compile group: 'junit', name: 'junit', version: '4.+'
    compile group: 'org.jmock', name: 'jmock-junit4', version: '2.6.0'
    compile group: 'org.jmock', name: 'jmock-legacy', version: '2.6.0'
}

In Gradle 2.4, the hamcrest-library jar seems to get added to the classpath as the last element, whereas in Gradle 2.5, the jar gets added at the front of the classpath. As far as I can tell, this change seems to be only change between the javac compiler args between the two versions. 2.5 fails to compile with this error:

/home/omitted/tmp/j/src/main/java/Test.java:8: error: matchesSafely(String) in Test cannot override matchesSafely(T) in TypeSafeMatcher
    protected boolean matchesSafely(String item) {
                      ^
  attempting to assign weaker access privileges; was public
  where T is a type-variable:
    T extends Object declared in class TypeSafeMatcher

I’ve included a minimal example that displays the problem below. In the minimal example, the issue goes away when I remove the dependency on jmock-legacy, but that isn’t an option in the full project. I’m using Oracle Java 8u51 on Arch Linux, and I’ve also seen the issue on a Ubuntu 14.04 Server, running Oracle Java 7u80. Any insight that can be shed on this would be helpful.
build.gradle:

apply plugin: 'java'

repositories {
    mavenCentral()
}

dependencies {
    compile group: 'junit', name: 'junit', version: '4.+'
    compile group: 'org.jmock', name: 'jmock-junit4', version: '2.6.0'
    compile group: 'org.jmock', name: 'jmock-legacy', version: '2.6.0'
}

src/main/java/Test.java

import org.hamcrest.TypeSafeMatcher;
import org.hamcrest.Description;

public class Test extends TypeSafeMatcher<String> {
    @Override
    public void describeTo(Description description) {}

    @Override
    protected boolean matchesSafely(String item) {
        return true;
    }
}

Additionally, I’m not sure what’s up with the code formatting. It renders correctly in the editor on my computer, but not in the final posting.

Thanks for the report, Fredric.

While we don’t consider a change to classpath ordering to be a breaking change, it turns out that Gradle 2.5 introduced a change that means the ordering of artifacts can be unpredictable, which can cause unnecessary inconvenience in cases like yours.

By fixing this unpredictability (use of LinkedHashMap in place of HashMap) the classpath ordering reverts to that from Gradle 2.4. This fix will be in Gradle 2.6-rc-2. I would encourage you to try it out when it is released later this week.