Customizing Generation

The output generated by jtsgen can be customized either by using the TSModule Annototaion and/or by command line Parameters. The latter is useful embedding data from the build process, e.g. the version number.

The most relevant customizations are done adding one TSModule Annotation at a package of your compilation unit.

The TSModule Annotation

Currently only one TSModule annotation is permitted in one compilation unit. The annotation must be put to a package Element, like this:

@TSModule(
        moduleName = "namespace_test",
        nameSpaceMapping = "jts.modules.nsmap -> easy"
)
package jts.modules.nsmap;

import dz.jtsgen.annotations.TSModule;

The following annotation parameters are supported:

  • moduleName: The module name of the JavaScript/TypeScript Module. This must be a java package friendly name.
  • author: The author number for the package.json file
  • authorUrl: The authorURL for the package.json file
  • version: The version number for the package.json file, default is “1.0.0”
  • license: The license for the package.json file
  • description: he description for the package.json file
  • customTypeMappings: Custom Type Mapping for the module, the default is {}
  • excludes: regular expression to exclude type conversion, default is: {"^sun", "^jdk.internal", "^java.lang.Comparable"}
  • nameSpaceMapping: The name space mapping, the default is {}
  • outputType: The type of the output. Default is OutputType.NAMESPACE_AMBIENT_TYPE
  • nameSpaceMappingStrategy: Defines how the default name space is calculated. Default is NameSpaceMappingStrategy.ALL_TO_ROOT (since 0.2.0)

Processing Parameters

with the following annotation processor parameters some of the settings made using the TSModule annotation can be overridden:

  • jtsgenLogLevel: enable additional logging. Use ine of the following j.u.Logging levels: ,`OFF` ,`SEVERE` ,`WARNING` ,`INFO` ,`CONFIG` ,`FINE` ,`FINER` ,`FINEST` ,`ALL`
  • jtsgenModuleName: the name of the module, that should be exported
  • jtsgenModuleVersion: the version number of the module
  • jtsgenModuleDescription: the description of the module
  • jtsgenModuleAuthor: the module author
  • jtsgenModuleLicense: the npm license string of the module
  • jtsgenModuleAuthorUr: the URL of the author

To use one of them, use the javac prefix -A, e.g.

javac -AjtsgenLogLevel=FINEST MyClass.java`