use of org.apache.cxf.tools.wsdlto.javascript.WSDLToJavaScript in project cxf by apache.
the class ForkOnceWSDL2Javascript method main.
public static void main(String[] args) throws Exception {
File file = new File(args[0]);
BufferedReader reader = new BufferedReader(new FileReader(file));
String line = reader.readLine();
while (line != null) {
int i = Integer.parseInt(line);
if (i == -1) {
reader.close();
return;
}
String[] wargs = new String[i];
for (int x = 0; x < i; x++) {
wargs[x] = reader.readLine();
}
new WSDLToJavaScript(wargs).run(new ToolContext());
line = reader.readLine();
}
reader.close();
}
use of org.apache.cxf.tools.wsdlto.javascript.WSDLToJavaScript in project cxf by apache.
the class WSDL2JavaScriptMojo method generate.
@Override
protected Bus generate(GenericWsdlOption genericWsdlOption, Bus bus, Set<URI> classPath) throws MojoExecutionException {
WsdlOption wsdlOption = (WsdlOption) genericWsdlOption;
File outputDirFile = wsdlOption.getOutputDir();
outputDirFile.mkdirs();
URI basedir = project.getBasedir().toURI();
URI wsdlURI;
try {
wsdlURI = new URI(wsdlOption.getUri());
} catch (URISyntaxException e) {
throw new MojoExecutionException("Failed to get URI for wsdl " + wsdlOption.getUri(), e);
}
File doneFile = getDoneFile(basedir, wsdlURI, "js");
if (!shouldRun(wsdlOption, doneFile, wsdlURI)) {
return bus;
}
doneFile.delete();
List<String> list = wsdlOption.generateCommandLine(outputDirFile, basedir, wsdlURI, getLog().isDebugEnabled());
String[] args = list.toArray(new String[list.size()]);
getLog().debug("Calling wsdl2js with args: " + Arrays.toString(args));
if (!"false".equals(fork)) {
Set<URI> artifactsPath = new LinkedHashSet<URI>();
for (Artifact a : pluginArtifacts) {
File file = a.getFile();
if (file == null) {
throw new MojoExecutionException("Unable to find file for artifact " + a.getGroupId() + ":" + a.getArtifactId() + ":" + a.getVersion());
}
artifactsPath.add(file.toURI());
}
addPluginArtifact(artifactsPath);
artifactsPath.addAll(classPath);
runForked(artifactsPath, WSDLToJavaScript.class.getName(), args);
} else {
if (bus == null) {
bus = BusFactory.newInstance().createBus();
BusFactory.setThreadDefaultBus(bus);
}
try {
new WSDLToJavaScript(args).run(new ToolContext());
} catch (Throwable e) {
getLog().debug(e);
throw new MojoExecutionException(e.getMessage(), e);
}
}
try {
createMarkerFile(wsdlOption, doneFile, wsdlURI);
} catch (Throwable e) {
getLog().warn("Could not create marker file " + doneFile.getAbsolutePath());
getLog().debug(e);
throw new MojoExecutionException("Failed to create marker file " + doneFile.getAbsolutePath());
}
if (project != null && getGeneratedSourceRoot() != null && getGeneratedSourceRoot().exists()) {
project.addCompileSourceRoot(getGeneratedSourceRoot().getAbsolutePath());
}
if (project != null && getGeneratedTestRoot() != null && getGeneratedTestRoot().exists()) {
project.addTestCompileSourceRoot(getGeneratedTestRoot().getAbsolutePath());
}
return bus;
}
Aggregations