<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>
    <artifactId>webswing-server-war</artifactId>
    <packaging>war</packaging>
    <parent>
        <artifactId>webswing-server</artifactId>
        <groupId>org.webswing</groupId>
        <version>20.2.5</version>
        <relativePath>..</relativePath>
    </parent>
    <dependencies>
		<dependency>
            <groupId>org.webswing</groupId>
            <artifactId>webswing-server-api</artifactId>
            <version>${project.parent.version}</version>
        </dependency>
		<dependency>
            <groupId>org.webswing</groupId>
            <artifactId>webswing-sessionpool-api</artifactId>
            <version>${project.parent.version}</version>
            <exclusions>
                <exclusion>
                    <groupId>org.webswing</groupId>
                    <artifactId>modpatch-jdk-jsobject</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.webswing</groupId>
                    <artifactId>modpatch-java-desktop</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
          <groupId>jakarta.servlet</groupId>
          <artifactId>jakarta.servlet-api</artifactId>
          <version>6.0.0</version>
          <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.logging.log4j</groupId>
            <artifactId>log4j-api</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.logging.log4j</groupId>
            <artifactId>log4j-core</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.logging.log4j</groupId>
            <artifactId>log4j-web</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.logging.log4j</groupId>
            <artifactId>log4j-slf4j-impl</artifactId>
        </dependency>
        <dependency>
            <groupId>commons-logging</groupId>
            <artifactId>commons-logging</artifactId>
        </dependency>
    </dependencies>

    <build>
        <finalName>${webswing-war-name}</finalName>
        <plugins>
            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-war-plugin</artifactId>
                <executions>
                    <execution>
                        <id>prepare-war</id>
                        <phase>prepare-package</phase>
                        <goals>
                            <goal>exploded</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <attachClasses>true</attachClasses>
                    <warSourceDirectory>src/main/webapp</warSourceDirectory>
                    <packagingExcludes>**</packagingExcludes>
                    <archive>
                        <manifest>
                            <mainClass>main.Main</mainClass>
                        </manifest>
                        <manifestEntries>
                            <remoteOriginUrl>${git.remote.origin.url}</remoteOriginUrl>
                            <branch>${git.branch}</branch>
                            <version>${project.version}</version>
                            <commitId>${git.commit.id}</commitId>
                            <describe>${git.commit.id.describe}</describe>
                            <commitTime>${git.commit.time}</commitTime>
                            <buildTime>${git.build.time}</buildTime>
                            <Ignore-Scanning-Packages>com,org,net</Ignore-Scanning-Packages><!--prevent classpath scanning in websphere-->
                        </manifestEntries>
                    </archive>
                </configuration>
            </plugin>
            <plugin>
                <artifactId>maven-antrun-plugin</artifactId>
                <executions>
                    <execution>
                        <id>package-server-lib</id>
                        <phase>package</phase>
                        <goals>
                            <goal>run</goal>
                        </goals>
                        <configuration>
                            <target>
                                <copy todir="${project.build.directory}/${project.build.finalName}">
                                    <fileset dir="${project.basedir}/../webswing-server-frontend/target/webswing-server-frontend/" includes="**" />
                                    <fileset dir="${project.basedir}/../webswing-server-common/target/classes/" includes="main/*.class" />
                                    <fileset dir="${project.basedir}/../../webswing-app-services/target" includes="WEB-INF/swing-lib/*.jar" />
                                    <fileset dir="${project.basedir}/../../webswing-app-launcher/target" includes="WEB-INF/swing-boot/*.jar" />
                                    <fileset dir="${project.basedir}/../webswing-server-launcher/target" includes="WEB-INF/server-lib/*.jar" />
                                </copy>
                                <war destfile="${project.build.directory}/${project.build.finalName}.war" update="true">
                                    <fileset dir="${project.build.directory}/${project.build.finalName}" includes="**" />
                                </war>
                            </target>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
			<plugin>
				<artifactId>maven-resources-plugin</artifactId>
				<executions>
					<execution>
						<id>copy-resources</id>
						<phase>validate</phase>
						<goals>
							<goal>copy-resources</goal>
						</goals>
						<configuration>
							<outputDirectory>${basedir}/target</outputDirectory>
							<resources>
								<resource>
									<directory>${basedir}/src/main/resources</directory>
									<include>webswing.properties</include>
								</resource>
							</resources>
						</configuration>
					</execution>
				</executions>
			</plugin>
        </plugins>
    </build>
    <profiles>
        <!-- =========================================DEVELOPMENT JETTY RUN PROFILE=========================== -->
        <profile>
            <id>dev</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.codehaus.mojo</groupId>
                        <artifactId>exec-maven-plugin</artifactId>
                        <executions>
                            <execution>
                                <phase>package</phase>
                                <goals>
                                    <goal>java</goal>
                                </goals>
                            </execution>
                        </executions>
                        <configuration>
                            <mainClass>org.webswing.dev.server.InteractiveServerLauncher</mainClass>
                            <commandlineArgs>-example default-all-apps -j jetty.properties -ctx /webswing-server</commandlineArgs>
                            <!-- use "interactive -example benchmark ... " to select a different default example after startup -->
                            <addOutputToClasspath>false</addOutputToClasspath>
                            <additionalClasspathElements>
                                <additionalClasspathElement>${project.build.directory}/${project.build.finalName}</additionalClasspathElement>
                                <additionalClasspathElement>${project.build.directory}/test-classes</additionalClasspathElement>
                            </additionalClasspathElements>
                            <includeProjectDependencies>false</includeProjectDependencies>
                            <systemProperties>
                                <systemProperty>
                                    <key>webswing.rootDir</key>
                                    <value>${project.basedir}/../../../webswing-examples/webswing-examples-assembly/dist/webswing-examples-distribution/webswing-examples</value>
                                </systemProperty>
                            </systemProperties>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <!-- =========================================RELEASE BUILD PROFILE================================== -->
    </profiles>
</project>
