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

Classpath is too long 206 error #1125

Closed
Enigamitsuj opened this issue Oct 23, 2017 · 6 comments
Closed

Classpath is too long 206 error #1125

Enigamitsuj opened this issue Oct 23, 2017 · 6 comments

Comments

@Enigamitsuj
Copy link

Enigamitsuj commented Oct 23, 2017

When running Junit5 on our huge project we are getting our classpath to the size of 35.8k when Windows (unfortunately) supports 32k only. I'm not sure how JUnit4 tests are handled in Gradle but it all works fine.

This is how its done in the plugin and it seems to do what it says but it creates a massive classpath and we are using Windows, sadly.

classpath = project.sourceSets.test.runtimeClasspath + project.configurations.junitPlatform

Is there any way we can work around this issue? it seems to pull the whole world into the classpath with all transitives.

  • Exception is:
    org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':server:junitPlatformTest'.

Caused by: org.gradle.process.internal.ExecException: A problem occurred starting process 'command 'C:\Program Files\Java\jdk1.8.0_131\bin\java.exe''
...
Caused by: java.io.IOException: CreateProcess error=206, The filename or extension is too long

I Have created stack overflow question as well for this.
https://stackoverflow.com/questions/46827241/junit5-gradle-plugin-the-filename-or-extension-is-too-long

@marcphilipp
Copy link
Member

@krystiankk Can you please try using this plugin and let us know if it solves the issue? https://github.com/viswaramamoorthy/gradle-util-plugins

@marcphilipp marcphilipp added this to the 5.1 Backlog milestone Oct 29, 2017
@Enigamitsuj
Copy link
Author

Enigamitsuj commented Oct 30, 2017

@marcphilipp I did fix it doing below, but then I found this classpath plugin and yes it works just fine.
Thank you.

I did post it on Stack as well https://stackoverflow.com/questions/46827241/junit5-gradle-plugin-the-filename-or-extension-is-too-long

    def version = "5.0.1" 
    def platformVersion = "1.0.1"
    def vintageVersion = "4.12.1"
    def projectCp = "${project.name}Classpath.jar"

    dependencies {

    compile "org.junit.jupiter:junit-jupiter-api:$version"
    compile "org.junit.platform:junit-platform-launcher:$platformVersion"
    compile "org.junit.platform:junit-platform-runner:$platformVersion"

    testCompile "junit:junit:4.12"

    testCompile "org.junit.jupiter:junit-jupiter-params:$version"

    testRuntime "org.junit.vintage:junit-vintage-engine:$vintageVersion"
    testRuntime "org.junit.platform:junit-platform-console:$platformVersion"
    testRuntime "org.junit.jupiter:junit-jupiter-engine:$version"
    }

    afterEvaluate {
    if (!project.tasks.findByName('packClasspath')) {
        task packClasspath(type: Jar) {
            archiveName = projectCp
            version = ''
            manifest {
                attributes 'Class-Path':
                project.configurations.testRuntime.collect { "file:///${it.absolutePath}" }.join(' ')}

            }
        }

        if (!project.tasks.findByName('jupiterTest')) {
            task jupiterTest(type: JavaExec) {
                jvmArgs '-ea'
                classpath = files(
                    "${project.buildDir}\\libs\\${projectCp}",
                    project.sourceSets.test.output,
                    project.sourceSets.main.output,
                )

                main 'org.junit.platform.console.ConsoleLauncher'
                args '--scan-class-path'
                args "--reports-dir=$project.testReportDir"
            }
        }

        test.dependsOn jupiterTest
        jupiterTest.dependsOn packClasspath
        jupiterTest.dependsOn testClasses

        test.enabled = false

    }

@marcphilipp
Copy link
Member

Thanks for letting us know!

@junit-team/junit-lambda Do you think we should build such a "manifest JAR" by default in our Gradle plugin?

@Enigamitsuj
Copy link
Author

No problem! I'm glad I could help.

Ps. I am wondering how does Gradle natively run JUnit4 tests that those work with long classpaths atm?

@marcphilipp
Copy link
Member

I'm not sure, they're bound to be doing something similar.

@marcphilipp
Copy link
Member

Since Gradle now provides native support for running tests on the JUnit Platform, the classpath length should no longer be an issue. We've decided to deprecate our custom plugin (see #1317 for details) and not add any new features to it. Thus, I'm closing this issue.

@marcphilipp marcphilipp removed this from the 5.2 Backlog milestone Mar 16, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants