How to use raml-to-jaxrs in maven


#1

I am trying to generate my klient java api from raml file with the maven plugin raml-to-jaxrs-maven-plugin.

I have tried to use example for maven in https://github.com/mulesoft-labs/raml-for-jax-rs/tree/master/raml-to-jaxrs/examples/maven-examples.

When I run mvn raml:generate on my project all java files get in the <my rest api maven module>\target\generated-sources\raml-to-jaxrs-maven-plugin\se<mydomain><myproduct><my restapi raml filename> in 3 folder model, resources and support

My goal is to compile this java files and put the class files them into a jar file to use by another maven module in the project.

I don’t understand why the maven plugin put the generated source files in the target structure.

I compair it with the cxf-codegen-plugin for ws that have a <sourceRoot>${basedir}/src/main/java</sourceRoot> tag that generate source and build it to class and package it in a jar file.

Can anyone help me to setup a maven build that generate jar file with the generated classes?

Part of my maven file
<properties>
<raml-to-jaxrs-maven-plugin.version>3.0.3</raml-to-jaxrs-maven-plugin.version>
</properties>

<build>
<plugins>
<plugin>
<groupId>org.raml.jaxrs</groupId>
<artifactId>raml-to-jaxrs-maven-plugin</artifactId>
<version>{raml-to-jaxrs-maven-plugin.version}</version>; <configuration> <ramlFile> {project.build.resources[0].directory}/rest/consume//
</ramlFile>
<resourcePackage>.resources
</resourcePackage>
<modelPackage>.model</modelPackage>
<supportPackage>.support
</supportPackage>
<generateTypesWith>

<value>jackson2</value>
<value>jsr303</value>
<value>equalsAndHashCode</value>
</generateTypesWith>
</configuration>
<dependencies>
<dependency>
<groupId>org.raml.jaxrs</groupId>
<artifactId>jaxrs-code-generator</artifactId>
<version>${raml-to-jaxrs-maven-plugin.version}</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>


#2

If i run “mvn clean install” i get the raml and json files package in the jar file. The folder generated-sources is not included. It still generated under target folder.