Skip to content

Commit

Permalink
Merge branch 'release/v1.0.4'
Browse files Browse the repository at this point in the history
  • Loading branch information
monai committed Apr 6, 2016
2 parents 2ba43cb + 212a4ca commit a5df1eb
Show file tree
Hide file tree
Showing 4 changed files with 145 additions and 73 deletions.
90 changes: 49 additions & 41 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,18 @@ Download [latest](https://github.com/monai/cc-web-runner/releases) release.
## Build

```bash
mvn clean compile package
mvn compile package
```

Produces standalone JAR.
Produces 2 artifacts:

- WAR archive that can be deployed on servlet container
- Standalone executable JAR archive

## Run

```bash
java -jar target/cc-web-runner-1.0.3-SNAPSHOT.jar
java -jar target/cc-web-runner-standalone-1.0-SNAPSHOT.jar
```

## Use
Expand All @@ -35,53 +38,58 @@ curl -X POST -H "Content-Type: application/json" -d '{
' "http://localhost:8080/compile"
```

## Endpoints

Request and response content types are `application/json`.

### GET /status

Returns default options with given optimizations and Closure Compiler version.

Query parameters:

- `level` String - is of type [CompilationLevel](https://github.com/google/closure-compiler/blob/29bbd198f0bf4967e4f406674b3eaf302a1f16a4/src/com/google/javascript/jscomp/CompilationLevel.java), compilation level
- `debug` Boolean - whether to call `setDebugOptionsForCompilationLevel`
- `typeBased` Boolean - whether to call `setTypeBasedOptimizationOptions`
- `wrappedOutput` Boolean - whether to call `setWrappedOutputOptimizations`

Response:

```bash
{
"result":{
"debugLog":"",
"errors":[
],
"success":true,
"variableMap":{
"newNameToOriginalNameMap":{
},
"originalNameToNewNameMap":{
}
},
"warnings":[
]
},
"source":"console.log(function(){return 33});",
"status":"SUCCESS"
}
```
- `options` Object - is of type [CompilerOptions](https://github.com/google/closure-compiler/blob/v20160208/src/com/google/javascript/jscomp/CompilerOptions.java), compiler options
- `compilerVersions` String - Closure Compiler version

## Request
### GET /externs

- `externs` - array of file objects
- `sources` - array of file objects
- `optimizations`
- `level` - is of [CompilationLevel](https://github.com/google/closure-compiler/blob/29bbd198f0bf4967e4f406674b3eaf302a1f16a4/src/com/google/javascript/jscomp/CompilationLevel.java) type
- `debug` - true|false, whether to call `setDebugOptionsForCompilationLevel`
- `typeBased` - true|false, whether to call `setTypeBasedOptimizationOptions`
- `wrappedOutput` - true|false, whether to call `setWrappedOutputOptimizations`
- `options` - directly deserialized to [CompilerOptions](https://github.com/google/closure-compiler/blob/v20160208/src/com/google/javascript/jscomp/CompilerOptions.java) class
Returns default externs.

Response:

- `externs` Array - is of type List<[SourceFile](https://github.com/google/closure-compiler/blob/master/src/com/google/javascript/jscomp/SourceFile.java)>, array of extern files

File object
### POST /compile

- `fileName` - file name
- `code` - file content
Request:

- `externs` Array - `[{ fileName: String, code: String }]`, array of extern files
- `sources` Array - `[{ fileName: String, code: String }]`, array of source files to compile
- `optimizations`
- `level` String - is of type [CompilationLevel](https://github.com/google/closure-compiler/blob/29bbd198f0bf4967e4f406674b3eaf302a1f16a4/src/com/google/javascript/jscomp/CompilationLevel.java), compilation level
- `debug` Boolean - whether to call `setDebugOptionsForCompilationLevel`
- `typeBased` Boolean - whether to call `setTypeBasedOptimizationOptions`
- `wrappedOutput` Boolean - whether to call `setWrappedOutputOptimizations`
- `options` Object - is of type [CompilerOptions](https://github.com/google/closure-compiler/blob/v20160208/src/com/google/javascript/jscomp/CompilerOptions.java), compiler options

Add `?debug` query parameter to get exception object with error response.
Query parameters:

## Response
- `?debug` - whether return error error messages.

Response:

- `result` - directly serialized from [Result](https://github.com/google/closure-compiler/blob/v20160208/src/com/google/javascript/jscomp/Result.java) class
- `source` - compiled source
- `status` - SUCCESS|ERROR
- `message` - error message if status is 'ERROR'
- `result` Object - is of type [Result](https://github.com/google/closure-compiler/blob/v20160208/src/com/google/javascript/jscomp/Result.java), compilations results
- `source` String - compiled source
- `status` String - SUCCESS|ERROR
- `message` String - error message if status is 'ERROR'
- `exception` Object - is of type Throwable, occurred exception

## License

Expand Down
48 changes: 48 additions & 0 deletions pom-jar.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<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/maven-v4_0_0.xsd">

<modelVersion>4.0.0</modelVersion>

<groupId>com.github.monai</groupId>
<artifactId>cc-web-runner-standalone</artifactId>
<packaging>jar</packaging>
<version>1.0.4</version>

<parent>
<groupId>com.github.monai</groupId>
<artifactId>cc-web-runner-parent</artifactId>
<version>1.0.4</version>
<relativePath>pom.xml</relativePath>
</parent>

<properties>
<plugin.shade.version>2.4.3</plugin.shade.version>
<main.class>com.github.monai.Application</main.class>
</properties>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>${plugin.shade.version}</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>${main.class}</mainClass>
</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
39 changes: 39 additions & 0 deletions pom-war.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<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/maven-v4_0_0.xsd">

<modelVersion>4.0.0</modelVersion>

<groupId>com.github.monai</groupId>
<artifactId>cc-web-runner</artifactId>
<packaging>war</packaging>
<version>1.0.4</version>

<parent>
<groupId>com.github.monai</groupId>
<artifactId>cc-web-runner-parent</artifactId>
<version>1.0.4</version>
<relativePath>pom.xml</relativePath>
</parent>

<properties>
<plugin.war.version>2.6</plugin.war.version>
<main.class>com.github.monai.Application</main.class>
</properties>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>${plugin.war.version}</version>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
</manifest>
</archive>
</configuration>
</plugin>
</plugins>
</build>
</project>
41 changes: 9 additions & 32 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,27 @@
<modelVersion>4.0.0</modelVersion>

<groupId>com.github.monai</groupId>
<artifactId>cc-web-runner</artifactId>
<packaging>jar</packaging>
<version>1.0.3</version>
<artifactId>cc-web-runner-parent</artifactId>
<packaging>pom</packaging>
<version>1.0.4</version>

<properties>
<java.version>1.8</java.version>
<jetty.version>9.3.7.v20160115</jetty.version>
<jersey.version>2.22.2</jersey.version>
<genson.version>1.3</genson.version>
<closure-compiler.version>v20160208</closure-compiler.version>
<plugin.war.version>2.6</plugin.war.version>
<plugin.exec.version>1.4.0</plugin.exec.version>
<plugin.shade.version>2.4.3</plugin.shade.version>
<plugin.compiler.version>3.5.1</plugin.compiler.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<main.class>com.github.monai.Application</main.class>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<modules>
<module>pom-jar.xml</module>
<module>pom-war.xml</module>
</modules>

<build>
<plugins>
<plugin>
Expand All @@ -34,11 +37,6 @@
<target>${java.version}</target>
</configuration>
</plugin>
<plugin>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>${jetty.version}</version>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
Expand All @@ -54,27 +52,6 @@
<mainClass>${main.class}</mainClass>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>${plugin.shade.version}</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>${main.class}</mainClass>
</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>

Expand Down

0 comments on commit a5df1eb

Please sign in to comment.