<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>fish.focus.uvms.user</groupId>
		<artifactId>user</artifactId>
		<version>2.2.3</version>
	</parent>

	<artifactId>liquibase</artifactId>
	<name>liquibase</name>
	<packaging>pom</packaging>
	<properties>
		<liquibase.contexts>default</liquibase.contexts>
		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
		<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
		<liquibase.plugin.version>4.7.1</liquibase.plugin.version>
	</properties>

	<profiles>
		<profile>
			<id>testdata</id>
			<activation>
				<activeByDefault>true</activeByDefault>
			</activation>
			<properties>
				<liquibase.contexts>test</liquibase.contexts>
			</properties>
		</profile>
		<profile>
			<id>local</id>
			<activation>
				<activeByDefault>true</activeByDefault>
			</activation>
			<properties>
				<db.driver>org.postgresql.Driver</db.driver>
				<db.url>jdbc:postgresql://localhost:5432/db71u</db.url>
				<db.user>usm</db.user>
				<db.passwd>usm</db.passwd>
			</properties>
		</profile>
		<profile>
			<id>postgres</id>
			<activation>
				<activeByDefault>true</activeByDefault>
			</activation>
			<properties>
				<db.driver>org.postgresql.Driver</db.driver>
				<db.url>jdbc:postgresql://localhost:5432/db71u</db.url>
				<db.user>usm</db.user>
				<db.passwd>usm</db.passwd>
				<db.defaultSchema>usm</db.defaultSchema>
				<db.changeLogFile>changelog/db-changelog-master.xml</db.changeLogFile>
				<db.outputFile>changelog/generatedChangelog.xml</db.outputFile>
			</properties>
		</profile>
		<profile>
			<id>publish-sql</id>
			<build>
				<plugins>
					<plugin>
						<groupId>org.liquibase</groupId>
						<artifactId>liquibase-maven-plugin</artifactId>
						<version>${liquibase.plugin.version}</version>
						<configuration>
							<url>${db.docker.url}</url>
							<changeLogFile>changelog/db-changelog-master.xml</changeLogFile>
							<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?changeLogFile=target/databasechangelog.csv&amp;outputLiquibaseSql=true</db.docker.url>
			</properties>
		</profile>
	</profiles>
	<dependencies>
		<dependency>
			<groupId>org.postgresql</groupId>
			<artifactId>postgresql</artifactId>
			<version>42.3.3</version>
		</dependency>
	</dependencies>
	<build>
		<pluginManagement>
			<plugins>
				<plugin>
					<groupId>org.liquibase</groupId>
					<artifactId>liquibase-maven-plugin</artifactId>
					<version>${liquibase.plugin.version}</version>
					<configuration>
						<promptOnNonLocalDatabase>false</promptOnNonLocalDatabase>
						<changeLogFile>changelog/db-changelog-master.xml</changeLogFile>
						<driver>${db.driver}</driver>
						<url>${db.url}</url>
						<username>${db.user}</username>
						<password>${db.passwd}</password>
						<contexts>${liquibase.contexts}</contexts>
					</configuration>
				</plugin>
			</plugins>
		</pluginManagement>
		<plugins>
			<plugin>
                <artifactId>maven-assembly-plugin</artifactId>
                <version>3.3.0</version>
                <configuration>
                    <descriptors>assembly.xml</descriptors>
                    <finalName>${project.artifactId}</finalName>
                    <appendAssemblyId>false</appendAssemblyId>
                </configuration>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>single</goal>
                        </goals>
                    </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>