<?xml version="1.0" encoding="UTF-8"?>

<!--
  ~ Licensed to the Apache Software Foundation (ASF) under one
  ~ or more contributor license agreements. See the NOTICE file
  ~ distributed with this work for additional information
  ~ regarding copyright ownership. The ASF licenses this file
  ~ to you under the Apache License, Version 2.0 (the
  ~ "License"); you may not use this file except in compliance
  ~ with the License. You may obtain a copy of the License at
  ~
  ~ http://www.apache.org/licenses/LICENSE-2.0
  ~
  ~ Unless required by applicable law or agreed to in writing,
  ~ software distributed under the License is distributed on an
  ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  ~ KIND, either express or implied. See the License for the
  ~ specific language governing permissions and limitations
  ~ under the License.
  -->

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.apache.axis2</groupId>
        <artifactId>axis2</artifactId>
        <version>1.7.10-SNAPSHOT</version>
        <relativePath>../../../pom.xml</relativePath>
    </parent>
    <artifactId>axis2-ant-plugin</artifactId>
    <name>Apache Axis2 - tool - Ant Plugin</name>
    <description>The Axis 2 Plugin for Ant Tasks.</description>
    <url>http://axis.apache.org/axis2/java/core/</url>
    <scm>
        <connection>scm:svn:http://svn.apache.org/repos/asf/axis/axis2/java/core/branches/1_7/modules/tool/axis2-ant-plugin</connection>
        <developerConnection>scm:svn:https://svn.apache.org/repos/asf/axis/axis2/java/core/branches/1_7/modules/tool/axis2-ant-plugin</developerConnection>
        <url>http://svn.apache.org/viewvc/axis/axis2/java/core/branches/1_7/modules/tool/axis2-ant-plugin</url>
    </scm>
    <dependencies>
        <dependency>
            <groupId>org.apache.axis2</groupId>
            <artifactId>axis2-codegen</artifactId>
            <version>${project.version}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.axis2</groupId>
            <artifactId>axis2-kernel</artifactId>
            <version>${project.version}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.axis2</groupId>
            <artifactId>axis2-adb</artifactId>
            <version>${project.version}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.axis2</groupId>
            <artifactId>axis2-adb-codegen</artifactId>
            <version>${project.version}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.axis2</groupId>
            <artifactId>axis2-java2wsdl</artifactId>
            <version>${project.version}</version>
        </dependency>

        <dependency>
            <groupId>wsdl4j</groupId>
            <artifactId>wsdl4j</artifactId>
        </dependency>
        <dependency>
            <groupId>commons-logging</groupId>
            <artifactId>commons-logging</artifactId>
        </dependency>
        <dependency>
            <groupId>commons-httpclient</groupId>
            <artifactId>commons-httpclient</artifactId>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.neethi</groupId>
            <artifactId>neethi</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.ws.xmlschema</groupId>
            <artifactId>xmlschema-core</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.geronimo.specs</groupId>
            <artifactId>geronimo-javamail_1.4_spec</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.geronimo.specs</groupId>
            <artifactId>geronimo-activation_1.1_spec</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.ant</groupId>
            <artifactId>ant</artifactId>
        </dependency>
    </dependencies>
    <build>
        <plugins>
            <plugin>
                <artifactId>maven-remote-resources-plugin</artifactId>
                <executions>
                    <execution>
                        <goals>
                            <goal>process</goal>
                        </goals>
                        <configuration>
                            <resourceBundles>
                                <resourceBundle>org.apache.axis2:axis2-resource-bundle:${project.version}</resourceBundle>
                            </resourceBundles>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <artifactId>maven-antrun-plugin</artifactId>
                <executions>
                    <execution>
                        <goals>
                            <goal>run</goal>
                        </goals>
                        <phase>test</phase>
                        <configuration>
                            <tasks unless="maven.test.skip">
                                <taskdef name="java2wsdl" classname="org.apache.axis2.tool.ant.Java2WSDLTask">
                                    <classpath>
                                        <path refid="maven.test.classpath" />
                                    </classpath>
                                </taskdef>
                                
                                <echo message="Generating extraclasses*.wsdl" />
                                
                                <java2wsdl className="test.Service" outputLocation="${project.build.directory}/java2wsdl" outputFileName="extraclasses1.wsdl">
                                    <extraclass name="test.ExtraClass1" />
                                    <extraclass name="test.ExtraClass2" />
                                </java2wsdl>
                                
                                <java2wsdl className="test.Service" outputLocation="${project.build.directory}/java2wsdl" outputFileName="extraclasses2.wsdl" extraClasses="test.ExtraClass1,test.ExtraClass2" />
                                
                                <java2wsdl className="test.Service" outputLocation="${project.build.directory}/java2wsdl" outputFileName="extraclasses3.wsdl" extraClasses="test.ExtraClass1">
                                    <extraclass name="test.ExtraClass2" />
                                </java2wsdl>
                                
                                <echo message="Generating mappings.wsdl" />
                                
                                <java2wsdl className="test.Service" outputLocation="${project.build.directory}/java2wsdl" outputFileName="mappings.wsdl" schemaTargetNamespace="http://www.example.org/schema/test-service">
                                    <mapping package="test" namespace="http://www.example.org/schema/test" />
                                </java2wsdl>
                            </tasks>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.codehaus.gmavenplus</groupId>
                <artifactId>gmavenplus-plugin</artifactId>
                <executions>
                    <execution>
                        <phase>test</phase>
                        <goals>
                            <goal>execute</goal>
                        </goals>
                        <configuration>
                            <scripts>
                                <script>
                                    import groovy.xml.*
                                    
                                    if (System.properties['maven.test.skip']) {
                                        println 'Tests are skipped'
                                        return
                                    }
                                    
                                    def parser = new XmlParser()
                                    def wsdl = new Namespace('http://schemas.xmlsoap.org/wsdl/')
                                    def xs = new Namespace('http://www.w3.org/2001/XMLSchema')
    
                                    println 'Checking extraclasses*.wsdl'
                                    
                                    for (i in 1..3) {                                
                                        def wsdlDoc = parser.parse(new File(project.build.directory, "java2wsdl/extraclasses${i}.wsdl"))
                                        def complexTypes = wsdlDoc[wsdl.types][xs.schema][xs.complexType].'@name'
                                        assert complexTypes.contains('ExtraClass1')
                                        assert complexTypes.contains('ExtraClass2')
                                    }
                                    
                                    println 'Checking mappings.wsdl'
                                    
                                    def wsdlDoc = parser.parse(new File(project.build.directory, "java2wsdl/mappings.wsdl"))
                                    def namespaces = wsdlDoc[wsdl.types][xs.schema].'@targetNamespace'
                                    assert namespaces.contains('http://www.example.org/schema/test-service')
                                    assert namespaces.contains('http://www.example.org/schema/test')
                                </script>
                            </scripts>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>
