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

    The MIT License
    Copyright © 2014-2019 Ilkka Seppälä

    Permission is hereby granted, free of charge, to any person obtaining a copy
    of this software and associated documentation files (the "Software"), to deal
    in the Software without restriction, including without limitation the rights
    to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
    copies of the Software, and to permit persons to whom the Software is
    furnished to do so, subject to the following conditions:

    The above copyright notice and this permission notice shall be included in
    all copies or substantial portions of the Software.

    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
    AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
    LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
    OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
    THE SOFTWARE.

-->
<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>com.iluwatar</groupId>
		<artifactId>naked-objects</artifactId>
		<version>1.23.0-SNAPSHOT</version>
	</parent>

	<artifactId>naked-objects-webapp</artifactId>

	<description>This module runs both the Wicket viewer and the Restfulobjects viewer in a single webapp configured to run using the datanucleus object store.</description>

	<packaging>war</packaging>

	<properties>
		<siteBaseDir>..</siteBaseDir>
	</properties>

	<build>
		<plugins>
			<plugin>
				<groupId>org.mortbay.jetty</groupId>
				<artifactId>maven-jetty-plugin</artifactId>
			</plugin>

			<!-- mvn package -->
			<plugin>
				<groupId>org.simplericity.jettyconsole</groupId>
				<artifactId>jetty-console-maven-plugin</artifactId>
				<executions>
					<execution>
						<goals>
							<goal>createconsole</goal>
						</goals>
						<configuration>
							<backgroundImage>${basedir}/src/main/jettyconsole/isis-banner.png</backgroundImage>
							<destinationFile>${project.build.directory}/${project.build.finalName}-jetty-console.jar</destinationFile>
						</configuration>
						<phase>package</phase>
					</execution>
				</executions>
			</plugin>

			<plugin>
				<groupId>org.codehaus.mojo</groupId>
				<artifactId>build-helper-maven-plugin</artifactId>
				<version>1.8</version>
				<executions>
					<execution>
						<phase>validate</phase>
						<goals>
							<goal>maven-version</goal>
						</goals>
					</execution>
				</executions>
			</plugin>

			<plugin>
				<artifactId>maven-war-plugin</artifactId>
				<configuration>
					<warName>simpleapp</warName>
					<archive>
						<manifest>
							<addClasspath>false</addClasspath>
						</manifest>
						<manifestEntries>
							<Build-Time>${maven.build.timestamp}</Build-Time>
							<Build-Host>${agent.name}</Build-Host>
							<Build-User>${user.name}</Build-User>
							<Build-Maven>Maven ${maven.version}</Build-Maven>
							<Build-Java>${java.version}</Build-Java>
							<Build-OS>${os.name}</Build-OS>
							<Build-Label>${project.version}</Build-Label>
						</manifestEntries>
					</archive>
					<packagingExcludes>WEB-INF/lib/isis-core-webserver*.jar,
						WEB-INF/lib/javax.servlet-api-*.jar,
						WEB-INF/lib/javax.websocket-api-*.jar,
						WEB-INF/lib/jetty-all-*.jar</packagingExcludes>
				</configuration>
			</plugin>

		</plugins>
		<pluginManagement>
			<plugins>
				<!--This plugin's configuration is used to store Eclipse m2e settings 
					only. It has no influence on the Maven build itself. -->
				<plugin>
					<groupId>org.eclipse.m2e</groupId>
					<artifactId>lifecycle-mapping</artifactId>
					<version>1.0.0</version>
					<configuration>
						<lifecycleMappingMetadata>
							<pluginExecutions>
								<pluginExecution>
									<pluginExecutionFilter>
										<groupId>org.codehaus.mojo</groupId>
										<artifactId>build-helper-maven-plugin</artifactId>
										<versionRange>[1.5,)</versionRange>
										<goals>
											<goal>maven-version</goal>
										</goals>
									</pluginExecutionFilter>
									<action>
										<ignore></ignore>
									</action>
								</pluginExecution>
							</pluginExecutions>
						</lifecycleMappingMetadata>
					</configuration>
				</plugin>
			</plugins>
		</pluginManagement>
	</build>

	<dependencies>

		<!-- other modules in this project -->
		<dependency>
			<groupId>${project.groupId}</groupId>
			<artifactId>naked-objects-dom</artifactId>
			<exclusions>
				<exclusion>
					<!-- so don't pick up transitive dependency to asm 4.0.0 -->
					<groupId>org.datanucleus</groupId>
					<artifactId>datanucleus-enhancer</artifactId>
				</exclusion>
			</exclusions>
		</dependency>
		<dependency>
			<groupId>${project.groupId}</groupId>
			<artifactId>naked-objects-fixture</artifactId>
			<exclusions>
				<exclusion>
					<!-- so don't pick up transitive dependency to asm 4.0.0 -->
					<groupId>org.datanucleus</groupId>
					<artifactId>datanucleus-enhancer</artifactId>
				</exclusion>
			</exclusions>
		</dependency>

		<!-- other isis components -->
		<dependency>
			<groupId>org.apache.isis.viewer</groupId>
			<artifactId>isis-viewer-wicket-impl</artifactId>
		</dependency>
		<dependency>
			<groupId>org.apache.isis.core</groupId>
			<artifactId>isis-core-viewer-restfulobjects-server</artifactId>
		</dependency>
		<dependency>
			<groupId>org.apache.isis.core</groupId>
			<artifactId>isis-core-security-shiro</artifactId>
		</dependency>


		<!-- isis core -->
		<dependency>
			<groupId>org.apache.isis.core</groupId>
			<artifactId>isis-core-runtime</artifactId>
		</dependency>
		<dependency>
			<groupId>org.apache.isis.core</groupId>
			<artifactId>isis-core-wrapper</artifactId>
		</dependency>
		<dependency>
			<groupId>org.apache.isis.core</groupId>
			<artifactId>isis-core-security</artifactId>
		</dependency>


		<!-- to run using WebServer (optional) -->
		<dependency>
			<groupId>org.apache.isis.core</groupId>
			<artifactId>isis-core-webserver</artifactId>
			<scope>runtime</scope>
			<optional>true</optional>
		</dependency>


		<dependency>
			<groupId>org.apache.geronimo.specs</groupId>
			<artifactId>geronimo-servlet_3.0_spec</artifactId>
		</dependency>

		<!-- JDBC drivers (for jdo objectstore) -->
		<dependency>
			<groupId>org.hsqldb</groupId>
			<artifactId>hsqldb</artifactId>
		</dependency>

		<dependency>
			<groupId>junit</groupId>
			<artifactId>junit</artifactId>
			<scope>test</scope>
		</dependency>

		<dependency>
			<groupId>org.junit.vintage</groupId>
			<artifactId>junit-vintage-engine</artifactId>
			<scope>test</scope>
		</dependency>
	</dependencies>

	<profiles>
		<profile>
			<id>self-host</id>
			<build>
				<plugins>
					<!-- mvn -P self-host antrun:run -->
					<plugin>
						<groupId>org.apache.maven.plugins</groupId>
						<artifactId>maven-antrun-plugin</artifactId>
						<configuration>
							<tasks>
								<exec executable="java" failonerror="true">
									<arg value="-jar" />
                                    <arg value="${project.build.directory}/${project.build.finalName}-jetty-console.jar" />
								</exec>
							</tasks>
						</configuration>
					</plugin>
				</plugins>
			</build>
		</profile>
		<profile>
			<id>intellij</id>
			<activation>
				<property>
					<name>idea.version</name>
				</property>
			</activation>
			<dependencies>
				<dependency>
					<groupId>org.apache.geronimo.specs</groupId>
					<artifactId>geronimo-servlet_3.0_spec</artifactId>
					<!-- Use 'compile' so can run o.a.i.WebServer from within IntelliJ; 
						can rely on servlet container to ignore this in war file -->
					<scope>compile</scope>
				</dependency>
			</dependencies>
		</profile>
		<profile>
			<id>jrebel</id>
			<properties>
				<!-- as used in the rebel.xml in the dom project -->
				<target.dir>target</target.dir>
				<isis-jrebel-plugin.packagePrefix>dom.simple,org.apache.isis.objectstore.jdo.applib</isis-jrebel-plugin.packagePrefix>
				<isis-jrebel-plugin.loggingLevel>warn</isis-jrebel-plugin.loggingLevel>
			</properties>
			<build>
				<plugins>
					<!-- mvn -P jrebel antrun:run \ -Djrebel.jar="C:/Users/Dan/.IdeaIC13/config/plugins/jr-ide-idea/lib/jrebel/jrebel.jar" 
						\ -Disis_jrebel_plugin.jar="C:/github/danhaywood/isis-jrebel-plugin/target/danhaywood-isis-jrebel-plugin-1.0.0-SNAPSHOT.jar" -->
					<plugin>
						<groupId>org.apache.maven.plugins</groupId>
						<artifactId>maven-antrun-plugin</artifactId>
						<configuration>
							<target>
								<property name="compile_classpath" refid="maven.compile.classpath" />
								<property name="runtime_classpath" refid="maven.runtime.classpath" />
								<property name="test_classpath" refid="maven.test.classpath" />
								<property name="plugin_classpath" refid="maven.plugin.classpath" />

								<echo message="" />
								<echo message="" />
								<echo message="jrebel.jar             = ${jrebel.jar}" />
								<echo message="isis_jrebel_plugin.jar = ${isis_jrebel_plugin.jar}" />
								<echo message="target.dir             = ${target.dir}" />
								<echo message="" />
								<echo message="" />

								<exec executable="java" failonerror="true">
									<arg value="-javaagent:${jrebel.jar}" />
									<arg value="-Drebel.log=false" />
									<arg value="-Drebel.check_class_hash=true" />
									<arg value="-Drebel.packages_exclude=org.apache.isis" />

									<!-- as used in the rebel.xml in the dom project -->
									<arg value="-Dproject.root=${project.basedir}/.." />
									<arg value="-Dtarget.dir=${target.dir}" />

									<arg value="-Drebel.plugins=${isis_jrebel_plugin.jar}" />
                                    <arg value="-Disis-jrebel-plugin.packagePrefix=${isis-jrebel-plugin.packagePrefix}" />
                                    <arg value="-Disis-jrebel-plugin.loggingLevel=${isis-jrebel-plugin.loggingLevel}" />
									<arg value="-XX:MaxPermSize=128m" />
									<arg value="-classpath" />
									<arg value="${runtime_classpath}" />
									<arg value="org.apache.isis.WebServer" />
								</exec>
							</target>
						</configuration>
					</plugin>
				</plugins>
			</build>
		</profile>
	</profiles>


</project>
