<!--
  ~ Copyright 2005-2007 WSO2, Inc. (http://wso2.com)
  ~
  ~ Licensed 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">

    <parent>
        <groupId>org.wso2.wsas</groupId>
        <artifactId>org.wso2.wsas</artifactId>
        <version>2.2</version>
    </parent>

    <modelVersion>4.0.0</modelVersion>
    <artifactId>wso2wsas-admin</artifactId>
    <packaging>jar</packaging>
    <name>Admin</name>
    <description>This is the WSO2 WSAS Administration module</description>

    <dependencies>

        <!-- WSAS Dependencies -->
        <dependency>
            <groupId>org.wso2.wsas</groupId>
            <artifactId>wso2wsas-core</artifactId>
            <version>${pom.version}</version>
        </dependency>

        <!-- System dependency -->
        <dependency>
            <groupId>sun.jdk</groupId>
            <artifactId>tools</artifactId>
            <version>${java.version}</version>
            <scope>system</scope>
            <systemPath>${toolsjar}</systemPath>
        </dependency>

        <dependency>
            <groupId>org.wso2.wsas</groupId>
            <artifactId>wso2wsas-core</artifactId>
            <version>${pom.version}</version>
            <type>test-jar</type>
            <scope>test</scope>
        </dependency>

    </dependencies>

    <build>
        <sourceDirectory>src</sourceDirectory>
        <testSourceDirectory>test</testSourceDirectory>

        <testResources>
            <testResource>
                <directory>../core/test-resources</directory>
                <includes>
                    <include>**/*.cfg.xml</include>
                </includes>
            </testResource>
            <testResource>
                <directory>../core/conf/hibernate</directory>
                <includes>
                    <include>**/*.hbm.xml</include>
                </includes>
            </testResource>
            <testResource>
                <directory>../core/conf</directory>
                <includes>
                    <include>**/*.properties</include>
                </includes>
            </testResource>
        </testResources>

        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>1.4</source>
                    <target>1.4</target>
                </configuration>
            </plugin>

            <plugin>
                <artifactId>maven-surefire-plugin</artifactId>
                <inherited>true</inherited>
                <configuration>
                    <systemProperties>
                        <property>
                            <name>log4j.configuration</name>
                            <value>file:${basedir}/../core/conf/log4j.properties</value>
                        </property>
                        <property>
                            <name>maven.test.haltafterfailure</name>
                            <value>false</value>
                        </property>
                        <property>
                            <name>wsas.test.timeout</name>
                            <value>1200000</value>
                        </property>
                    </systemProperties>
                    <forkMode>pertest</forkMode>
                    <argLine>-enableassertions</argLine>
                    <testFailureIgnore>false</testFailureIgnore>
                    <skip>false</skip>
                    <includes>
                        <include>**/*AdminTestSuite.java</include>
                        <include>**/*LoggingServiceTest.java</include>
                    </includes>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <version>2.0-alpha-4</version>
                <executions>
                    <execution>
                        <id>copy</id>
                        <phase>generate-test-resources</phase>
                        <goals>
                            <goal>copy</goal>
                        </goals>
                        <configuration>
                            <artifactItems>
                                <artifactItem>
                                    <groupId>org.wso2.throttle</groupId>
                                    <artifactId>wso2throttle</artifactId>
                                    <version>${wso2throttle.version}</version>
                                    <type>mar</type>
                                    <overWrite>true</overWrite>
                                    <outputDirectory>target/tomcat_test/repository/modules
                                    </outputDirectory>
                                </artifactItem>
                            </artifactItems>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-antrun-plugin</artifactId>
                <version>1.1</version>
                <executions>
                    <execution>
                        <id>generate-code</id>
                        <phase>process-resources</phase>
                        <configuration>
                            <tasks>
                                <echo>Generating skeletons for Generic Services</echo>
                                <java classname="org.wso2.utils.codegen.CodegenHelper"
                                      fork="true">
                                    <arg value="./src/org/wso2/wsas/admin/wsas-admin-codegen.xml"/>
                                    <classpath refid="maven.dependency.classpath"/>
                                    <classpath refid="maven.compile.classpath"/>
                                    <classpath refid="maven.runtime.classpath"/>
                                </java>
                            </tasks>
                        </configuration>
                        <goals>
                            <goal>run</goal>
                        </goals>
                    </execution>

                    <execution>
                        <id>create_repo</id>
                        <phase>generate-test-resources</phase>
                        <configuration>
                            <tasks>

                                <mkdir dir="target/toAdmin"/>
                                <mkdir dir="target/tmp/service"/>
                                <mkdir dir="target/toAdmin/service/META-INF"/>
                                <mkdir dir="target/toAdmin/module/META-INF"/>
                                <copy file="src/org/wso2/wsas/admin/module/admin/META-INF/module.xml"
                                      tofile="target/toAdmin/module/META-INF/module.xml"/>
                                <copy file="src/org/wso2/wsas/admin/service/META-INF/services.xml"
                                      tofile="target/toAdmin/service/META-INF/services.xml"/>

                                <jar jarfile="target/wso2wsas-administration.aar"
                                     basedir="target/toAdmin/service">
                                    <include name="**"/>
                                </jar>
                                <jar jarfile="target/wso2wsas-admin-${wso2.admin.module.version}.mar"
                                     basedir="target/toAdmin/module">
                                    <include name="**"/>
                                </jar>

                                <copy file="test-resources/META-INF/admin-services.xml"
                                      tofile="target/tmp/service/META-INF/services.xml"/>
                                <jar jarfile="target/wso2wsas-test-logging.aar"
                                     basedir="target/tmp/service">
                                    <include name="**"/>
                                </jar>

                                <delete dir="target/toAdmin"/>
                                <delete dir="target/tmp"/>

                                <mkdir dir="target/test-classes"/>
                                <mkdir dir="target/repository"/>

                                <copy todir="target/repository/modules">
                                    <fileset file="target/wso2wsas-admin-${wso2.admin.module.version}.mar"/>
                                </copy>

                                <!-- Copying throttle related resources -->
                                <copy todir="target/tomcat_test/repository/services">
                                    <fileset dir="test-resources/repository/services"/>
                                </copy>

                                <copy file="target/wso2wsas-admin-${wso2.admin.module.version}.mar"
                                      tofile="target/tomcat_test/repository/modules/wso2wsas-admin-${wso2.admin.module.version}.mar"/>
                                <copy file="target/wso2wsas-test-logging.aar"
                                      tofile="target/tomcat_test/repository/services/wso2wsas-test-logging.aar"/>
                                <copy todir="target/tomcat_test">
                                    <fileset dir="../core/target/tomcat_test"/>
                                </copy>

                            </tasks>
                        </configuration>
                        <goals>
                            <goal>run</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>build-helper-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <id>copy-code</id>
                        <phase>generate-sources</phase>
                        <goals>
                            <goal>add-source</goal>
                        </goals>
                        <configuration>
                            <sources>
                                <source>${basedir}/target/generated/src</source>
                            </sources>
                        </configuration>
                    </execution>
                    <execution>
                        <id>add-test-source</id>
                        <phase>generate-sources</phase>
                        <goals>
                            <goal>add-test-source</goal>
                        </goals>
                        <configuration>
                            <sources>
                                <source>${basedir}/target/generated-test/src</source>
                            </sources>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-checkstyle-plugin</artifactId>
                <configuration>
                    <enableRulesSummary>false</enableRulesSummary>
                </configuration>
            </plugin>
            <!--<plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-clover-plugin</artifactId>
                <configuration>
                    <licenseLocation>${clover.license.file}</licenseLocation>
                    <targetPercentage>60%</targetPercentage>
                    <generateHtml>true</generateHtml>
                    <generatePdf>false</generatePdf>
                    <generateXml>false</generateXml>
                    <excludes>
                        <exclude>**/*TestSuite.java</exclude>
                        <exclude>**/*Test.java</exclude>
                    </excludes>
                </configuration>
                <executions>
                    <execution>
                        <phase>verify</phase>
                        <goals>
                            <goal>aggregate</goal>
                            <goal>instrument</goal>
                            <goal>clover</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>-->
        </plugins>
    </build>

    <reporting>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-report-plugin</artifactId>
                <configuration>
                    <outputDirectory>../../target/site/${artifactId}</outputDirectory>
                    <reportsDirectory>target/surefire-reports</reportsDirectory>
                    <outputName>${artifactId}-test-report</outputName>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jxr-plugin</artifactId>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-site-plugin</artifactId>
                <configuration>
                    <outputDirectory>../../target/site/${artifactId}</outputDirectory>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>findbugs-maven-plugin</artifactId>
                <version>1.1.1</version>
                <configuration>
                    <!--<xmlOutput>true|false</xmlOutput>
                    <xmlOutputDirectory>
                    directory location of xml findbugs report
                    </xmlOutputDirectory>
                    <threshold>Normal</threshold>
                    <effort>Default</effort>
                    <excludeFilterFile>findbugs-exclude.xml</excludeFilterFile>
                    <includeFilterFile>findbugs-include.xml</includeFilterFile>
                    <visitors>FindDeadLocalStores,UnreadFields</visitors>
                    <omitVisitors>FindDeadLocalStores,UnreadFields</omitVisitors>
                    <onlyAnalyze>org.codehaus.mojo.findbugs.*</onlyAnalyze>
                    <pluginList>/libs/fb-contrib/fb-contrib-2.8.0.jar</pluginList>
                    <debug>true|false</debug>
                    <relaxed>true|false</relaxed>-->
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-checkstyle-plugin</artifactId>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-clover-plugin</artifactId>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-pmd-plugin</artifactId>
            </plugin>
        </plugins>
    </reporting>
</project>
