Client Maven Plugin

Generate java client of RESTful API.

License

License

Categories

Categories

Maven Build Tools CLI User Interface
GroupId

GroupId

com.bekioui.plugin
ArtifactId

ArtifactId

client-maven-plugin
Last Version

Last Version

1.0.1
Release Date

Release Date

Type

Type

maven-plugin
Description

Description

Client Maven Plugin
Generate java client of RESTful API.
Project URL

Project URL

https://github.com/MehdiBekioui/client-maven-plugin
Source Code Management

Source Code Management

https://github.com/MehdiBekioui/client-maven-plugin

Download client-maven-plugin

How to add to project

<plugin>
    <groupId>com.bekioui.plugin</groupId>
    <artifactId>client-maven-plugin</artifactId>
    <version>1.0.1</version>
</plugin>

Dependencies

compile (7)

Group / Artifact Type Version
org.apache.maven : maven-plugin-api jar 3.3.9
org.apache.maven : maven-artifact jar 3.3.9
org.apache.maven : maven-project jar 2.2.1
org.apache.maven : maven-model jar 3.3.9
org.apache.maven : maven-core jar 3.3.9
com.squareup : javapoet jar 1.5.1
com.google.auto.value : auto-value jar 1.1

provided (1)

Group / Artifact Type Version
org.apache.maven.plugin-tools : maven-plugin-annotations jar 3.4

Project Modules

There are no modules declared in this project.

Client Maven Plugin

Basically, when you are developing RESTful APIs, you could need to provide a java client for some java programs. You could need to call some of yours RESTful APIs too (in particular with microservices architecture). Writing a java client is redundant. This plugin generates it for you. It's based on your RESTful service resources.

Using context

This plugin works with this specific flow:

  • Create a pom maven project with maven modules (for example: one for your API and another one for your implementation)
  • Develop your API
  • Declare the plugin in your pom parent
  • Run the plugin to generate your client module
  • Build your project with maven and use your client

Plugin declaration

<build>
  <plugins>
    <plugin>
      <groupId>com.bekioui.plugin</groupId>
      <artifactId>client-maven-plugin</artifactId>
	  <version>1.0.1</version>
	  <configuration>
	    <apiUrl>http://localhost:8080</apiUrl>
	    <apiArtifactId>rest-api</apiArtifactId>
	    <clientArtifactId>rest-client</clientArtifactId>
	    <clientPrefix>Rest</clientPrefix>
	    <resourcePackageName>com.rest.api.resource</resourcePackageName>
	  </configuration>
    </plugin>
  </plugins>
</build>

Goal

  • client:generate: generate the java client or your RESTful API

Configuration

Property Required
apiUrl true
apiArtifactId true
clientArtifactId true
clientPrefix false default: empty string
resourcePackageName true

How to use your client in a project

Add the following to your Maven configuration:

<dependency>
	<groupId>com.rest</groupId>
	<artifactId>rest-client</artifactId>
	<version>1.0.0</version>
</dependency>

Add the following to your Spring configuration file:

@Configuration
@Import({ RestClientConfig.class })
public class SpringConfig {

}

Import the client in your class and use it:

@Component
public class MyClass {
	@Autowired
	private RestClient restClient;
}

License

Copyright (C) 2016 Mehdi Bekioui ([email protected])

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

	http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.	

Versions

Version
1.0.1
1.0.0