mulesoft-labs / raml-java-client-generator

Raml Java Client Generator
Apache License 2.0
34 stars 34 forks source link

Unable to run generate-client goal with arguments #15

Closed stevelyall closed 6 years ago

stevelyall commented 6 years ago

Hi there- thanks for your plugin, appreciate your work on it!

I'm running into an issue with the basePackage argument when trying to generate classes with Maven on the command line:

mvn raml-client-generator-maven-plugin:generate-client -DbasePackage=com.example.mypackage
[ERROR] Failed to execute goal org.mule.raml.codegen:raml-client-generator-maven-plugin:0.1.1:generate-client (default-cli) on project integration-services: The parameters 'basePackage' for goal org.mule.raml.codegen:raml-client-generator-maven-plugin:0.1.1:generate-client are missing or invalid -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.mule.raml.codegen:raml-client-generator-maven-plugin:0.1.1:generate-client (default-cli) on project integration-services: The parameters 'basePackage' for goal org.mule.raml.codegen:raml-client-generator-maven-plugin:0.1.1:generate-client are missing or invalid
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:213)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:154)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:146)
        at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:117)
        at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:81)
        at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
        at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:309)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:194)
        at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:107)
        at org.apache.maven.cli.MavenCli.execute(MavenCli.java:993)
        at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:345)
        at org.apache.maven.cli.MavenCli.main(MavenCli.java:191)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
        at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
        at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
Caused by: org.apache.maven.plugin.PluginParameterException: The parameters 'basePackage' for goal org.mule.raml.codegen:raml-client-generator-maven-plugin:0.1.1:generate-client are missing or invalid
        at org.apache.maven.plugin.internal.DefaultMavenPluginManager.populatePluginFields(DefaultMavenPluginManager.java:643)
        at org.apache.maven.plugin.internal.DefaultMavenPluginManager.getConfiguredMojo(DefaultMavenPluginManager.java:596)
        at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:121)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
        ... 20 more

I may be missing something, though can't seem to find the correct usage of the plugin documented anywhere?

Is this still being maintained? If so I'd like to learn more or help resolve an issue if there is one!

Thanks and all the best!

rscadrde commented 6 years ago

The @Parameter annotation in RamlJavaClientGeneratorMojo.java does not provide a property attribute.

Workaround is to configure the plugin in your pom.xml with a self defined maven property and run it:

I did so for

            <plugins>
                <plugin>
                    <groupId>org.mule.raml.codegen</groupId>
                    <artifactId>raml-client-generator-maven-plugin</artifactId>
                    <version>0.1.1</version>
                    <configuration>
                        <outputDir>src/test/java</outputDir>
                        <basePackage>com.canda.x.generated</basePackage>
                        <ramlURL>${generator.ramlURL}</ramlURL>
                    </configuration>
                </plugin>
            </plugins>

and

-Dgenerator.ramlURL=file:///C:/..... works then.

rscadrde commented 6 years ago

With version 0.2 you can use -DRamlJavaClientGeneratorMojo.basePackage=com.example.mypackage with the command line.

stevelyall commented 6 years ago

Awesome, thank you!!