Skip to content

sedwards2009/typescript-maven-plugin

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

53 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TypeScript Maven Plugin

Maven plugin that integrates TypeScript compiler into maven builds. Supports v1.6.2 of the TypeScript compiler and can use automatically use the Rhino JavaScript engine if the `tsc` command is not available.

To use the plugin in maven you need to follow these steps:

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>
  1. 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>

About

TypeScript Maven Plugin

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 98.3%
  • Java 1.7%