To use the plugin in maven you need to follow these steps:
0.1) build using maven
mvn install -DskipTests
1) Add the following plugin repository to your pom.xml
TODO: publish this plugin to a repository. In the mean time you should just clone down this repo and build/deploy the plugin to your own maven repository.
<pluginRepository> <id>typescript-maven-plugin</id> <url>https://raw.github.com/ppedregal/typescript-maven-plugin/master/repo</url> </pluginRepository>
- There are two ways of using the plugin. The old way where you specify all of the compiler options in the plugin, and the new way where you just point the plugin at an
tsconfig.json
file.
2.1) To use the old way add the following build plugin to your pom.xml
. The options are directly derived from the compiler's command line options:
<plugin> <groupId>com.simonzone.typescript</groupId> <artifactId>typescript-maven-plugin</artifactId> <configuration> <sourceDirectory>src/main/ts</sourceDirectory> <targetDirectory>target/ts</targetDirectory> <!-- Replace targetDirectory with 'out' to compile everything into one --> <!-- file. 'out' should contain the name of the outout .js file. --> <!-- 'amd' or 'commonjs' --> <module>amd</module> <!-- Defaults to false --> <noStandardLib>false</noStandardLib> <!-- 'ES3' or 'ES5'. Defaults to ES3 --> <targetVersion>ES5</targetVersion> <!-- true or false. Defaults to false --> <removeComments>false</removeComments> <!-- true or false. Defaults to false --> <noImplicitAny>false</noImplicitAny> <!-- true or false. Defaults to false --> <declaration>false</declaration> <!-- true or false. Defaults to false --> <sourceMap>false</sourceMap> <!-- (Optional) Source root path. --> <sourceRoot>...</sourceRoot> <!-- (Optional) Map root path. --> <mapRoot>...</mapRoot> </configuration> <executions> <execution> <phase>compile</phase> <goals> <goal>tsc<goal> </goals> </execution> </executions> </plugin>
2.2) This is the new way which uses tsconfig.json
. In the configuration you just need to omit everything except for a project
tag. The contents of this tag must be the name of the directory containing your tsconfig.json
file. Most of the time you will want to put your tsconfig.json
file in the same directory as the pom.xml
itself. In this case use a .
to indicate the current project directory.
<plugin> <groupId>com.simonzone.typescript</groupId> <artifactId>typescript-maven-plugin</artifactId> <configuration> <project>.</project> </configuration> <executions> <execution> <phase>compile</phase> <goals> <goal>tsc<goal> </goals> </execution> </executions> </plugin>