Skip to content

Default classpath filtering from #49 unintentionally filters user (cwd) class path due to 2 little bugs (on Windows) #57

@reinholdfuereder

Description

@reinholdfuereder

This leads to the fact that the gradle plug-in under test (not being in gradle cache yet, because it is just being built and tested) is not in the classpath of the nebula test of the plug-in...

Current code in GradleRunner:

    static final Predicate<URL> CLASSPATH_USER_DIR = new Predicate<URL>() {
        @Override
        boolean apply(URL url) {
            File userDir = new File(StandardSystemProperty.USER_DIR.value())
            return url.path.startsWith(userDir.path)
        }
    }

Debug logs show the problem right away:

url: file:/D:/workspaces/testautomation/buildsystem/gradle/???/plugins/artifactory/build/classes/test/
userDir: D:\workspaces\testautomation\buildsystem\gradle\???\plugins\artifactory
userDir.path: D:\workspaces\testautomation\buildsystem\gradle\???\plugins\artifactory
url.path: /D:/workspaces/testautomation/buildsystem/gradle/???/plugins/artifactory/build/classes/test/

Thus, it does not work on Windows, because of:

  • the leading '/' in url.path
  • '/' vs. ''

(It seems to be okay on Mac.)

The solution seems to be changing the return statement check of the GradleRunner.CLASSPATH_USER_DIR predicate like this for example:

    static final Predicate<URL> CLASSPATH_USER_DIR = new Predicate<URL>() {
        @Override
        boolean apply(URL url) {
            File userDir = new File(StandardSystemProperty.USER_DIR.value())
            return url.path.substring(1).startsWith(userDir.path.replace('\\', '/'))
            // Or:
            //return url.path.contains(userDir.path.replace('\\', '/'))
        }
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions