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

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

Closed
4 of 6 tasks
simplyaduck opened this issue Sep 16, 2020 · 5 comments · Fixed by #7487
Assignees
Milestone

Comments

@simplyaduck
Copy link

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

@wing328
Copy link
Member

wing328 commented Sep 17, 2020

cc @jimschubert

@jimschubert
Copy link
Member

This is an issue in Java generator which should be fixed as of a few weeks ago. Can you try 5.0.0-beta2?

@simplyaduck
Copy link
Author

I have tried 5.0.0-beta2 and the issue still exists

@black-snow
Copy link

5.0.0-beta2 issue remains

@jimschubert jimschubert self-assigned this Sep 22, 2020
@jimschubert jimschubert added this to the 5.0.0 milestone Sep 22, 2020
@jimschubert
Copy link
Member

jimschubert commented Sep 22, 2020

I'll try and look tonight. I thought I'd changed everything in those generators, but maybe I missed some.

The issue is that we're using file separator in path constructs, when that's not a safe assumption in all cases. In some locations, we're doing things like "src/main" +File.separator. which causes the above behavior.

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

Successfully merging a pull request may close this issue.

4 participants