New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Publish JUnit Platform Gradle Plugin to Gradle plugin repository #768

Closed
jackmiras opened this Issue Apr 4, 2017 · 14 comments

Comments

Projects
None yet
9 participants
@jackmiras

jackmiras commented Apr 4, 2017

The current gradle plugin implementation where Junit 5 is available doesn't support the new syntax of plugins inclusion from gradle.

Currently in order to include Junit 5 in a gradle project I have to implement the following script:

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

apply plugin: 'org.junit.platform.gradle.plugin'

But recently gradle include a new feature that allows us to load plugins by implement a shorter script, just like down below:

plugins {
    id 'org.junit.platform.gradle.plugin' version '1.0.0-M4'
}

Unfortunately is not possible to load Junit 5 plugin in the second way because to load plugins in that way the plugins must be "uploaded" in the plugins gradle repositorty... The steps to inclue a plugin in the repository is available in the following link.

@sbrannen

This comment has been minimized.

Show comment
Hide comment
@sbrannen

sbrannen Apr 4, 2017

Member

We are aware of this and will look into it.

Cheers!

Member

sbrannen commented Apr 4, 2017

We are aware of this and will look into it.

Cheers!

@sbrannen sbrannen self-assigned this Apr 4, 2017

@sbrannen sbrannen changed the title from Applying Gradle plugins with the plugins DSL to Publish JUnit Platform Gradle Plugin to Gradle plugin repository Apr 4, 2017

@sbrannen sbrannen added this to the 5.0 M5 milestone Apr 4, 2017

@jochenchrist

This comment has been minimized.

Show comment
Hide comment
@jochenchrist

jochenchrist Jun 9, 2017

The plugin id should simply be

org.junit.platform

as the suffix .gradle.plugin is quite obvious in the Gradle plugin repo.

jochenchrist commented Jun 9, 2017

The plugin id should simply be

org.junit.platform

as the suffix .gradle.plugin is quite obvious in the Gradle plugin repo.

@sormuras

This comment has been minimized.

Show comment
Hide comment
@sormuras

sormuras Jun 9, 2017

Member

I really hope, after the 4.0 dust settles, the native/core plugin will be designed and implemented: gradle/gradle#1037

Member

sormuras commented Jun 9, 2017

I really hope, after the 4.0 dust settles, the native/core plugin will be designed and implemented: gradle/gradle#1037

@marcphilipp marcphilipp modified the milestones: 5.0 M5, 5.0 M6 Jun 20, 2017

@sbrannen sbrannen modified the milestones: 5.0 M6, 5.0 RC1 Jul 3, 2017

@sbrannen sbrannen modified the milestones: 5.0 RC1, 5.0 GA Jul 25, 2017

@marcphilipp marcphilipp modified the milestones: 5.0 GA, 5.1 Backlog Sep 7, 2017

@Minecrell

This comment has been minimized.

Show comment
Hide comment
@Minecrell

Minecrell Sep 17, 2017

If anyone stumbles on this issue trying to use the JUnit Platform Gradle Plugin together with kotlin-dsl and its automatically generated extension accessors, it's also possible to use the pluginManagement DSL as a workaround to make the plugin available within the plugins block. By default, kotlin-dsl only generates extension accessors for plugins applied in the plugins block so the solution below is necessary if you want to access junitPlatform directly in your build script.

If you add this to settings.gradle:

// Workaround to make the JUnit Platform Gradle Plugin available using the `plugins` DSL
// See https://github.com/junit-team/junit5/issues/768
pluginManagement {
    repositories {
        gradlePluginPortal()
        maven { url = ArtifactRepositoryContainer.MAVEN_CENTRAL_URL }
    }
    resolutionStrategy {
        eachPlugin {
            if (requested.id.id == 'org.junit.platform.gradle.plugin') {
                useModule("org.junit.platform:junit-platform-gradle-plugin:${requested.version}")
            }
        }
    }
}

You can then reference it normally with the plugins DSL:

plugins {
    id("org.junit.platform.gradle.plugin") version "1.0.0"
}

junitPlatform {
    platformVersion = "1.0"
    logManager = "org.apache.logging.log4j.jul.LogManager"
    setReportsDir(file("build/test-results/junit-platform"))
}

Minecrell commented Sep 17, 2017

If anyone stumbles on this issue trying to use the JUnit Platform Gradle Plugin together with kotlin-dsl and its automatically generated extension accessors, it's also possible to use the pluginManagement DSL as a workaround to make the plugin available within the plugins block. By default, kotlin-dsl only generates extension accessors for plugins applied in the plugins block so the solution below is necessary if you want to access junitPlatform directly in your build script.

If you add this to settings.gradle:

// Workaround to make the JUnit Platform Gradle Plugin available using the `plugins` DSL
// See https://github.com/junit-team/junit5/issues/768
pluginManagement {
    repositories {
        gradlePluginPortal()
        maven { url = ArtifactRepositoryContainer.MAVEN_CENTRAL_URL }
    }
    resolutionStrategy {
        eachPlugin {
            if (requested.id.id == 'org.junit.platform.gradle.plugin') {
                useModule("org.junit.platform:junit-platform-gradle-plugin:${requested.version}")
            }
        }
    }
}

You can then reference it normally with the plugins DSL:

plugins {
    id("org.junit.platform.gradle.plugin") version "1.0.0"
}

junitPlatform {
    platformVersion = "1.0"
    logManager = "org.apache.logging.log4j.jul.LogManager"
    setReportsDir(file("build/test-results/junit-platform"))
}
@sdeleuze

This comment has been minimized.

Show comment
Hide comment
@sdeleuze

sdeleuze Oct 13, 2017

+1 for publishing the plugin, this is especially needed for Kotlin developers.

sdeleuze commented Oct 13, 2017

+1 for publishing the plugin, this is especially needed for Kotlin developers.

@sbrannen sbrannen modified the milestones: 5.x Backlog, 5.1 Backlog Oct 13, 2017

@sbrannen

This comment has been minimized.

Show comment
Hide comment
@sbrannen

sbrannen Oct 13, 2017

Member

Switched to 5.1 Backlog

Member

sbrannen commented Oct 13, 2017

Switched to 5.1 Backlog

@sdeleuze

This comment has been minimized.

Show comment
Hide comment
@sdeleuze

sdeleuze Oct 16, 2017

@Minecrell As reported here, this workaround seems to work only when the plugin is in Gradle cache. I have raised the point to gradle team and am waiting their feedback.

sdeleuze commented Oct 16, 2017

@Minecrell As reported here, this workaround seems to work only when the plugin is in Gradle cache. I have raised the point to gradle team and am waiting their feedback.

@Minecrell

This comment has been minimized.

Show comment
Hide comment
@Minecrell

Minecrell Oct 18, 2017

@sdeleuze Weird, it's still working for me after deleting the ~/.gradle cache. It downloads the JUnit Gradle plugin automatically.

I think this is something that is broken specifically only for your project. I can't tell for sure, but it looks like the issue in your case is somehow connected to the custom Maven repository and the specific setup of the POM of org.springframework.boot:spring-boot-gradle-plugin:2.0.0.M5.

The workaround I've posted above is working correctly for the JUnit Gradle plugin.

Minecrell commented Oct 18, 2017

@sdeleuze Weird, it's still working for me after deleting the ~/.gradle cache. It downloads the JUnit Gradle plugin automatically.

I think this is something that is broken specifically only for your project. I can't tell for sure, but it looks like the issue in your case is somehow connected to the custom Maven repository and the specific setup of the POM of org.springframework.boot:spring-boot-gradle-plugin:2.0.0.M5.

The workaround I've posted above is working correctly for the JUnit Gradle plugin.

@sdeleuze

This comment has been minimized.

Show comment
Hide comment
@sdeleuze

sdeleuze Oct 18, 2017

@Minecrell It works in your case probably because all your artifacts are in Maven Central, when you are using multiple repos, it is broken, see gradle/gradle#3210 (comment).

sdeleuze commented Oct 18, 2017

@Minecrell It works in your case probably because all your artifacts are in Maven Central, when you are using multiple repos, it is broken, see gradle/gradle#3210 (comment).

@dmvk

This comment has been minimized.

Show comment
Hide comment
@dmvk

dmvk Jan 21, 2018

Is there any blocker for this issue? This could make move to junit 5 much less painful for gradle users.

dmvk commented Jan 21, 2018

Is there any blocker for this issue? This could make move to junit 5 much less painful for gradle users.

@marcphilipp

This comment has been minimized.

Show comment
Hide comment
@marcphilipp

marcphilipp Jan 27, 2018

Member

We're working with Gradle towards official support so it might be better not to publish it to the Gradle plugin repository in order to avoid confusing future users.

@junit-team/junit-lambda Thoughts?

Member

marcphilipp commented Jan 27, 2018

We're working with Gradle towards official support so it might be better not to publish it to the Gradle plugin repository in order to avoid confusing future users.

@junit-team/junit-lambda Thoughts?

@sormuras

This comment has been minimized.

Show comment
Hide comment
@sormuras

sormuras Jan 27, 2018

Member

As the official integration into Gradle "is near", we should not publish the soon to-be deprecated implementation.

Member

sormuras commented Jan 27, 2018

As the official integration into Gradle "is near", we should not publish the soon to-be deprecated implementation.

@guenhter

This comment has been minimized.

Show comment
Hide comment
@guenhter

guenhter commented Mar 13, 2018

I guess with gradle 4.6, this is no longer an issue because support is now integrated.

https://docs.gradle.org/4.6/release-notes.html?_ga=2.23402686.529326761.1520834024-229490448.1507271429#junit-5-support

@sbrannen

This comment has been minimized.

Show comment
Hide comment
@sbrannen

sbrannen Mar 13, 2018

Member

Good point.

Thanks for mentioning it!

I'll close this issue now...

Member

sbrannen commented Mar 13, 2018

Good point.

Thanks for mentioning it!

I'll close this issue now...

@sbrannen sbrannen closed this Mar 13, 2018

@sbrannen sbrannen removed this from the 5.2 Backlog milestone Mar 13, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment