Talend Validation Toolkit is a static code analysis tool to motivate Talend developers to design Talend Projects that adheres to a coding standard. It automates the process of checking Talend components for validation rules and spare humans from this boring (but important) task. Talend Validation Toolkit ideal for Talend projects that want to enforce coding standards.
Talend Validation Toolkit can be used for multiple purposes and methods such as;
- As a Java Library (module: talend-validation-util)
- As a Desktop application (module: talend-validation-tool)
- As a Maven Plugin for Talend Project (module: talend-validation-maven-plugin)
- TODO: As a Plugin for a Build Tool which configured for remote SVN Talend Project
import com.hjchanna.talend.TalendValidationUtil;
import com.hjchanna.talend.ValidationResponse;
...
File talendProjectRoot = new File("path/to/your/talend/project/");
TalendValidationUtil validationUtil = TalendValidationUtil.getInstance();
//validate the talend project
List<ValidationResponse> validationResponses = validationUtil.validateTalendProject(talendProjectRoot);
Please download an run the talend-validation-tool.jar
in the release section of this repository. The desktop application allows developers to locate Talend project clonned locally and validate them.
Add following plugin configuration to pom.xml
of the Talend Project.
<plugin>
<groupId>com.hjchanna.talend</groupId>
<artifactId>talend-validation-maven-plugin</artifactId>
<version>1.0</version>
<executions>
<execution>
<id>validate-talend</id>
<phase>validate</phase>
<goals>
<goal>validate-talend</goal>
</goals>
</execution>
</executions>
</plugin>
This feature is still in development stage.
- Java (JDK 1.7)
- Maven
Talend Validation Toolkit has serveral maven modules for the parent project. The project hierarchy as follows.
| talend-validation-toolkit
|----| talend-validation-util
|----| talend-validation-tool
|----| talend-validation-maven-plugin
talend-validation-util is the main artifact of the talend-validation-toolkit which consists of validation logics and validation configurations. Validation configurations are defined in json format in resource directory. Validation rules json template as follows;
{
"name": "Validation Rule Name",
"description":"Validation Rule Description",
"level": "WARN",
"fileLocations": [
"context" (folders to match files)
],
"includeSubDirectories": true,
"filePattern": "file pattern in regex format",
"validationType": "content/xml", (or filename)
"sourceXpath": "//contextParameter/@name", (if validationType is content/xml)
"assertionRegex": "value match pattern in regex"
}
{
"name": "Context Parameter Validation",
"description":"A context variable should be in Camel Case",
"level": "WARN",
"fileLocations": [
"context"
],
"includeSubDirectories": true,
"filePattern": ".*(.item)",
"validationType": "content/xml",
"sourceXpath": "//contextParameter/@name",
"assertionRegex": "[a-z][A-Za-z0-9]*"
}
Note: Once a validattion rule is defined as a JSON, it shoul add to the validators.json
file which is available in the resource directory.
There are only two validation rules are defined in this stage of the project which are;
- Context Parameter Validation (Rule: A context variable should be in Camel Case)
- Joblet Name Validation (Rule: A joblet name should be in Camel Case)
talend-validation-maven-plugin is a dependent project of talend-validation-util and it has packaged as a maven-plugin which enables to control the maven build. The plugin would be applied in verify
phase of a maven project in default.
Use following maven commands to build the project from the project root.
mvn clean install
- Channa Jayamuni ([email protected])