<?xml version="1.0" encoding="UTF-8"?>
<!--
- Copyright 2014 Red Hat Inc. and/or its affiliates and other contributors.
-
- 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/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.switchyard.quickstarts</groupId>
        <artifactId>switchyard-quickstart-parent</artifactId>
        <version>2.0.0.Alpha2</version>
        <relativePath>../pom.xml</relativePath>
    </parent>
    <artifactId>switchyard-camel-sql-binding</artifactId>
    <name>SwitchYard Quickstart: camel-sql-binding</name>
    <description>Quickstart : Camel SQL Binding</description>
    <licenses>
        <license>
            <name>Apache License, Version 2.0</name>
            <distribution>repo</distribution>
            <url>http://www.apache.org/licenses/LICENSE-2.0.html</url>
        </license>
    </licenses>
    <properties>
        <deploy.skip>true</deploy.skip>
        <maven.compiler.target>1.6</maven.compiler.target>
        <maven.compiler.source>1.6</maven.compiler.source>
        <switchyard.osgi.export.pkg>org.switchyard.quickstarts.camel.sql.binding*</switchyard.osgi.export.pkg>
        <switchyard.osgi.require.capability>
            org.ops4j.pax.cdi.extension; filter:="(extension=switchyard-component-bean)",
            org.ops4j.pax.cdi.extension; filter:="(extension=deltaspike-core-api)",
            osgi.extender; filter:="(osgi.extender=pax.cdi)"
        </switchyard.osgi.require.capability>
        <switchyard.osgi.provide.capability/>
    </properties>
    <dependencies>
        <dependency>
            <groupId>org.switchyard</groupId>
            <artifactId>switchyard-api</artifactId>
        </dependency>
        <dependency>
            <groupId>org.switchyard</groupId>
            <artifactId>switchyard-extensions-java</artifactId>
        </dependency>
        <dependency>
            <groupId>org.switchyard</groupId>
            <artifactId>switchyard-plugin</artifactId>
        </dependency>
        <dependency>
            <groupId>org.switchyard.components</groupId>
            <artifactId>switchyard-component-camel-sql</artifactId>
        </dependency>
        <dependency>
            <groupId>org.switchyard.components</groupId>
            <artifactId>switchyard-component-camel-quartz</artifactId>
        </dependency>
        <dependency>
            <groupId>org.switchyard.components</groupId>
            <artifactId>switchyard-component-bean</artifactId>
        </dependency>
        <dependency>
            <groupId>org.switchyard</groupId>
            <artifactId>switchyard-test</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.switchyard.components</groupId>
            <artifactId>switchyard-component-test-mixin-cdi</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.switchyard.components</groupId>
            <artifactId>switchyard-component-test-mixin-naming</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.h2database</groupId>
            <artifactId>h2</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.hamcrest</groupId>
            <artifactId>hamcrest-all</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>
    <build>
        <finalName>${project.artifactId}</finalName>
        <plugins>
            <plugin>
                <groupId>org.switchyard</groupId>
                <artifactId>switchyard-plugin</artifactId>
                <executions>
                    <execution>
                        <goals>
                            <goal>configure</goal>
                        </goals>
                        <configuration>
                            <scannerClassNames>
                                <param>org.switchyard.transform.config.model.TransformSwitchYardScanner</param>
                            </scannerClassNames>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.jboss.as.plugins</groupId>
                <artifactId>jboss-as-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <id>deploy</id>
                        <phase>install</phase>
                        <goals>
                            <goal>deploy</goal>
                        </goals>
                        <configuration>
                            <beforeDeployment>
                                <scripts>
                                    <script>config.cli</script>
                                </scripts>
                            </beforeDeployment>
                            <skip>${deploy.skip}</skip>
                        </configuration>
                    </execution>
                    <execution>
                        <id>undeploy</id>
                        <phase>clean</phase>
                        <goals>
                            <goal>undeploy</goal>
                        </goals>
                        <configuration>
                            <afterDeployment>
                                <scripts>
                                    <script>unconfig.cli</script>
                                </scripts>
                            </afterDeployment>
                            <skip>${deploy.skip}</skip>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
    <profiles>
        <profile>
            <id>deploy</id>
            <properties>
                <deploy.skip>false</deploy.skip>
            </properties>
            <build>
                <plugins>
                    <plugin>
                        <groupId>com.edugility</groupId>
                        <artifactId>h2-maven-plugin</artifactId>
                        <version>1.0</version>
                        <inherited>false</inherited>
                        <configuration>
                            <baseDirectory>${project.build.directory}</baseDirectory>
                        </configuration>
                        <executions>
                            <execution>
                                <id>Spawn a new H2 TCP server</id>
                                <phase>package</phase>
                                <goals>
                                    <goal>spawn</goal>
                                </goals>
                            </execution>
                            <execution>
                                <id>Stop a spawned H2 TCP server</id>
                                <phase>pre-clean</phase>
                                <goals>
                                    <goal>stop</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.codehaus.mojo</groupId>
                        <artifactId>sql-maven-plugin</artifactId>
                        <version>1.5</version>
                        <dependencies>
                            <dependency>
                                <groupId>com.h2database</groupId>
                                <artifactId>h2</artifactId>
                                <version>${version.com.h2database}</version>
                            </dependency>
                        </dependencies>
                        <configuration>
                            <driver>org.h2.Driver</driver>
                            <url>jdbc:h2:tcp://localhost/h2db</url>
                            <username>sa</username>
                            <skip>${deploy.skip}</skip>
                        </configuration>
                        <executions>
                            <execution>
                                <id>create</id>
                                <phase>package</phase>
                                <goals>
                                    <goal>execute</goal>
                                </goals>
                                <configuration>
                                    <sqlCommand>CREATE TABLE IF NOT EXISTS greetings ( id INT PRIMARY KEY AUTO_INCREMENT, receiver VARCHAR(255), sender VARCHAR(255) )</sqlCommand>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>
    <packaging>bundle</packaging>
</project>
