001    /**
002     * Copyright (c) 2000-2011 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.util.ant;
016    
017    import java.io.File;
018    
019    import org.apache.axis.tools.ant.wsdl.NamespaceMapping;
020    import org.apache.axis.tools.ant.wsdl.Wsdl2javaAntTask;
021    
022    /**
023     * @author Brian Wing Shun Chan
024     */
025    public class Wsdl2JavaTask {
026    
027            public static void generateJava(String url, String output) {
028                    generateJava(url, output, null);
029            }
030    
031            public static void generateJava(String url, String output, String mapping) {
032                    Wsdl2javaAntTask wsdl2Java = new Wsdl2javaAntTask();
033    
034                    wsdl2Java.setProject(AntUtil.getProject());
035                    wsdl2Java.setURL(url);
036                    wsdl2Java.setOutput(new File(output));
037                    wsdl2Java.setServerSide(true);
038                    wsdl2Java.setTestCase(false);
039                    wsdl2Java.setVerbose(false);
040    
041                    if (mapping != null) {
042                            NamespaceMapping namespaceMapping = new NamespaceMapping();
043    
044                            namespaceMapping.setFile(new File(mapping));
045    
046                            wsdl2Java.addMapping(namespaceMapping);
047                    }
048    
049                    wsdl2Java.execute();
050            }
051    
052    }