我使用 jSweet Maven 插件从java代码生成JavaScript代码,并获得成功的JavaScript代码。现在我想根据下面提到的细节自定义JavaScript文件:
我在这里遵循一些步骤:
我正在使用 NetBeans IDE 来解决我的问题。
DemoColor.java
package com.company.javatojstest;
public enum DemoColor
{
Unknown,
Blue,
Green,
Black,
Yellow,
White,;
}
我正在获取下面的输出文件。
Democolor.js
var com;
(function (com) {
var company;
(function (company) {
var javatojstest;
(function (javatojstest) {
/**
*
* @author Admin
* @enum
* @property {com.company.javatojstest.DemoColor} Unknown
* @property {com.company.javatojstest.DemoColor} Blue
* @property {com.company.javatojstest.DemoColor} Green
* @property {com.company.javatojstest.DemoColor} Black
* @property {com.company.javatojstest.DemoColor} Yellow
* @property {com.company.javatojstest.DemoColor} White
* @class
*/
var DemoColor;
(function (DemoColor) {
DemoColor[DemoColor["Unknown"] = 0] = "Unknown";
DemoColor[DemoColor["Blue"] = 1] = "Blue";
DemoColor[DemoColor["Green"] = 2] = "Green";
DemoColor[DemoColor["Black"] = 3] = "Black";
DemoColor[DemoColor["Yellow"] = 4] = "Yellow";
DemoColor[DemoColor["White"] = 5] = "White";
})(DemoColor = javatojstest.DemoColor || (javatojstest.DemoColor = {}));
})(javatojstest = company.javatojstest || (company.javatojstest = {}));
})(company = com.company || (com.company = {}));
})(com || (com = {}));
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.jsweet</groupId>
<artifactId>jsweet-quickstart</artifactId>
<version>2.2.0-SNAPSHOT</version>
<name>javatojs</name>
<description>A simple project structure to get started with JSweet v2</description>
<developers>
<developer>
<id>rpawlak</id>
<name>Renaud Pawlak</name>
<email>renaud.pawlak@gmail.com</email>
</developer>
</developers>
<licenses>
<license>
<name>The Apache Software License, Version 2.0</name>
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
<distribution>repo</distribution>
</license>
</licenses>
<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>
<repositories>
<repository>
<id>jsweet-central</id>
<name>libs-release</name>
<url>http://repository.jsweet.org/artifactory/libs-release-local</url>
</repository>
<repository>
<snapshots />
<id>jsweet-snapshots</id>
<name>libs-snapshot</name>
<url>http://repository.jsweet.org/artifactory/libs-snapshot-local</url>
</repository>
</repositories>
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<fork>true</fork>
</configuration>
</plugin>
<plugin>
<groupId>org.jsweet</groupId>
<artifactId>jsweet-maven-plugin</artifactId>
<version>2.2.0-SNAPSHOT</version>
<configuration>
<verbose>true</verbose>
<tsOut>target/ts</tsOut>
<outDir>target/js</outDir>
<candiesJsOut>webapp</candiesJsOut>
<targetVersion>ES3</targetVersion>
</configuration>
<executions>
<execution>
<id>generate-js</id>
<phase>generate-sources</phase>
<goals>
<goal>jsweet</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
<pluginManagement>
<plugins>
<!--This plugin's configuration is used to store Eclipse m2e settings
only. It has no influence on the Maven build itself. -->
<plugin>
<groupId>org.eclipse.m2e</groupId>
<artifactId>lifecycle-mapping</artifactId>
<version>1.0.0</version>
<configuration>
<lifecycleMappingMetadata>
<pluginExecutions>
<pluginExecution>
<pluginExecutionFilter>
<groupId>
org.jsweet
</groupId>
<artifactId>
jsweet-maven-plugin
</artifactId>
<versionRange>
[1.0.0,)
</versionRange>
<goals>
<goal>jsweet</goal>
</goals>
</pluginExecutionFilter>
<action>
<ignore></ignore>
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
<dependencies>
<dependency>
<groupId>org.jsweet</groupId>
<artifactId>jsweet-core</artifactId>
<version>6-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.jsweet.candies</groupId>
<artifactId>jquery</artifactId>
<version>1.10.0-20170726</version>
</dependency>
</dependencies>
</project>
In JavaScript file i want to customize from this line, DemoColor[DemoColor["Unknown"] = 0] = "Unknown"; to DemoColor[DemoColor["Unknown"] = Unknown] = "Unknown"; I.e whenever JavaScript file find unknown then the index value will automatically change to unknown.
谢谢。