Skip to content
This repository has been archived by the owner on Nov 23, 2024. It is now read-only.

Allow configuration of ExecTask jvm arguments #221

Closed
JamesGuthrie opened this issue Apr 16, 2021 · 3 comments · Fixed by #248
Closed

Allow configuration of ExecTask jvm arguments #221

JamesGuthrie opened this issue Apr 16, 2021 · 3 comments · Fixed by #248

Comments

@JamesGuthrie
Copy link

Describe the feature

I would like to be able to provide a jvmArgs parameter during the configuration which is passed into the underlying ExecTask.

An example of how this could look:

swaggerSources {
    myApi {
        inputFile = file("myApi.yaml")
        code {
            language = 'java'
        }
        jvmArgs = '--add-opens java.base/java.util=ALL-UNNAMED'
    }
}

Why do you want the feature?

The swagger generator currently does not run on jdk 16 because one of its dependencies performs illegal reflection. There is an issue open against that dependency jknack/handlebars.java#667. I suspect that it could take a while before anything moves there. In the meantime, it would be nice to be able to configure the jvm args to provide an add-opens argument.

@sne11ius
Copy link

sne11ius commented Dec 8, 2021

Hey @JamesGuthrie, I'm having the same problem. Did you happen to find any workaround?

@sne11ius
Copy link

sne11ius commented Dec 9, 2021

@JamesGuthrie I replaced swagger-codegen-cli with the current openapi-generator-cli in my build. I was lucky and didn't even have to change the configuration of the swaggerSources task. Looks like I finally have a working build with jdk 17.

Maybe this could also be an option for you...

@int128
Copy link
Owner

int128 commented Dec 18, 2021

I reproduced this error in 63fb0b8 as follows:

Exception in thread "Thread-0" java.lang.RuntimeException: Could not generate supporting file 'SupportingFile:
	templateFile: index.mustache
	folder: 
	destinationFilename: index.html
'
	at io.swagger.codegen.v3.DefaultGenerator.generateSupportingFiles(DefaultGenerator.java:663)
	at io.swagger.codegen.v3.DefaultGenerator.generate(DefaultGenerator.java:786)
	at io.swagger.codegen.v3.cli.cmd.Generate.run(Generate.java:388)
	at java.base/java.lang.Thread.run(Thread.java:833)
Caused by: com.github.jknack.handlebars.HandlebarsException: /handlebars/htmlDocs2/sample_java.mustache:1:10: java.lang.reflect.InaccessibleObjectException: Unable to make public boolean java.util.Collections$EmptyMap.isEmpty() accessible: module java.base does not "opens java.util" to unnamed module @5274766b
    /handlebars/htmlDocs2/sample_java.mustache:1:10
	at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:354)
	at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:297)
	at java.base/java.lang.reflect.Method.checkCanSetAccessible(Method.java:199)
	at java.base/java.lang.reflect.Method.setAccessible(Method.java:193)
	at com.github.jknack.handlebars.context.MemberValueResolver.cache(MemberValueResolver.java:82)
	at com.github.jknack.handlebars.context.MemberValueResolver.resolve(MemberValueResolver.java:54)
	at com.github.jknack.handlebars.Context$CompositeValueResolver.resolve(Context.java:199)
	at com.github.jknack.handlebars.internal.path.PropertyPath.eval(PropertyPath.java:52)
	at com.github.jknack.handlebars.Context$PathExpressionChain.next(Context.java:361)
	at com.github.jknack.handlebars.Context$PathExpressionChain.eval(Context.java:381)
	at com.github.jknack.handlebars.Context.get(Context.java:621)
	at com.github.jknack.handlebars.Context$PartialCtx.get(Context.java:165)
	at com.github.jknack.handlebars.internal.Variable.value(Variable.java:183)
	at com.github.jknack.handlebars.internal.Variable.merge(Variable.java:160)
	at com.github.jknack.handlebars.internal.BaseTemplate.apply(BaseTemplate.java:130)
	at com.github.jknack.handlebars.internal.TemplateList.merge(TemplateList.java:95)
	at com.github.jknack.handlebars.internal.BaseTemplate.apply(BaseTemplate.java:130)
	at com.github.jknack.handlebars.internal.ForwardingTemplate.apply(ForwardingTemplate.java:86)
	at com.github.jknack.handlebars.internal.Partial.merge(Partial.java:228)
	at com.github.jknack.handlebars.internal.BaseTemplate.apply(BaseTemplate.java:130)
	at com.github.jknack.handlebars.internal.TemplateList.merge(TemplateList.java:95)
	at com.github.jknack.handlebars.internal.BaseTemplate.apply(BaseTemplate.java:130)
	at com.github.jknack.handlebars.internal.BaseTemplate.apply(BaseTemplate.java:118)
	at com.github.jknack.handlebars.Options.apply(Options.java:538)
	at com.github.jknack.handlebars.Options.fn(Options.java:445)
	at com.github.jknack.handlebars.helper.WithHelper.apply(WithHelper.java:58)
	at com.github.jknack.handlebars.internal.Block.merge(Block.java:211)
	at com.github.jknack.handlebars.internal.BaseTemplate.apply(BaseTemplate.java:130)
	at com.github.jknack.handlebars.internal.TemplateList.merge(TemplateList.java:95)
	at com.github.jknack.handlebars.internal.BaseTemplate.apply(BaseTemplate.java:130)
	at com.github.jknack.handlebars.internal.BaseTemplate.apply(BaseTemplate.java:118)
	at com.github.jknack.handlebars.Options.apply(Options.java:538)
	at com.github.jknack.handlebars.helper.EachHelper.apply(EachHelper.java:73)
	at com.github.jknack.handlebars.internal.Block.merge(Block.java:211)
	at com.github.jknack.handlebars.internal.BaseTemplate.apply(BaseTemplate.java:130)
	at com.github.jknack.handlebars.internal.TemplateList.merge(TemplateList.java:95)
	at com.github.jknack.handlebars.internal.BaseTemplate.apply(BaseTemplate.java:130)
	at com.github.jknack.handlebars.internal.BaseTemplate.apply(BaseTemplate.java:118)
	at com.github.jknack.handlebars.Options.apply(Options.java:538)
	at com.github.jknack.handlebars.helper.EachHelper.apply(EachHelper.java:73)
	at com.github.jknack.handlebars.internal.Block.merge(Block.java:211)
	at com.github.jknack.handlebars.internal.BaseTemplate.apply(BaseTemplate.java:130)
	at com.github.jknack.handlebars.internal.TemplateList.merge(TemplateList.java:95)
	at com.github.jknack.handlebars.internal.BaseTemplate.apply(BaseTemplate.java:130)
	at com.github.jknack.handlebars.internal.BaseTemplate.apply(BaseTemplate.java:118)
	at com.github.jknack.handlebars.Options.apply(Options.java:538)
	at com.github.jknack.handlebars.Options.fn(Options.java:445)
	at com.github.jknack.handlebars.helper.WithHelper.apply(WithHelper.java:58)
	at com.github.jknack.handlebars.internal.Block.merge(Block.java:211)
	at com.github.jknack.handlebars.internal.BaseTemplate.apply(BaseTemplate.java:130)
	at com.github.jknack.handlebars.internal.TemplateList.merge(TemplateList.java:95)
	at com.github.jknack.handlebars.internal.BaseTemplate.apply(BaseTemplate.java:130)
	at com.github.jknack.handlebars.internal.BaseTemplate.apply(BaseTemplate.java:118)
	at com.github.jknack.handlebars.Options.apply(Options.java:538)
	at com.github.jknack.handlebars.helper.EachHelper.apply(EachHelper.java:73)
	at com.github.jknack.handlebars.internal.Block.merge(Block.java:211)
	at com.github.jknack.handlebars.internal.BaseTemplate.apply(BaseTemplate.java:130)
	at com.github.jknack.handlebars.internal.TemplateList.merge(TemplateList.java:95)
	at com.github.jknack.handlebars.internal.BaseTemplate.apply(BaseTemplate.java:130)
	at com.github.jknack.handlebars.internal.BaseTemplate.apply(BaseTemplate.java:118)
	at com.github.jknack.handlebars.Options.apply(Options.java:538)
	at com.github.jknack.handlebars.Options.fn(Options.java:445)
	at com.github.jknack.handlebars.helper.WithHelper.apply(WithHelper.java:58)
	at com.github.jknack.handlebars.internal.Block.merge(Block.java:211)
	at com.github.jknack.handlebars.internal.BaseTemplate.apply(BaseTemplate.java:130)
	at com.github.jknack.handlebars.internal.TemplateList.merge(TemplateList.java:95)
	at com.github.jknack.handlebars.internal.BaseTemplate.apply(BaseTemplate.java:130)
	at com.github.jknack.handlebars.internal.BaseTemplate.apply(BaseTemplate.java:118)
	at com.github.jknack.handlebars.internal.ForwardingTemplate.apply(ForwardingTemplate.java:72)
	at io.swagger.codegen.v3.templates.HandlebarTemplateEngine.getRendered(HandlebarTemplateEngine.java:25)
	at io.swagger.codegen.v3.DefaultGenerator.generateSupportingFiles(DefaultGenerator.java:634)
	... 3 more
Caused by: java.lang.reflect.InaccessibleObjectException: Unable to make public boolean java.util.Collections$EmptyMap.isEmpty() accessible: module java.base does not "opens java.util" to unnamed module @5274766b
	... 74 more

Fixed by #248. Thank you for your contribution.

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

Successfully merging a pull request may close this issue.

3 participants