<?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.cayenne</groupId>
		<artifactId>cayenne-parent</artifactId>
		<version>4.0.M5</version>
	</parent>
	<artifactId>cayenne-server</artifactId>
	<name>cayenne-server: Cayenne Server</name>
	<description>Cayenne Server</description>
	<packaging>jar</packaging>
	
	<dependencies>

		<!-- Compile dependencies -->
		<dependency>
			<groupId>org.apache.cayenne</groupId>
			<artifactId>cayenne-di</artifactId>
			<version>${project.version}</version>
			<scope>compile</scope>
		</dependency>
		<dependency>
			<groupId>commons-collections</groupId>
			<artifactId>commons-collections</artifactId>
			<scope>compile</scope>
		</dependency>
		<dependency>
			<groupId>commons-logging</groupId>
			<artifactId>commons-logging</artifactId>
			<scope>compile</scope>
		</dependency>
		<dependency>
			<groupId>org.apache.velocity</groupId>
			<artifactId>velocity</artifactId>
			<scope>compile</scope>
		</dependency>

		<!-- Optional dependencies... things that might have been placed in submodules... -->
		<dependency>
			<groupId>com.caucho</groupId>
            <artifactId>hessian</artifactId>
			<scope>provided</scope>
			<optional>true</optional>
		</dependency>
		<dependency>
			<groupId>jgroups</groupId>
			<artifactId>jgroups-all</artifactId>
			<scope>provided</scope>
			<optional>true</optional>
		</dependency>
		<dependency>
			<groupId>jivesoftware</groupId>
			<artifactId>smack</artifactId>
			<scope>provided</scope>
			<optional>true</optional>
		</dependency>
		<dependency>
			<groupId>jivesoftware</groupId>
			<artifactId>smackx</artifactId>
			<scope>provided</scope>
			<optional>true</optional>
		</dependency>
		<dependency>
			<groupId>opensymphony</groupId>
			<artifactId>oscache</artifactId>
			<scope>provided</scope>
			<optional>true</optional>
		</dependency>
		<dependency>
			<groupId>net.sf.ehcache</groupId>
			<artifactId>ehcache-core</artifactId>
			<scope>provided</scope>
			<optional>true</optional>
		</dependency>
		<dependency>
			<groupId>org.apache.geronimo.specs</groupId>
			<artifactId>geronimo-jms_1.1_spec</artifactId>
			<scope>provided</scope>
			<optional>true</optional>
		</dependency>
		<dependency>
			<groupId>javax.servlet</groupId>
			<artifactId>servlet-api</artifactId>
			<scope>provided</scope>
			<optional>true</optional>
		</dependency>

		<!-- Test dependencies -->
		<dependency>
			<groupId>junit</groupId>
			<artifactId>junit</artifactId>
			<scope>test</scope>
		</dependency>
		<dependency>
			<groupId>org.mockito</groupId>
			<artifactId>mockito-all</artifactId>
			<scope>test</scope>
		</dependency>
		<dependency>
			<groupId>org.apache.cayenne.build-tools</groupId>
			<artifactId>cayenne-test-utilities</artifactId>
			<version>${project.version}</version>
			<scope>test</scope>
		</dependency>
		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-core</artifactId>
			<scope>test</scope>
		</dependency>
		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-mock</artifactId>
			<scope>test</scope>
		</dependency>
		<dependency>
			<groupId>mockrunner</groupId>
			<artifactId>mockrunner</artifactId>
			<scope>test</scope>
		</dependency>
        <dependency>
    		<groupId>org.slf4j</groupId>
    		<artifactId>jcl-over-slf4j</artifactId>
    		<scope>test</scope>
		</dependency>
		<dependency>
    		<groupId>org.slf4j</groupId>
    		<artifactId>slf4j-api</artifactId>
    		<scope>test</scope>
		</dependency>
		<dependency>
    		<groupId>org.slf4j</groupId>
    		<artifactId>slf4j-simple</artifactId>
    		<scope>test</scope>
		</dependency>
		<dependency>
			<groupId>xmlunit</groupId>
			<artifactId>xmlunit</artifactId>
			<version>1.5</version>
			<scope>test</scope>
		</dependency>
	</dependencies>
	<build>
		<resources>
			<resource>
				<directory>src/main/resources</directory>
				<filtering>true</filtering>
			</resource>
		</resources>
		<plugins>
			<!-- This ensures LICENSE and NOTICE inclusion in all jars -->
            <plugin>
                <artifactId>maven-remote-resources-plugin</artifactId>
                <executions>
                    <execution>
                        <goals>
                            <goal>process</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
			<plugin>
				<groupId>org.codehaus.mojo</groupId>
				<artifactId>javacc-maven-plugin</artifactId>
				<version>2.6</version>
				<executions>
					<execution>
						<id>jjtree-ejbql</id>
						<phase>generate-sources</phase>
						<configuration>
							<sourceDirectory>
								${basedir}/src/main/jjtree/org/apache/cayenne/ejbql
							</sourceDirectory>
							<outputDirectory>
								${project.build.directory}/generated-sources/javacc/org/apache/cayenne/ejbql
							</outputDirectory>
							<buildNodeFiles>false</buildNodeFiles>
                            <grammarEncoding>UTF-8</grammarEncoding>
						</configuration>
						<goals>
							<goal>jjtree-javacc</goal>
						</goals>
					</execution>
					<!--
						src/main/jjtree/org/apache/cayenne/exp/parser for now is generated
						outside of Maven with JavaCC command line tools (maybe we should do the same for EJBQL) :
							$ cd cayenne-server/src/main/jjtree/org/apache/cayenne/exp/parser
						# Parser grammar out of tree grammar:
							$ ~/javacc-5.0/bin/jjtree ExpressionParser.jjt
						# Parser java code:
							$ ~/javacc-5.0/bin/javacc ExpressionParser.jj

						# Copy generated classes to src/main/jjtree/org/apache/cayenne/exp/parser
						# except all AST*, Node, SimpleNode, JavaCharStream

						# docs
							$ ./javacc-5.0/bin/jjdoc -TEXT=true ExpressionParser.jj
					-->
				</executions>
			</plugin>
			<plugin>
				<artifactId>maven-antrun-plugin</artifactId>
				<executions>
					<execution>
						<phase>process-sources</phase>
						<configuration>
							<tasks>
								<!-- This will remove duplicate Node file -->
								<delete file="${project.build.directory}/generated-sources/jjtree/org/apache/cayenne/ejbql/parser/Node.java" />
							</tasks>
						</configuration>
						<goals>
							<goal>run</goal>
						</goals>
					</execution>
				</executions>
			</plugin>
			<plugin>
				<artifactId>maven-jar-plugin</artifactId>
				<!-- include OSGi stuff -->
				<configuration>
					<archive>  
						<manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
					</archive> 
				</configuration>
				<!-- share tests with downstream modules -->
				<executions>
					<execution>
						<goals>
							<goal>test-jar</goal>
						</goals>
					</execution>
				</executions>
			</plugin>
			<plugin>
				<groupId>org.apache.felix</groupId>
				<artifactId>maven-bundle-plugin</artifactId>
				<executions>
					<execution>
						<id>bundle-manifest</id>
						<phase>process-classes</phase>
						<goals>
							<goal>manifest</goal>
						</goals>
						<!-- TODO: export package filters. -->
					</execution>
				</executions>
			</plugin>
        </plugins>
	</build>

    <profiles>
        <profile>
            <id>postgres-docker</id>
            <activation>
                <property>
                    <name>cayenneTestConnection</name>
                    <value>postgres-docker</value>
                </property>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <groupId>io.fabric8</groupId>
                        <artifactId>docker-maven-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>start-postgres</id>
                                <phase>pre-integration-test</phase>
                                <goals>
                                    <goal>start</goal>
                                </goals>
                            </execution>
                            <execution>
                                <id>stop-postgres</id>
                                <phase>post-integration-test</phase>
                                <goals>
                                    <goal>stop</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <id>mysql-docker</id>
            <activation>
                <property>
                    <name>cayenneTestConnection</name>
                    <value>mysql-docker</value>
                </property>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <groupId>io.fabric8</groupId>
                        <artifactId>docker-maven-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>start-mysql</id>
                                <phase>pre-integration-test</phase>
                                <goals>
                                    <goal>start</goal>
                                </goals>
                            </execution>
                            <execution>
                                <id>stop-mysql</id>
                                <phase>post-integration-test</phase>
                                <goals>
                                    <goal>stop</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <id>code-quality</id>

            <activation>
                <property>
                    <name>!fast-and-dirty</name>
                </property>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <artifactId>maven-checkstyle-plugin</artifactId>
                        <configuration>
                            <suppressionsLocation>${project.basedir}/cayenne-checkstyle-suppression.xml</suppressionsLocation>
                        </configuration>
                    </plugin>
                    <plugin>
                        <artifactId>maven-pmd-plugin</artifactId>
                        <configuration>
                            <excludes>
                                <exclude>**/ExpressionParserTreeConstants.java</exclude>
                                <exclude>**/JavaCharStream.java</exclude>
                                <exclude>**/JJTExpressionParserState.java</exclude>
                                <exclude>**/ParseException.java</exclude>
                                <exclude>**/Token.java</exclude>
                                <exclude>**/TokenMgrError.java</exclude>
                                <exclude>**/ExpressionParser.java</exclude>
                                <exclude>**/ExpressionParserConstants.java</exclude>
                                <exclude>**/ExpressionParserTokenManager.java</exclude>
                                <exclude>**/SimpleNode.java</exclude>
                                <exclude>**/ParseException.java</exclude>
                                <exclude>**/Parser.java.java</exclude>
                                <exclude>**/ParserConstants.java</exclude>
                                <exclude>**/ParserTokenManager.java</exclude>
                                <exclude>**/SimpleCharStream.java</exclude>
                                <exclude>**/TokenMgrError.java</exclude>
                                <exclude>org/apache/cayenne/ejbql/parser/*</exclude>
                            </excludes>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>
</project>
