diff --git a/code-gen/build.xml b/code-gen/build.xml
index 57dfc57115b..3298102479d 100644
--- a/code-gen/build.xml
+++ b/code-gen/build.xml
@@ -10,24 +10,36 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+ Must specify the parameter: outputPath eg. -DoutputPath=../java/src/main/java/com/wordnik/
+
+
+ outputPath for Api = ${outputPath}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/code-gen/src/main/java/com/wordnik/codegen/DriverCodeGenerator.java b/code-gen/src/main/java/com/wordnik/codegen/DriverCodeGenerator.java
index 9cdb32e613e..1aee4933eba 100644
--- a/code-gen/src/main/java/com/wordnik/codegen/DriverCodeGenerator.java
+++ b/code-gen/src/main/java/com/wordnik/codegen/DriverCodeGenerator.java
@@ -1,20 +1,17 @@
package com.wordnik.codegen;
-import com.sun.jersey.api.client.Client;
-import com.sun.jersey.api.client.ClientResponse;
-import com.sun.jersey.api.client.WebResource;
import com.wordnik.codegen.api.SwaggerApi;
import com.wordnik.codegen.config.CodeGenConfig;
import com.wordnik.codegen.config.GenerationEnvironmentConfig;
import com.wordnik.codegen.resource.*;
import com.wordnik.exception.CodeGenerationException;
-
import org.antlr.stringtemplate.StringTemplate;
import org.antlr.stringtemplate.StringTemplateGroup;
-import org.codehaus.jackson.map.ObjectMapper;
-import org.codehaus.jackson.map.DeserializationConfig.Feature;
-import java.io.*;
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
diff --git a/code-gen/src/main/java/com/wordnik/codegen/java/JavaGenEnvConfig.java b/code-gen/src/main/java/com/wordnik/codegen/java/JavaGenEnvConfig.java
index 8d2456a0fa7..c41cf771495 100644
--- a/code-gen/src/main/java/com/wordnik/codegen/java/JavaGenEnvConfig.java
+++ b/code-gen/src/main/java/com/wordnik/codegen/java/JavaGenEnvConfig.java
@@ -1,6 +1,7 @@
package com.wordnik.codegen.java;
import com.wordnik.codegen.config.GenerationEnvironmentConfig;
+import com.wordnik.exception.CodeGenerationException;
/**
* User: deepakmichael
@@ -9,9 +10,15 @@ import com.wordnik.codegen.config.GenerationEnvironmentConfig;
*/
public class JavaGenEnvConfig extends GenerationEnvironmentConfig{
- public JavaGenEnvConfig() {
- this.setModelClassLocation("../java/src/main/java/com/wordnik/model/");
- this.setResourceClassLocation("../java/src/main/java/com/wordnik/api/");
+ public JavaGenEnvConfig(String outputPath) {
+ if(outputPath == null){
+ throw new CodeGenerationException("Error creating output path : Output path was null ");
+ }
+
+ outputPath = outputPath.endsWith("/") ? outputPath.substring(0, outputPath.lastIndexOf("/")) : outputPath;
+
+ this.setModelClassLocation(outputPath + "/model/");
+ this.setResourceClassLocation(outputPath + "/api/");
this.setTemplateLocation("conf/templates/java");
}
}
diff --git a/code-gen/src/main/java/com/wordnik/codegen/java/JavaLibCodeGen.java b/code-gen/src/main/java/com/wordnik/codegen/java/JavaLibCodeGen.java
index 8be3d290545..d74e3c38a35 100644
--- a/code-gen/src/main/java/com/wordnik/codegen/java/JavaLibCodeGen.java
+++ b/code-gen/src/main/java/com/wordnik/codegen/java/JavaLibCodeGen.java
@@ -1,6 +1,7 @@
package com.wordnik.codegen.java;
import com.wordnik.codegen.DriverCodeGenerator;
+import com.wordnik.exception.CodeGenerationException;
/**
* User: ramesh
@@ -10,12 +11,17 @@ import com.wordnik.codegen.DriverCodeGenerator;
public class JavaLibCodeGen extends DriverCodeGenerator {
public static void main(String[] args) {
- JavaLibCodeGen codeGenerator = new JavaLibCodeGen();
+ if(args.length < 1){
+ throw new CodeGenerationException("Invalid number of arguments passed: No command line argument was passed to the program for output path");
+ }
+
+ String outputPath = args[0];
+ JavaLibCodeGen codeGenerator = new JavaLibCodeGen(outputPath);
codeGenerator.generateCode();
}
- public JavaLibCodeGen(){
+ public JavaLibCodeGen(String outputPath){
this.setConfig(new JavaCodeGenConfig());
- this.setEnvConfig(new JavaGenEnvConfig());
+ this.setEnvConfig(new JavaGenEnvConfig(outputPath));
}
}