'How to configure the hamcrest dependency for gradle?

Again an abslout beginer question :-(

My gradle version is: Gradle 6.3

I initilized a small gradle project using gradle init for java and junit5 to learn junit5 and jmockit :-) I tried to add some tutorial classes but gradle cannot resolve the hamcrest dependency :-( // https://mvnrepository.com/artifact/org.hamcrest/hamcrest testImplementation 'org.hamcrest:hamcrest:2.2' as well as // https://mvnrepository.com/artifact/org.hamcrest/hamcrest-all testImplementation 'org.hamcrest:hamcrest-all:1.3' on the hamcrest web site, this hint is given http://hamcrest.org/JavaHamcrest/distributables#using-hamcrest-in-a-gradle-project here my build.gradle file:

/*
 * This file was generated by the Gradle 'init' task.
 *
 * This generated file contains a sample Java project to get you started.
 * For more details take a look at the Java Quickstart chapter in the Gradle
 * User Manual available at https://docs.gradle.org/6.3/userguide/tutorial_java_projects.html
 */

plugins {
    // Apply the java plugin to add support for Java
    id 'java'

    // Apply the application plugin to add support for building a CLI application.
    id 'application'
}

repositories {
    // Use jcenter for resolving dependencies.
    // You can declare any Maven/Ivy/file repository here.
    jcenter()
    mavenCentral()
    google()
}

dependencies {
    // This dependency is used by the application.
    implementation 'com.google.guava:guava:28.2-jre'

    testImplementation 'org.hamcrest:hamcrest:2.2'

    // Use JUnit Jupiter API for testing.
    testImplementation 'org.junit.jupiter:junit-jupiter-api:5.6.0'

    // Use JUnit Jupiter Engine for testing.
    testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.6.0'
}


application {
    // Define the main class for the application.
    mainClassName = 'jmockit_examples.App'
}

test {
    // Use junit platform for unit tests
    useJUnitPlatform()
}


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source