vietj / vertx-codegen-cli

A cli for Vert.x Codegen
5 stars 3 forks source link

Cli issues #1

Open mozinrat opened 9 years ago

mozinrat commented 9 years ago

While trying to use the cli as , I got below error

java -jar vertx-codegen-cli-3.2.0-SNAPSHOT.jar --codegen codegen.json --target generated io.vertx:vertx-core:3.2.0-SNAPSHOT SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder". SLF4J: Defaulting to no-operation (NOP) logger implementation SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details. Exception in thread "main" java.lang.NullPointerException at io.vertx.codegen.cli.Main.run(Main.java:185) at io.vertx.codegen.cli.Main.main(Main.java:64)

I edit line 185 with addURL.invoke(classLoader, codegenFile.toURI().toURL()); to make it work but it generate only ascii doc and databojects doc.

I tried to use below codegen.json

{ "name": "java", "generators": [ { "kind": "class", "fileName": "'src/main/java/Application.java'", "templateFileName": "vertx-groovy/template/java.templ" } ] }

as well as

{ "name": "Groovy", "generators": [ { "kind": "class", "fileName": "'groovy/' + fqn.replace('io.vertx', 'io.vertx.groovy').replace('.', '/') + '.groovy'", "templateFileName": "vertx-groovy/template/groovy.templ" } ] } This is from vertex-codegen git page.

Can you please help me out with how to use it. Also I didn't get the rationale for providing io.vertx:vertx-core:3.2.0-SNAPSHOT after generated folder while trying to run this.

The basic goal is to create different hello world application generator for vertx-web/ vertx-rx/vertx-esb.

vietj commented 9 years ago

1/ you need to pass the Maven coordinates of the project to code translate, so if you pass io.vertx:vertx-core:3.2.0-SNAPSHOT as argument it generates the api shim for vertx-core, you can also use io.vertx:vertx-web:3.2.0-SNAPSHOT to generate the vertx-web shim.

2/ you need to pass the code generator codegen.json config, there are several existing at the moment: javascript, groovy, ruby, etc... all are projects in the vert-x3 github organization, for instance https://github.com/vert-x3/vertx-lang-js/blob/master/src/main/resources/codegen.json

2/ you said you edited line 185 to make it work, what did you change ?

4/ it is not clear what you want to use it for, can you describe the hello world application generator use case ? i.e it does not seem to fit the codegen use case

oneto018 commented 9 years ago

I too got the nullpointer exeption with following message. "Exception in thread "main" java.lang.NullPointerException at io.vertx.codegen.cli.Main.run(Main.java:185) at io.vertx.codegen.cli.Main.main(Main.java:64)"

Fix mentioned by mozinrat supressed the error. But nothing got generated after that. I am just trying to understand the syntax for templating. I couldn't get it working. A simple starter project with really simple generator code would be fine

oneto018 commented 9 years ago

I might have found the reason and fix for the issue. Its just at line 185 , you are trying to get parent path using getParentFile() method. Its returns null. So if I put codegen.json and template file inside a folder and run jar from outside , it works and generates the file

vietj commented 9 years ago

why does it return null ?

yes I will come with a clonable base codege project soon.

vietj commented 9 years ago

here it is : https://github.com/vietj/vertx-codegen-starter