<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>liquibase</artifactId>
	<name>${project.artifactId}</name>
    <packaging>pom</packaging>
   
    <parent>
        <groupId>fish.focus.uvms.spatial</groupId>
        <artifactId>spatial</artifactId>
        <version>2.2.12</version>
    </parent>

    <profiles>
        <profile>
            <id>postgres</id>
            <activation>
                <activeByDefault>false</activeByDefault>
            </activation>
            <properties>
                <db.driver>org.postgresql.Driver</db.driver>
                <db.url>jdbc:postgresql://localhost:5432/db71u</db.url>
                <db.user>spatial</db.user>
                <db.passwd>spatial</db.passwd>
                <db.defaultSchema>spatial</db.defaultSchema>
                <db.changeLogFile>changelog/db-changelog-master.xml</db.changeLogFile>
                <db.outputFile>changelog/generatedChangelog.xml</db.outputFile>
                <driver.groupId>org.postgresql</driver.groupId>
                <driver.artifactId>postgresql</driver.artifactId>
                <driver.version>42.3.3</driver.version>
            </properties>
			<dependencies>
				<dependency>
					<groupId>${driver.groupId}</groupId>
		            <artifactId>${driver.artifactId}</artifactId>
		            <version>${driver.version}</version>
				</dependency>
			</dependencies>
        </profile>

        <profile>
            <id>exec</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.liquibase</groupId>
                        <artifactId>liquibase-maven-plugin</artifactId>
                        <version>3.10.1</version>
                        <configuration>
                            <promptOnNonLocalDatabase>false</promptOnNonLocalDatabase>
                            <changeLogFile>${db.changeLogFile}</changeLogFile>
                            <driver>${db.driver}</driver>
                            <url>${db.url}</url>
                            <username>${db.user}</username>
                            <password>${db.passwd}</password>
                            <defaultSchemaName>${db.defaultSchema}</defaultSchemaName>
                            <outputChangeLogFile>${db.outputFile}</outputChangeLogFile>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
			<id>publish-sql</id>
			<build>
				<plugins>
					<plugin>
						<groupId>org.liquibase</groupId>
						<artifactId>liquibase-maven-plugin</artifactId>
						<version>3.10.1</version>
						<configuration>
                            <changeLogFile>${db.changeLogFile}</changeLogFile>
							<url>${db.docker.url}</url>
							<migrationSqlOutputFile>${project.build.directory}/full-update.sql</migrationSqlOutputFile>
							<outputFileEncoding>UTF-8</outputFileEncoding>
						</configuration>
						<executions>
							<execution>
								<id>update-schema-sql</id>
								<phase>process-resources</phase>
								<goals>
									<goal>updateSQL</goal>
								</goals>
							</execution>
						</executions>
					</plugin>
					<plugin>
						<groupId>org.codehaus.mojo</groupId>
						<artifactId>build-helper-maven-plugin</artifactId>
						<version>3.3.0</version>
						<executions>
							<execution>
								<id>attach-artifacts</id>
								<phase>process-test-resources</phase>
								<goals>
									<goal>attach-artifact</goal>
								</goals>
								<configuration>
									<artifacts>
										<artifact>
											<file>${project.build.directory}/full-update.sql</file>
											<type>sql</type>
										</artifact>
									</artifacts>
								</configuration>
							</execution>
						</executions>
					</plugin>
				</plugins>
			</build>
			<properties>
				<db.docker.url>offline:postgresql?version=9&amp;changeLogFile=target/databasechangelog.csv&amp;outputLiquibaseSql=true</db.docker.url>
			</properties>
		</profile>                               
    </profiles>
    <build>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.liquibase</groupId>
                    <artifactId>liquibase-maven-plugin</artifactId>
                    <version>3.10.1</version>
                    <configuration>
                        <promptOnNonLocalDatabase>false</promptOnNonLocalDatabase>
                        <changeLogFile>${db.changeLogFile}</changeLogFile>
                        <driver>${db.driver}</driver>
                        <url>${db.url}</url>
                        <username>${db.user}</username>
                        <password>${db.passwd}</password>
                        <defaultSchemaName>${db.defaultSchema}</defaultSchemaName>
                        <outputChangeLogFile>${db.outputFile}</outputChangeLogFile>
                    </configuration>
                    <dependencies>
                        <dependency>
                            <groupId>com.github.lonnyj</groupId>
                            <artifactId>liquibase-spatial</artifactId>
                            <version>1.2.1</version>
                        </dependency>
                    </dependencies>
                </plugin>
            </plugins>
        </pluginManagement>
        <plugins>
        	<plugin>
                    <artifactId>maven-assembly-plugin</artifactId>
                    <version>3.3.0</version>
                    <configuration>
                        <descriptors>
                            <descriptor>assembly.xml</descriptor>
                        </descriptors>
                        <finalName>${project.artifactId}</finalName>
                        <appendAssemblyId>false</appendAssemblyId>
                    </configuration>
                    <executions>
                        <execution>
                            <phase>package</phase>
                            <goals>
                                <goal>single</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>
                <plugin>
                    <artifactId>maven-jar-plugin</artifactId>
                    <executions>
                        <execution>
                            <id>default-jar</id>
                            <!-- put the default-jar in the none phase to skip it from being created -->
                            <phase>none</phase>
                        </execution>
                    </executions>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-deploy-plugin</artifactId>
                    <goals>
                        <goal>deploy-file</goal>
                    </goals>
                    <configuration>
                        <packaging>zip</packaging>
                        <generatePom>true</generatePom>
                        <artifactId>${project.artifactId}</artifactId>
                        <groupId>${project.groupId}</groupId>
                        <version>${project.version}</version>
                        <file>target/liquibase.zip</file>
                    </configuration>
                </plugin>        	
        </plugins>
    </build>
</project>