开源软件名称(OpenSource Name):lgrignon/jsweet-maven-plugin开源软件地址(OpenSource Url):https://github.com/lgrignon/jsweet-maven-plugin开源编程语言(OpenSource Language):Java 100.0%开源软件介绍(OpenSource Introduction):JSweet maven pluginUnleash the power of JSweet into your maven project Table of ContentsBasic ConfigurationAdd the JSweet's plugin repositories to your project's pom.xml: <pluginRepositories>
<pluginRepository>
<id>jsweet-plugins-release</id>
<name>plugins-release</name>
<url>http://repository.jsweet.org/artifactory/plugins-release-local</url>
</pluginRepository>
<pluginRepository>
<snapshots />
<id>jsweet-plugins-snapshots</id>
<name>plugins-snapshot</name>
<url>http://repository.jsweet.org/artifactory/plugins-snapshot-local</url>
</pluginRepository>
</pluginRepositories> Configure your pom's sourceDirectory, as usual: <build>
<sourceDirectory>src</sourceDirectory> Add your JSweet dependencies (candies): <dependencies>
<dependency>
<groupId>org.jsweet.candies</groupId>
<artifactId>angular</artifactId>
<version>1.4.1-SNAPSHOT</version>
</dependency> Enable the JSweet transpiler plugin for the preferred phase (here, generate-sources): <plugin>
<groupId>org.jsweet</groupId>
<artifactId>jsweet-maven-plugin</artifactId>
<version>3.0.0</version>
<configuration>
<outDir>javascript</outDir>
<targetVersion>ES6</targetVersion>
</configuration>
<executions>
<execution>
<id>generate-js</id>
<phase>generate-sources</phase>
<goals>
<goal>jsweet</goal>
</goals>
</execution>
</executions>
</plugin> The configuration options of the plugin:
Run JSweetThen, just run the maven command line as usual:
Hot transpilationJSweet maven plugin is now able to watch changes in your JSweet files and transpile them on the fly. Try it with
Advanced configurationYou can use the plugin with profiles in order to transpile differently several parts of your application. For instance, a node server and a HTML5 client app: <profiles>
<profile>
<id>client</id>
<build>
<plugins>
<plugin>
<groupId>org.jsweet</groupId>
<artifactId>jsweet-maven-plugin</artifactId>
<version>3.0.0</version>
<configuration>
<outFile>client/out.js</outFile>
<targetVersion>ES6</targetVersion>
<includes>
<include>**/*.java</include>
</includes>
<excludes>
<exclude>**/server/**</exclude>
</excludes>
</configuration>
<executions>
<execution>
<id>generate-js</id>
<phase>generate-sources</phase>
<goals>
<goal>jsweet</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>server</id>
<build>
<plugins>
<plugin>
<groupId>org.jsweet</groupId>
<artifactId>jsweet-maven-plugin</artifactId>
<version>3.0.0</version>
<configuration>
<outFile>server/full.js</outFile>
<module>commonjs</module>
<targetVersion>ES5</targetVersion>
<includes>
<include>**/*.java</include>
</includes>
<excludes>
<exclude>**/app/**</exclude>
</excludes>
</configuration>
<executions>
<execution>
<id>generate-js</id>
<phase>generate-sources</phase>
<goals>
<goal>jsweet</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles> then run the desired profile:
Use with code generators / preprocessorsWhen using some code generators/preprocessors (eg: Project Lombok) the code is not ready for JSweet fully yet (eg: there are custom annotations to handle beforehand). To let JSweet use a non default source directory, the compileSourceRootsOverride config element can be used, for instance with Lombok: <build>
<plugins>
<plugin>
<groupId>org.projectlombok</groupId>
<artifactId>lombok-maven-plugin</artifactId>
<version>1.18.12.0</version>
<executions>
<execution>
<phase>generate-sources</phase>
<goals>
<goal>delombok</goal>
</goals>
<configuration>
<addOutputDirectory>false</addOutputDirectory>
<sourceDirectory>src/main/java</sourceDirectory>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.jsweet</groupId>
<artifactId>jsweet-maven-plugin</artifactId>
<version>3.0.0</version>
<configuration>
<compileSourceRootsOverride>
<compileSourceRoot>target/generated-sources/delombok</compileSourceRoot>
</compileSourceRootsOverride>
<sourceRoot>target/generated-sources/delombok</sourceRoot>
<outDir>javascript</outDir>
<targetVersion>ES5</targetVersion>
</configuration>
<executions>
<execution>
<id>generate-js</id>
<phase>generate-sources</phase>
<goals>
<goal>jsweet</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build> |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论