Search in sources :

Example 1 with WSDLToJavaScript

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();
}
Also used : BufferedReader(java.io.BufferedReader) FileReader(java.io.FileReader) ToolContext(org.apache.cxf.tools.common.ToolContext) File(java.io.File) WSDLToJavaScript(org.apache.cxf.tools.wsdlto.javascript.WSDLToJavaScript)

Example 2 with WSDLToJavaScript

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;
}
Also used : GenericWsdlOption(org.apache.cxf.maven_plugin.GenericWsdlOption) LinkedHashSet(java.util.LinkedHashSet) MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) ToolContext(org.apache.cxf.tools.common.ToolContext) URISyntaxException(java.net.URISyntaxException) URI(java.net.URI) Artifact(org.apache.maven.artifact.Artifact) File(java.io.File) WSDLToJavaScript(org.apache.cxf.tools.wsdlto.javascript.WSDLToJavaScript)

Aggregations

File (java.io.File)2 ToolContext (org.apache.cxf.tools.common.ToolContext)2 WSDLToJavaScript (org.apache.cxf.tools.wsdlto.javascript.WSDLToJavaScript)2 BufferedReader (java.io.BufferedReader)1 FileReader (java.io.FileReader)1 URI (java.net.URI)1 URISyntaxException (java.net.URISyntaxException)1 LinkedHashSet (java.util.LinkedHashSet)1 GenericWsdlOption (org.apache.cxf.maven_plugin.GenericWsdlOption)1 Artifact (org.apache.maven.artifact.Artifact)1 MojoExecutionException (org.apache.maven.plugin.MojoExecutionException)1