asoldano closed pull request #406: [CXF-7711] enable JavaToWS to use custom
compiler
URL: https://github.com/apache/cxf/pull/406
This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:
As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):
diff --git
a/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2ws/JavaToWS.java
b/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2ws/JavaToWS.java
index 22df372fb03..ed9f7a0b1f1 100644
--- a/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2ws/JavaToWS.java
+++ b/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2ws/JavaToWS.java
@@ -24,6 +24,7 @@
import org.apache.cxf.common.util.StringUtils;
import org.apache.cxf.tools.common.CommandInterfaceUtils;
+import org.apache.cxf.tools.common.ToolContext;
import org.apache.cxf.tools.common.toolspec.ToolRunner;
public class JavaToWS {
@@ -84,6 +85,17 @@ public void run(OutputStream os) throws Exception {
.getResourceAsStream("java2ws.xml"), false, args,
os);
}
+ /**
+ * Pass user app's (compiler) information in the context.
+ * @param context
+ * @param os
+ * @throws Exception
+ */
+ public void run(ToolContext context, OutputStream os) throws Exception {
+ ToolRunner.runTool(JavaToWSContainer.class,
+ JavaToWSContainer.class.getResourceAsStream("java2ws.xml"),
+ false, args, isExitOnFinish(), context, os);
+ }
private boolean isExitOnFinish() {
String exit = System.getProperty("exitOnFinish");
diff --git
a/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2ws/JavaToWSContainer.java
b/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2ws/JavaToWSContainer.java
index 08366b9b331..08a1d5c8f3b 100644
---
a/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2ws/JavaToWSContainer.java
+++
b/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2ws/JavaToWSContainer.java
@@ -52,6 +52,12 @@ public void execute(boolean exitOnFinish) throws
ToolException {
if (!hasInfoOption()) {
ToolContext env = new ToolContext();
env.setParameters(getParametersMap(new HashSet<>()));
+
+ // check for custom compiler object to pass on
+ if (getContext() != null &&
getContext().get(ToolConstants.COMPILER) != null) {
+ env.put(ToolConstants.COMPILER,
getContext().get(ToolConstants.COMPILER));
+ }
+
if (env.get(ToolConstants.CFG_OUTPUTDIR) == null) {
env.put(ToolConstants.CFG_OUTPUTDIR, ".");
}
diff --git
a/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/generator/wsdl11/BeanGenerator.java
b/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/generator/wsdl11/BeanGenerator.java
index 3df2ee25694..49e4d2f8165 100644
---
a/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/generator/wsdl11/BeanGenerator.java
+++
b/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/generator/wsdl11/BeanGenerator.java
@@ -82,7 +82,10 @@ public void generateAndCompile(Collection<JavaClass>
wrapperClasses, File dir) {
}
//compile the classes
- Compiler compiler = new Compiler();
+ Compiler compiler =
(Compiler)getToolContext().get(ToolConstants.COMPILER);
+ if (compiler == null) {
+ compiler = new Compiler();
+ }
compiler.setOutputDir(compileToDir);
List<String> files = new ArrayList<>(generatedFiles.size());
for (File file : generatedFiles) {
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services