Configuration for generating raml using maven plugin


#1

Hi,

I am trying to generate raml from java files using raml maven plugin.

For this i have done configuration in pom.xml of my project.

Though i am able to generate raml files, i am facing problem with below things :

1. How to specify complete package, so that raml is generated for all the classes in that package.
So from the below configuration you can see that i have specified sourcePaths, in order to include multiple classes i am able to do this by adding multiple source path.
This approach is not an efficient approach, it would be good if i can include complete package here and all the classes under it are picked.

2. For above need individual raml files for each class.
Again in the below configuration i have specified an outputFile. This is a single file that presently contains all the web api calls generated from all the classes included in source path. How can i configure multiple output files on the basis of classes.

3. How and where to specify base uri - presently it is displaying base uri as http://example.com


Please find below configuration done in pom.xml for raml

<plugin>
			    <groupId>org.raml.plugins</groupId>
			    <artifactId>jaxrs-raml-maven-plugin</artifactId>
			    <version>1.3.3</version>
			    <configuration>
			        <sourcePaths>
			            <param>${basedir}/src/main/java/com/x/y/server/web/service/MyLoginService.java</param>
			        </sourcePaths>
			        <sourceDirectory>${basedir}/src/main/java</sourceDirectory>
			        <outputFile>${project.build.directory}/generated-sources/jaxrs-raml/myprojectWebServicesRaml.raml</outputFile>
			        <removeOldOutput>false</removeOldOutput>
			    </configuration>
			    <executions>
			        <execution>
			            <goals>
			                <goal>generate-raml</goal>
			            </goals>
			            <phase>process-classes</phase>
			        </execution>
			    </executions>
			</plugin>

and

<pluginManagement>
		    <plugins>
		        <plugin>
		            <groupId>org.eclipse.m2e</groupId>
		            <artifactId>lifecycle-mapping</artifactId>
		            <version>1.0.0</version>
		            <configuration>
		                <lifecycleMappingMetadata>
		                    <pluginExecutions>
		                        <pluginExecutionFilter>
		                            <groupId>org.raml.plugins</groupId>
		                            <artifactId>jaxrs-raml-maven-plugin</artifactId>
		                            <version>1.3.3</version>
		                            <goals>
		                                <goal>generate-raml</goal>
		                            </goals>
		                        </pluginExecutionFilter>
		                        <action>
		                            <execute>
		                                <runOnIncremental>false</runOnIncremental>
		                            </execute>
		                        </action>
		                    </pluginExecutions>
		                </lifecycleMappingMetadata>
		            </configuration>
		        </plugin>
		    </plugins>
		</pluginManagement>

#2

I can answer question 3. In your maven pom.xml within your tag for the plugin, add the tag

<baseUrl>https://my.site.com/api</baseUrl>

<configuration>
    <sourcePaths>
      <param>${basedir}/src/main/java/com/x/y/server/web/service/MyLoginService.java</param>
   </sourcePaths>
   <sourceDirectory>${basedir}/src/main/java</sourceDirectory>
   <outputFile>${project.build.directory}/generated-sources/jaxrs-raml/myprojectWebServicesRaml.raml</outputFile>
   <removeOldOutput>false</removeOldOutput>
   <baseUrl>https://my.site.com/api</baseUrl>
</configuration>

I am not using the lifecycle-mapping plugin, but this worked for me and I expect it should work for you.