<?xml version="1.0" encoding="UTF-8"?>
<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>com.atlassian.codeindexer</groupId>
        <artifactId>atlassian-codeindexer</artifactId>
        <version>1.0.264</version>
    </parent>

    <artifactId>atlassian-code-indexer-legacy-converter</artifactId>
    <version>1.0.264</version>
    <name>Legacy Converter</name>
    <description>A utility convert indexer's JSON output to the legacy hibernate derived schema</description>

    <properties>
        <querydsl.version>5.1.0</querydsl.version>
    </properties>

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>com.querydsl</groupId>
                <artifactId>querydsl-core</artifactId>
                <version>${querydsl.version}</version>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <dependencies>
        <dependency>
            <groupId>com.atlassian.codeindexer</groupId>
            <artifactId>atlassian-code-indexer-json</artifactId>
            <version>${project.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-jdbc</artifactId>
        </dependency>
        <dependency>
            <groupId>org.ow2.asm</groupId>
            <artifactId>asm</artifactId>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
        </dependency>
        <dependency>
            <groupId>com.google.guava</groupId>
            <artifactId>guava</artifactId>
        </dependency>
        <dependency>
            <groupId>jakarta.inject</groupId>
            <artifactId>jakarta.inject-api</artifactId>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-core</artifactId>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-databind</artifactId>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-annotations</artifactId>
        </dependency>
        <dependency>
            <groupId>org.postgresql</groupId>
            <artifactId>postgresql</artifactId>
        </dependency>
        <dependency>
            <groupId>com.opencsv</groupId>
            <artifactId>opencsv</artifactId>
            <version>5.9</version>
        </dependency>
        <dependency>
            <groupId>com.querydsl</groupId>
            <artifactId>querydsl-sql</artifactId>
            <version>${querydsl.version}</version>
        </dependency>
        <!-- querydsl needs an implementation of the validation API -->
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-validator</artifactId>
            <version>8.0.1.Final</version>
        </dependency>
        <!-- hibernate-validator needs an implementation of el -->
        <dependency>
            <groupId>org.glassfish.web</groupId>
            <artifactId>javax.el</artifactId>
            <version>2.2.6</version>
        </dependency>
        <dependency>
            <groupId>com.atlassian.codeindexer</groupId>
            <artifactId>test-fixtures</artifactId>
            <version>${project.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-api</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.mockito</groupId>
            <artifactId>mockito-core</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.hamcrest</groupId>
            <artifactId>hamcrest-library</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.mockito</groupId>
            <artifactId>mockito-junit-jupiter</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-engine</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <resources>
            <resource>
                <directory>src/main/resources</directory>
                <filtering>true</filtering>
            </resource>
        </resources>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <version>${spring.boot.version}</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>repackage</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <addResources>true</addResources>
                    <mainClass>com.atlassian.codeindexer.legacy.main.Main</mainClass>
                </configuration>
            </plugin>
        </plugins>
    </build>

    <profiles>
        <profile>
            <!-- This profile can be manually run
                    :; mvn -pl legacy-converter -Pgenerate-model generate-sources
                if you need to regenerate the Query DSL classes, assuming that you have a local database codeindex
                with the legacy schema.

                If you do need to do this, be aware that the querydsl-maven-plugin does not normalize the output, so
                expect to see variation around the ordering of foreign key declarations. Also, intellij has a habit
                of removing the unnecessary imports in those files. In practice this isn't too bad, but it does make
                diff based validation of changes that "should be no-ops" harder.
             -->
            <id>generate-model</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>com.querydsl</groupId>
                        <artifactId>querydsl-maven-plugin</artifactId>
                        <version>${querydsl.version}</version>
                        <executions>
                            <execution>
                                <goals>
                                    <goal>export</goal>
                                </goals>
                            </execution>
                        </executions>
                        <configuration>
                            <jdbcDriver>org.postgresql.Driver</jdbcDriver>
                            <jdbcUrl>jdbc:postgresql://localhost:5432/codeindex</jdbcUrl>
                            <jdbcUser>charlie</jdbcUser>
                            <jdbcPassword>charlie</jdbcPassword>
                            <packageName>com.atlassian.codeindexer.legacy.schema</packageName>
                            <targetFolder>${project.basedir}/src/main/java</targetFolder>
                            <tableTypesToExport>TABLE,VIEW,MATERIALIZED VIEW</tableTypesToExport>
                        </configuration>
                        <dependencies>
                            <dependency>
                                <groupId>org.postgresql</groupId>
                                <artifactId>postgresql</artifactId>
                                <version>${postgresql.version}</version>
                            </dependency>
                        </dependencies>
                    </plugin>
                </plugins>
            </build>

        </profile>

    </profiles>
</project>
