Build and Develop¶
This chapter describes the internal structures of tsgen for development purpose. Also the build / release process and how to contribute to tsgen.
Build & Release¶
Build tsgen¶
To build tsgen you only need a JDK 8+ compatible environment on your machine, e.g.:
- AdoptOpenJDK – Available on https://adoptopenjdk.net
- Amazon Correto – Available on https://aws.amazon.com/corretto
- Azul OpenJDK 8+ – Available on https://www.azul.com/downloads/zulu
- IcedTea 3.8+ – Available on https://icedtea.classpath.org
- Oracle JDK 8+ – Available on https://java.com
- SapMachine – Available on https://sap.github.io/SapMachine
Tools like SdkMan are recommended for switching between various JDK versions.
Since version 0.5.0 the final releases have been built with IcdedTea.
Building on Linux¶
To build this project execute the following command:
$ ./gradlew build
Starting a Gradle Daemon, 1 incompatible and 1 stopped Daemons could not be reused, use --status for details
Deprecated Gradle features were used in this build, making it incompatible with Gradle 5.0.
See https://docs.gradle.org/4.8/userguide/command_line_interface.html#sec:command_line_warnings
BUILD SUCCESSFUL in 14s
18 actionable tasks: 10 executed, 8 up-to-date
Development¶
Structures¶
- tsgen is an annotation processor, therefore it applies to an
- implicit contract between the compiler and the processor. It only extracts the type information, mainly from the sources. Remember: some types are erased, especially on the classes
It processes the Java sources in the following stages:
- The annotation processor
TsGenProcessor
is started by the compiler. It Analyzes only classes, that are annotated by the types from thedz.jtsgen.annotations
package.- Before any Java conversion is processed, the a configuration structure is built by combining the command line arguments for the compiler and the information added to the
TSModule
annotation- After the configuration has been determined, the name space mappings are resolved.
- The processor converts the Java types to an internal, AST like, structure for the render. There are multiple converters involved in this stage
- It generates TypeScript code into the sources folder, which might be changed in the near future
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 | /*
* Copyright (c) 2017 Dragan Zuvic
*
* This file is part of jtsgen.
*
* jtsgen is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* jtsgen is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with jtsgen. If not, see http://www.gnu.org/licenses/
*
*/
package dz.jtsgen.processor.model;
import dz.jtsgen.processor.model.rendering.TSTypeElement;
import org.immutables.value.Value;
import javax.lang.model.element.Element;
import java.util.List;
import java.util.Optional;
import static dz.jtsgen.processor.util.StringUtils.lastOf;
import static dz.jtsgen.processor.util.StringUtils.untill;
/**
* This type contains all information about a converted type
*/
public abstract class TSType implements TSTypeElement {
@Value.Default
public String getNamespace() {
return untill(this.getElement().toString());
}
@Value.Default
public String getName() {
return lastOf(this.getElement().toString());
}
public abstract List<TSMember> getMembers();
public abstract List<TSConstant> getConstants();
public abstract Optional<String> getDocumentString();
public abstract List<TSType> getSuperTypes();
public abstract List<TSTypeVariable> getTypeParams();
@Value.Parameter
public abstract Element getElement();
public abstract String getKeyword();
public abstract TSType changedNamespace(String namespace, List<TSMember> members, List<TSMethod> methods, List<TSConstant> mappedConstants);
public abstract List<TSMethod> getMethods();
}
|