Skip to content
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

Platform dependencies not possible in dependency block of test suite plugin #19065

Closed
toerni opened this issue Nov 19, 2021 · 10 comments · Fixed by #23535
Closed

Platform dependencies not possible in dependency block of test suite plugin #19065

toerni opened this issue Nov 19, 2021 · 10 comments · Fixed by #23535
Assignees
Labels
a:bug in:test-suites Work related to the JvmTestSuite Plugin
Milestone

Comments

@toerni
Copy link

toerni commented Nov 19, 2021

While testing the new test-suite plugin, I tried to add a dependency to my platform in the new dependency block using kotlin dsl

Expected Behavior

Expecting the dependency below to compile

testing {
    suites {

        val integrationtest by registering(JvmTestSuite::class) {
            this.useJUnitJupiter()


            dependencies {
                implementation(platform(project(":myPlatform")))
            }
            
            targets {
                all {
                    testTask.configure {
                        shouldRunAfter(tasks.named("test"))
                        testLogging {
                            events(FAILED, SKIPPED)
                            exceptionFormat = TestExceptionFormat.FULL
                        }
                    }
                }
            }
        }
    }
}

Current Behavior

platform dependency does not compile in script plugin in buildSrc

image

Your Environment

  • gradle 7.3
  • jvm-test-suite plugin
  • used in a script plugin in buildSrc
@Vampire
Copy link
Contributor

Vampire commented Nov 19, 2021

It is the same also for normal build scripts, not only precompiled script plugins.
The problem is, that within the test suite dependencies block the context object is JvmComponentDependencies and not DependencyHandlerScope.
Although the project(...) call is not read, it also is a different project call than one would expect to happen.
Also other things from DependencyHandlerScope are missing like testFixture(...).

Work-arounds are to use something like

implementation(project.dependencies.platform(project.dependencies.project(":myPlatform")))

within the test suite dependencies block, or to use the normal dependencies block like with

val integrationtestImplementation by configurations.getting
dependencies {
    integrationtestImplementation(platform(project(":myPlatform")))
}

@github-actions
Copy link

This issue has been automatically marked as stale because it has not had recent activity. Given the limited bandwidth of the team, it will be scheduled for a (potentially) final review and might be closed afterwards (if no further activity occurs). If you feel this is something you could contribute to, please have a look at our Contributor Guide. Thank you for your contribution.

@github-actions github-actions bot added the stale label Nov 19, 2022
@grossws
Copy link
Contributor

grossws commented Nov 19, 2022

Still relevant

@github-actions github-actions bot removed the stale label Nov 19, 2022
@jfurmankiewiczpros
Copy link

Any updates on this? We just tried to use the jvm-test-suite plugin, but the lack of support for platform has been an unexpected roadblock. We have to go back to custom source sets for integration tests instead of using this cool new plugin.

@grossws
Copy link
Contributor

grossws commented Dec 29, 2022

It was added in 7.6.0 (released on 25th of November, 2022). So I believe the issue should be closed as fixed.

For Gradle 7.3-7.5 @Vampire provided two different viable methods in the comment above.

@big-guy big-guy added this to the 7.6 RC1 milestone Jan 11, 2023
@big-guy big-guy closed this as completed Jan 11, 2023
@LarsKaulen
Copy link
Contributor

Can somebody give a small groovy example, how this should work with 7.6?

Because when I use

dependencies {
    testImplementation(platform("com.example:platform"))
}

or

testing {
    suites {
        configureEach {
            dependencies {
                implementation(project.dependencies.platform("com.example:platform"))
            }
        }
    }
}

in a convention plugin everything works as intended, but when using

testing {
    suites {
        configureEach {
            dependencies {
                implementation(platform("com.example:platform"))
            }
        }
    }
}

I get the following errors:

Cannot set attributes for dependency "com.example:platform:null": it was probably created by a plugin using internal APIs
Could not resolve: com.example:platform

Might that be a problem in my platform definition/creation?

@tresat
Copy link
Member

tresat commented Jan 12, 2023

@LarsKaulen can you put together a reproducer? I just tried this and I'm not seeing that problem.

@LarsKaulen
Copy link
Contributor

LarsKaulen commented Jan 12, 2023

@tresat you can find it here

You can see it works with implementation(project.dependencies.platform("org.example.gradle:platform")) here and here

You can see it does not work with implementation(platform("org.example.gradle:platform")) here and here.

@tresat tresat self-assigned this Jan 12, 2023
@tresat
Copy link
Member

tresat commented Jan 12, 2023

I'm investigating the issue with convention plugins. Thanks for the reproducer.

@tresat
Copy link
Member

tresat commented Jan 13, 2023

@LarsKaulen - Thanks for following up on this. There was indeed a problem using Test Suites and platforms which will be fixed in the next 7.x release (see the attached PR #23535).

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