Skip to content

[BUG] [GRADLE PLUGIN] openapi gradle project generates main.java.srcDirs = ['src/main\java'] which fails build on windows #7434

@simplyaduck

Description

@simplyaduck

Bug Report Checklist

  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator (example)?
  • Have you tested with the latest master to confirm the issue still exists? on 5.0.0-beta2
  • Have you searched for related issues/PRs?
  • What's the actual output vs expected output?
  • [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description

The project using openapi is used to automatically generate the client REST API code as an inner gradle project. the generated build.gradle generates the sourcesets as:

sourceSets {
    main.java.srcDirs = ['src/main\java']
}

When building from Windows, this causing the build to fail with

startup failed:
build file 'C:\dev\cloudmanagement-currency\currency-api-spec\generated\client\build.gradle': 23: unexpected char: '' @ line 23, column 35.
main.java.srcDirs = ['src/main\java']

The only way to fix would be to manually modify this file and build again, or to go back a version.

Expected output:

sourceSets {
    main.java.srcDirs = ['src/main/java']
}
openapi-generator version

"org.openapi.generator" version "4.3.1" workaround to use "org.openapi.generator" version "4.3.0"

OpenAPI declaration file content or url

Content of yaml is irrelevant to the issue

Generation Details

Java based Gradle project run with openapi-generator to create REST service

build.gradle:

task generateJavaClientProject (type: org.openapitools.generator.gradle.plugin.tasks.GenerateTask) {
	inputs.file("src/main/yaml/example-service.yaml")
	outputs.dir(file("generated/client"))
	
    generatorName = "java"
    inputSpec = file("src/main/yaml/example-service.yaml").toString()
    outputDir = file("generated/client").toString()
    apiPackage = "com.example.rest.client"
    invokerPackage = "com.example.rest.invoker"
    modelPackage = "com.example.rest.model"
    configOptions = [
        dateLibrary: "java8"
    ]
}
/**
 * Invoke a "gradlew build" on the generated client project
 */
task buildJavaClientProject(type: GradleBuild) {
	inputs.dir 'generated/client/src'
	outputs.dir 'generated/client/build'
	
	dependsOn 'generateJavaClientProject'
	buildFile = 'generated/client/build.gradle'
	tasks = ['build']	
}
Steps to reproduce

run gradlew build from command line on a windows machine with the above in the configuration files

Related issues/PRs

could not find any related issues

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions