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

Configuration of inputFile via command line flags is not working #156

Open
astuetz opened this issue Jun 30, 2022 · 1 comment
Open

Configuration of inputFile via command line flags is not working #156

astuetz opened this issue Jun 30, 2022 · 1 comment

Comments

@astuetz
Copy link

astuetz commented Jun 30, 2022

I'm trying to specify the inputFile via command line options, as described inside the readme:

./gradlew generateSwagger --inputFile=./specs.json

but this fails with

Option 'inputFile' cannot be cast to type 'java.io.File' in class 'com.yelp.codegen.plugin.GenerateTask'.

I tried many different options of specifying the inputFile parameter, without any success.

After playing around with some custom task and @InputFile / @Option myself, it seems like it would only work if the type is a String (and not a RegularFileProperty). This would be in line with what the Gradle documentation about Option is saying:

https://docs.gradle.org/current/javadoc/org/gradle/api/tasks/options/Option.html

An option may have one of the following types:

  • boolean
  • Boolean
  • Property<Boolean>
  • an enum type
  • Property<T> of an enum type
  • String
  • Property<String>
  • List<T> of an enum type
  • List<String>

I didn't try any other properties, but maybe outputDir could also make problems, as it's a DirectoryProperty.

Plugin version: 1.4.1

@cortinico
Copy link
Collaborator

Thanks for reporting this @astuetz. You're right in the sense that this is broken. I think we should go for something like:

    @get:Input
    @get:Optional
    @get:Option(option = "inputPath", description = "Configures path of the Swagger Spec.")
    abstract val inputPath: Property<String>
    
    @get:InputFile
    abstract val inputFile: RegularFileProperty

And check which of the two is present, giving priority to inputPath and falling back to inputFile. The outputDir is also affected by this.

Happy to review a PR that fixes this 👍

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

No branches or pull requests

2 participants