Skip to content

Refaster style recipes cannot match types that require transitive dependencies to be loaded #86

@sambsnyd

Description

@sambsnyd

This parser:

JavaTemplate.builder("#{any(com.azure.cosmos.CosmosClientBuilder)}.endpoint(\"boo\").userAgentSuffix(\"test\").buildAsyncClient()")
                .javaParser(JavaParser.fromJavaVersion().classpath("azure-cosmos"))
                .build()

Cannot be used to match a method invocation of CosmosClientBuilder.buildAsyncClient() because the method its parser produces lacks type information. CosmosClientBuilder is defined within the jar "azure-cosmos", but also requires "azure-core" for the java compiler to type attribute it.

This is because JavaParser.fromJavaVersion().classpath() does not look up transitive dependencies of the named artifact, so "azure-core" is absent from the classpath.

This test can be used to reproduce the issue. Changing JavaParser.fromJavaVersion().classpath(JavaParser.fromRuntimeClasspath()) resolves this problem because the full runtime classpath has both "azure-cosmos" and "azure-core".

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions