-
Notifications
You must be signed in to change notification settings - Fork 237
Class Names Glob Patterns
Typescript-generator input classes can be specified using classPatterns
parameter which is a list of glob patterns.
Any class whose name matches any of the specified patterns will be included unless it is explicitly excluded.
This parameter can be combined with other input parameters (classes
and classesFromJaxrsApplication
).
Note: class dependencies will be also included even if they do not match any pattern (for example if class
A
has a propery of typeB
thenB
will be also included regardless of its name). This transitive mechanism applies to all input parameters.
Classes can be excluded one by one by using excludeClasses
parameter. It is also possible to exclude multiple classes at once by using excludeClassPatterns
parameter.
Class name glob patterns support two wildcards.
- Single
*
wildcard matches any character except for.
and$
. - Double
**
wildcard matches any character.
-
cz.habarta.example.*
- pattern for classes incz.habarta.example
package -
cz.habarta.example.**
- pattern for classes incz.habarta.example
package and all sub-packages -
cz.habarta.**Json
- pattern for classes ending withJson
suffix -
**.dto.*
- pattern for classes in anydto
package -
**$Companion
- pattern useful for excluding Kotlin companion objects
<plugin>
<groupId>cz.habarta.typescript-generator</groupId>
<artifactId>typescript-generator-maven-plugin</artifactId>
<version>1.7.x</version>
<executions>
<execution>
<id>generate</id>
<goals>
<goal>generate</goal>
</goals>
<phase>process-classes</phase>
<configuration>
<jsonLibrary>jackson2</jsonLibrary>
<classPatterns>
<pattern>cz.habarta.example.*</pattern>
<pattern>cz.habarta.example.data.**</pattern>
<pattern>cz.habarta.example.rest.*</pattern>
</classPatterns>
<excludeClasses>
<class>cz.habarta.example.Application</class>
</excludeClasses>
<outputFile>target/rest.d.ts</outputFile>
<outputKind>global</outputKind>
</configuration>
</execution>
</executions>
</plugin>
If you have JAX-RS Application it is recommended to specify input classes using classesFromJaxrsApplication
parameter instead of using globbing.
For more information see JAX RS Application.
Tip: as mentioned before classes are included transitively. But sometimes whole chain of classes is discovered unintentionally so it is practical to use
excludeClasses
parameter to exclude root of this chain or tree. For example if classA
which is explicitly included has a property of typeB
, classB
hasC
and classC
hasD
it is sufficient to exclude classB
to excludeB
,C
andD
and process classA
only.