jaxrs-client-gen

generate JAX-RS resourec client java source files

License

License

Categories

Categories

CLI User Interface
GroupId

GroupId

io.github.yeagy
ArtifactId

ArtifactId

jaxrs-client-gen
Last Version

Last Version

0.2.2
Release Date

Release Date

Type

Type

jar
Description

Description

jaxrs-client-gen
generate JAX-RS resourec client java source files
Project URL

Project URL

https://github.com/yeagy/jaxrs-client-gen
Source Code Management

Source Code Management

https://github.com/yeagy/jaxrs-client-gen

Download jaxrs-client-gen

How to add to project

<!-- https://jarcasting.com/artifacts/io.github.yeagy/jaxrs-client-gen/ -->
<dependency>
    <groupId>io.github.yeagy</groupId>
    <artifactId>jaxrs-client-gen</artifactId>
    <version>0.2.2</version>
</dependency>
// https://jarcasting.com/artifacts/io.github.yeagy/jaxrs-client-gen/
implementation 'io.github.yeagy:jaxrs-client-gen:0.2.2'
// https://jarcasting.com/artifacts/io.github.yeagy/jaxrs-client-gen/
implementation ("io.github.yeagy:jaxrs-client-gen:0.2.2")
'io.github.yeagy:jaxrs-client-gen:jar:0.2.2'
<dependency org="io.github.yeagy" name="jaxrs-client-gen" rev="0.2.2">
  <artifact name="jaxrs-client-gen" type="jar" />
</dependency>
@Grapes(
@Grab(group='io.github.yeagy', module='jaxrs-client-gen', version='0.2.2')
)
libraryDependencies += "io.github.yeagy" % "jaxrs-client-gen" % "0.2.2"
[io.github.yeagy/jaxrs-client-gen "0.2.2"]

Dependencies

compile (3)

Group / Artifact Type Version
com.squareup : javapoet jar 1.7.0
javax.ws.rs : javax.ws.rs-api jar 2.0.1
args4j : args4j jar 2.33

test (1)

Group / Artifact Type Version
junit : junit jar 4.12

Project Modules

There are no modules declared in this project.

Build Status Maven Central Javadocs

jaxrs-client-gen

Generate JAX-RS resource client source files.

Handles both classes and interfaces with JAX-RS resource annotations. Class derived resources can generate both synchronous and asynchronous clients.

<dependency>
  <groupId>io.github.yeagy</groupId>
  <artifactId>jaxrs-client-gen</artifactId>
  <version>0.2.2</version>
</dependency>

#####Usage To use from the command line, use the *-capsule.jar, which is executable:

java -jar <capsule jar> [options] [<dir>|<filename>]+

The --async (-a) flag will generate asynchronous clients from resources.
The --parent-classpath (-pcp) option takes a semicolon separated list of dependencies your clients require
A directory will be created named 'jaxrs-client-gen' which will contain all the generated sources.

Here is an example that will generate sources from the test classes of this project:

java -jar build/libs/jaxrs-client-gen-0.2.2-capsule.jar build/classes/test

On UNIX like systems the jar is self-executing:

build/libs/jaxrs-client-gen-0.2.2-capsule.jar build/classes/test

Afterwards you can copy the generated sources into your source tree:

cp -r jaxrs-client-gen/* src/main/java/.

Known limitations

  • Sub-resources not supported.
  • Targets Java6, so parameter names cannot be known via reflection. This library will use the JAX-RS annotation values as parameter names instead. 95% of the time, it works every time.
  • This library is forgiving with a mismatch of the parameter name and the corresponding annotation value (which typically match). One notable exception: any field setters or constructor parameters annotated with @*Param types, the annotation value should match the name of the backing field or getter used to call the method. This is a Java6 limitation. Note: annotating the backing field directly allows label mismatch.
class MyBeanParam{
    private String example;
    
    @QueryParam("anything")
    private String something;
    
    //any annotation value other than "example" would fail in this case.
    public MyBeanParam(@QueryParam("example") String foo, String bar) {
        this.example = foo;
        this.something = bar;
    }
    
    public String getExample() { return example; }
    public String getSomething() { return something; }
}

Versions

Version
0.2.2
0.2.1
0.2.0
0.1.1
0.1.0