Junit 5 gradle plugin not found

Try using junit 5 with gradle:

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath 'org.junit.platform:junit-platform-gradle-plugin:1.0.0'
    }
}

apply plugin: 'java-library'
apply plugin: 'org.junit.platform.gradle.plugin'
...

Error:

Plugin with id 'org.junit.platform.gradle.plugin' not found.

Gradle version 4.0. What's wrong?

+4
source share
3 answers

You must include a section repositoriesoutside the block buildscript:

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath 'org.junit.platform:junit-platform-gradle-plugin:1.0.0'
    }
}

apply plugin: 'java-library'
apply plugin: 'org.junit.platform.gradle.plugin'

repositories {
    mavenCentral()
}
+3
source

Do you put the above code in a separate file, which you then include in the main build.gradleone through apply from: ...? If so, you may encounter an error in Gradle, where the plugin identifier cannot be used in external scripts. Instead, you must specify the fully qualified class name.

Additional Information:

https://github.com/gradle/gradle/issues/1262

https://discuss.gradle.org/t/how-do-i-include-buildscript-block-from-external-gradle-script/7016

+1

4.6 Gradle,

Gradle supports Junit5 natively:

dependencies {
    test.useJUnitPlatform()

    testImplementation "org.junit.jupiter:junit-jupiter-params:$junitVersion"
    testImplementation "org.junit.jupiter:junit-jupiter-api:$junitVersion"

    testRuntimeOnly "org.junit.vintage:junit-vintage-engine:4.12.0"
    testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:$junitVersion"
}
0
source

Source: https://habr.com/ru/post/1686566/


All Articles