<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements.  See the NOTICE file
distributed with this work for additional information
regarding copyright ownership.  The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License.  You may obtain a copy of the License at

  http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied.  See the License for the
specific language governing permissions and limitations
under the License.
-->
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
		xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

	<parent>
		<groupId>org.apache</groupId>
		<artifactId>apache</artifactId>
		<version>23</version>
	</parent>

	<modelVersion>4.0.0</modelVersion>

	<groupId>io.streamnative.connectors</groupId>
	<artifactId>pulsar-flink-parent</artifactId>
	<version>1.14.3.0</version>

	<name>StreamNative :: Pulsar Flink Connector :: Root</name>
	<packaging>pom</packaging>
	<url>https://pulsar.apache.org</url>
	<inceptionYear>2019</inceptionYear>

	<licenses>
		<license>
			<name>Apache License, Version 2.0</name>
			<url>https://www.apache.org/licenses/LICENSE-2.0.txt</url>
			<distribution>repo</distribution>
		</license>
	</licenses>

	<scm>
		<url>https://github.com/streamnative/pulsar-flink</url>
		<connection>scm:git:https://github.com/streamnative/pulsar-flink.git</connection>
		<developerConnection>scm:git:https://github.com/streamnative/pulsar-flink.git
		</developerConnection>
		<tag>HEAD</tag>
	</scm>

	<issueManagement>
		<system>Github</system>
		<url>https://github.com/streamnative/pulsar-flink/issues</url>
	</issueManagement>

	<developers>
		<developer>
			<organization>StreamNative developers</organization>
			<organizationUrl>https://github.com/streamnative</organizationUrl>
		</developer>
	</developers>

	<modules>
		<module>pulsar-flink-connector</module>
		<module>pulsar-flink-sql-connector</module>
	</modules>

	<properties>
		<!-- Project configuration properties -->
		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
		<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
		<project.scm.id>snbot-github</project.scm.id>
		<target.java.version>1.8</target.java.version>
		<!-- Overwrite default values from parent pom.
			 Intellij is (sometimes?) using those values to choose target language level
			 and thus is changing back to java 1.6 on each maven re-import -->
		<maven.compiler.target>${target.java.version}</maven.compiler.target>
		<maven.compiler.source>${target.java.version}</maven.compiler.source>
		<testRetryCount>3</testRetryCount>

		<!-- Use latest Pulsar version -->
		<pulsar.version>2.8.2</pulsar.version>
		<flink.version>1.14.3</flink.version>
		<lombok.version>1.18.22</lombok.version>
		<!-- Keep track the slf4j version with flink -->
		<slf4j.version>1.7.15</slf4j.version>

		<!-- Protobuf support -->
		<protobuf.version>3.11.4</protobuf.version>
		<flink-protobuf.version>2.7.6</flink-protobuf.version>

		<!-- Default scala versions, must be overwritten by build profiles, so we set something
		invalid here -->
		<scala.version>2.11.12</scala.version>
		<scala.binary.version>2.11</scala.binary.version>

		<checkstyle.version>8.14</checkstyle.version>
		<testcontainers.version>1.16.2</testcontainers.version>
		<jna.version>5.10.0</jna.version>
		<pulsar.systemtest.image>apachepulsar/pulsar:${pulsar.version}</pulsar.systemtest.image>
		<mockito.version>4.0.0</mockito.version>
		<!-- TODO Migrate JUnit from 4 to 5 -->
		<hamcrest.version>1.3</hamcrest.version>
		<junit.version>4.13.2</junit.version>
		<test.unit.pattern>**/*Test.*</test.unit.pattern>

		<!-- Plugin dependencies -->
		<maven.version>3.5.4</maven.version>
		<maven-enforcer-plugin.version>3.0.0</maven-enforcer-plugin.version>
		<xml-maven-plugin.version>1.0.2</xml-maven-plugin.version>
		<directory-maven-plugin.version>1.0</directory-maven-plugin.version>
		<apache-rat-plugin.version>0.13</apache-rat-plugin.version>
		<maven-compiler-plugin.version>3.8.1</maven-compiler-plugin.version>
		<maven-checkstyle-plugin.version>3.1.2</maven-checkstyle-plugin.version>
		<spotless-maven-plugin.version>2.17.4</spotless-maven-plugin.version>
		<spotbugs-maven-plugin.version>4.4.2.2</spotbugs-maven-plugin.version>
		<maven-surefire-plugin.version>3.0.0-M5</maven-surefire-plugin.version>
		<maven-source-plugin.version>3.2.1</maven-source-plugin.version>
		<maven-javadoc-plugin.version>3.3.1</maven-javadoc-plugin.version>
		<maven-gpg-plugin.version>3.0.1</maven-gpg-plugin.version>
		<nexus-staging-maven-plugin.version>1.6.8</nexus-staging-maven-plugin.version>
		<maven-shade-plugin.version>3.2.4</maven-shade-plugin.version>
		<maven-deploy-plugin.version>3.0.0-M1</maven-deploy-plugin.version>
	</properties>

	<dependencyManagement>
		<dependencies>
			<dependency>
				<groupId>org.slf4j</groupId>
				<artifactId>jul-to-slf4j</artifactId>
				<version>${slf4j.version}</version>
			</dependency>
			<dependency>
				<groupId>org.slf4j</groupId>
				<artifactId>slf4j-api</artifactId>
				<version>${slf4j.version}</version>
			</dependency>
			<dependency>
				<groupId>org.apache.pulsar</groupId>
				<artifactId>pulsar-client-all</artifactId>
				<version>${pulsar.version}</version>
				<exclusions>
					<exclusion>
						<groupId>com.sun.activation</groupId>
						<artifactId>javax.activation</artifactId>
					</exclusion>
					<exclusion>
						<groupId>jakarta.activation</groupId>
						<artifactId>jakarta.activation-api</artifactId>
					</exclusion>
					<exclusion>
						<groupId>jakarta.ws.rs</groupId>
						<artifactId>jakarta.ws.rs-api</artifactId>
					</exclusion>
					<exclusion>
						<groupId>jakarta.xml.bind</groupId>
						<artifactId>jakarta.xml.bind-api</artifactId>
					</exclusion>
					<exclusion>
						<groupId>javax.validation</groupId>
						<artifactId>validation-api</artifactId>
					</exclusion>
					<exclusion>
						<groupId>javax.xml.bind</groupId>
						<artifactId>jaxb-api</artifactId>
					</exclusion>
					<exclusion>
						<groupId>net.jcip</groupId>
						<artifactId>jcip-annotations</artifactId>
					</exclusion>
					<exclusion>
						<groupId>org.apache.pulsar</groupId>
						<artifactId>pulsar-package-core</artifactId>
					</exclusion>
				</exclusions>
			</dependency>
		</dependencies>
	</dependencyManagement>

	<!-- dependencies for all modules -->
	<dependencies>
		<dependency>
			<groupId>org.projectlombok</groupId>
			<artifactId>lombok</artifactId>
			<version>${lombok.version}</version>
			<scope>provided</scope>
		</dependency>
		<dependency>
			<groupId>junit</groupId>
			<artifactId>junit</artifactId>
			<version>${junit.version}</version>
			<scope>test</scope>
		</dependency>
		<dependency>
			<groupId>net.java.dev.jna</groupId>
			<artifactId>jna</artifactId>
			<version>${jna.version}</version>
			<scope>test</scope>
		</dependency>
	</dependencies>

	<profiles>
		<profile>
			<id>scala-2.11</id>
			<properties>
				<scala.version>2.11.12</scala.version>
				<scala.binary.version>2.11</scala.binary.version>
			</properties>
			<activation>
				<property>
					<name>!scala-2.12</name>
				</property>
			</activation>
			<build>
				<plugins>
					<!-- make sure we don't have any _2.10 or _2.12 dependencies when building
					for Scala 2.11 -->
					<plugin>
						<artifactId>maven-enforcer-plugin</artifactId>
						<version>${maven-enforcer-plugin.version}</version>
						<executions>
							<execution>
								<id>enforce-versions</id>
								<goals>
									<goal>enforce</goal>
								</goals>
								<configuration>
									<rules>
										<bannedDependencies>
											<excludes combine.children="append">
												<exclude>*:*_2.12</exclude>
												<exclude>*:*_2.10</exclude>
											</excludes>
											<message>Scala 2.10/2.12 dependencies are not allowed for Scala 2.11 builds. This can be caused by hard-coded scala versions, where the 'scala.binary.version' property should be used instead.</message>
										</bannedDependencies>
									</rules>
								</configuration>
							</execution>
						</executions>
					</plugin>
				</plugins>
			</build>
		</profile>

		<profile>
			<id>scala-2.12</id>
			<properties>
				<scala.version>2.12.7</scala.version>
				<scala.binary.version>2.12</scala.binary.version>
			</properties>
			<activation>
				<property>
					<name>scala-2.12</name>
				</property>
			</activation>
			<build>
				<plugins>
					<!-- make sure we don't have any _2.10 or _2.11 dependencies when building
					for Scala 2.12 -->
					<plugin>
						<artifactId>maven-enforcer-plugin</artifactId>
						<version>${maven-enforcer-plugin.version}</version>
						<executions>
							<execution>
								<id>enforce-versions</id>
								<goals>
									<goal>enforce</goal>
								</goals>
								<configuration>
									<rules>
										<bannedDependencies>
											<excludes combine.children="append">
												<exclude>*:*_2.11</exclude>
												<exclude>*:*_2.10</exclude>
											</excludes>
											<message>Scala 2.10/2.11 dependencies are not allowed for Scala 2.12 builds. This can be caused by hard-coded scala versions, where the 'scala.binary.version' property should be used instead.</message>
										</bannedDependencies>
									</rules>
								</configuration>
							</execution>
						</executions>
					</plugin>
					<plugin>
						<artifactId>maven-deploy-plugin</artifactId>
						<version>${maven-deploy-plugin.version}</version>
						<configuration>
							<skip>true</skip>
						</configuration>
					</plugin>
				</plugins>
			</build>
		</profile>

		<profile>
			<id>release</id>
			<build>
				<plugins>
					<plugin>
						<artifactId>maven-source-plugin</artifactId>
						<version>${maven-source-plugin.version}</version>
						<executions>
							<execution>
								<id>attach-sources</id>
								<goals>
									<goal>jar</goal>
								</goals>
							</execution>
						</executions>
					</plugin>
					<plugin>
						<artifactId>maven-javadoc-plugin</artifactId>
						<version>${maven-javadoc-plugin.version}</version>
						<executions>
							<execution>
								<id>attach-javadocs</id>
								<goals>
									<goal>jar</goal>
								</goals>
							</execution>
						</executions>
						<configuration>
							<additionalJOption>-Xdoclint:none</additionalJOption>
						</configuration>
					</plugin>
					<plugin>
						<artifactId>maven-gpg-plugin</artifactId>
						<version>${maven-gpg-plugin.version}</version>
						<executions>
							<execution>
								<id>sign-artifacts</id>
								<phase>verify</phase>
								<goals>
									<goal>sign</goal>
								</goals>
							</execution>
						</executions>
						<configuration>
							<!-- Prevent `gpg` from using pinentry programs -->
							<gpgArguments>
								<arg>--pinentry-mode</arg>
								<arg>loopback</arg>
							</gpgArguments>
						</configuration>
					</plugin>
					<plugin>
						<groupId>org.sonatype.plugins</groupId>
						<artifactId>nexus-staging-maven-plugin</artifactId>
						<version>${nexus-staging-maven-plugin.version}</version>
						<extensions>true</extensions>
						<configuration>
							<serverId>ossrh</serverId>
							<nexusUrl>https://s01.oss.sonatype.org/</nexusUrl>
							<autoReleaseAfterClose>true</autoReleaseAfterClose>
						</configuration>
					</plugin>
				</plugins>
			</build>
		</profile>
	</profiles>

	<build>
		<plugins>
			<!-- Generate root dir path -->
			<plugin>
				<groupId>org.commonjava.maven.plugins</groupId>
				<artifactId>directory-maven-plugin</artifactId>
				<version>0.1</version>
				<executions>
					<execution>
						<id>directories</id>
						<goals>
							<goal>directory-of</goal>
						</goals>
						<phase>initialize</phase>
						<configuration>
							<property>rootDir</property>
							<project>
								<groupId>io.streamnative.connectors</groupId>
								<artifactId>pulsar-flink-parent</artifactId>
							</project>
						</configuration>
					</execution>
				</executions>
			</plugin>

			<plugin>
				<artifactId>maven-compiler-plugin</artifactId>
				<version>${maven-compiler-plugin.version}</version>
				<configuration>
					<source>${maven.compiler.source}</source>
					<target>${maven.compiler.target}</target>
					<compilerArgs>
						<compilerArg>-Xpkginfo:always</compilerArg>
					</compilerArgs>
				</configuration>
			</plugin>

			<plugin>
				<groupId>org.apache.rat</groupId>
				<artifactId>apache-rat-plugin</artifactId>
				<version>${apache-rat-plugin.version}</version>
				<inherited>false</inherited>
				<executions>
					<execution>
						<phase>verify</phase>
						<goals>
							<goal>check</goal>
						</goals>
					</execution>
				</executions>
				<configuration>
					<excludeSubProjects>false</excludeSubProjects>
					<numUnapprovedLicenses>0</numUnapprovedLicenses>
					<licenses>
						<!-- Enforce this license:
							Licensed to the Apache Software Foundation (ASF) under one
							or more contributor license agreements.  See the NOTICE file
							distributed with this work for additional information
							regarding copyright ownership.  The ASF licenses this file
							to you under the Apache License, Version 2.0 (the
							"License"); you may not use this file except in compliance
							with the License.  You may obtain a copy of the License at
							  http://www.apache.org/licenses/LICENSE-2.0
							Unless required by applicable law or agreed to in writing,
							software distributed under the License is distributed on an
							"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
							KIND, either express or implied.  See the License for the
							specific language governing permissions and limitations
							under the License.
						-->
						<license implementation="org.apache.rat.analysis.license.SimplePatternBasedLicense">
							<licenseFamilyCategory>AL2</licenseFamilyCategory>
							<licenseFamilyName>Apache License 2.0</licenseFamilyName>
							<notes/>
							<patterns>
								<pattern>Licensed to the Apache Software Foundation (ASF) under
									one
								</pattern>
							</patterns>
						</license>
					</licenses>
					<licenseFamilies>
						<licenseFamily implementation="org.apache.rat.license.SimpleLicenseFamily">
							<familyName>Apache License 2.0</familyName>
						</licenseFamily>
					</licenseFamilies>
					<excludes>
						<!-- Additional files like .gitignore etc.-->
						<exclude>**/.*/**</exclude>
						<exclude>**/*.prefs</exclude>
						<exclude>**/*.log</exclude>

						<!-- the licenses that are re-bundled -->
						<exclude>LICENSE*</exclude>
						<exclude>**/licenses/LICENSE*</exclude>
						<exclude>**/licenses-binary/LICENSE*</exclude>

						<!-- Test Data. -->
						<exclude>**/src/test/resources/*-data</exclude>

						<!-- Administrative files in the main trunk. -->
						<exclude>**/README.md</exclude>
						<exclude>.github/**</exclude>

						<!-- Build files -->
						<exclude>**/*.iml</exclude>

						<!-- Generated content -->
						<exclude>out/**</exclude>
						<exclude>**/target/**</exclude>
						<exclude>**/scalastyle-output.xml</exclude>
						<exclude>build-target/**</exclude>
						<exclude>docs/**</exclude>

						<!-- Tools: watchdog -->
						<exclude>tools/artifacts/**</exclude>
						<exclude>tools/flink*/**</exclude>

						<!-- Tools: japicmp output -->
						<exclude>tools/japicmp-output/**</exclude>

						<!-- artifacts created during release process -->
						<exclude>tools/releasing/release/**</exclude>

						<!-- manually installed version on travis -->
						<exclude>apache-maven-3.2.5/**</exclude>

						<!-- PyCharm -->
						<exclude>**/.idea/**</exclude>
					</excludes>
				</configuration>
			</plugin>

			<plugin>
				<artifactId>maven-checkstyle-plugin</artifactId>
				<version>${maven-checkstyle-plugin.version}</version>
				<dependencies>
					<dependency>
						<groupId>com.puppycrawl.tools</groupId>
						<artifactId>checkstyle</artifactId>
						<version>${checkstyle.version}</version>
					</dependency>
				</dependencies>
				<executions>
					<execution>
						<id>validate</id>
						<phase>validate</phase>
						<goals>
							<goal>check</goal>
						</goals>
					</execution>
				</executions>
				<configuration>
					<suppressionsLocation>/tools/maven/suppressions.xml</suppressionsLocation>
					<includeTestSourceDirectory>true</includeTestSourceDirectory>
					<configLocation>/tools/maven/checkstyle.xml</configLocation>
					<logViolationsToConsole>true</logViolationsToConsole>
					<failOnViolation>true</failOnViolation>
				</configuration>
			</plugin>

			<plugin>
				<groupId>com.diffplug.spotless</groupId>
				<artifactId>spotless-maven-plugin</artifactId>
				<version>${spotless-maven-plugin.version}</version>
				<configuration>
					<java>
						<googleJavaFormat>
							<version>1.7</version>
							<style>AOSP</style>
						</googleJavaFormat>

						<!-- Refers to the static imports -->
						<importOrder>
							<order>org.apache.flink,org.apache.flink.shaded,,javax,java,scala,\#</order>
						</importOrder>

						<removeUnusedImports />
					</java>
				</configuration>
				<executions>
					<execution>
						<id>spotless-check</id>
						<phase>validate</phase>
						<goals>
							<goal>check</goal>
						</goals>
					</execution>
				</executions>
			</plugin>

			<plugin>
				<groupId>com.github.spotbugs</groupId>
				<artifactId>spotbugs-maven-plugin</artifactId>
				<version>${spotbugs-maven-plugin.version}</version>

				<executions>
					<execution>
						<id>findbugs-run</id>
						<phase>compile</phase>
						<goals>
							<goal>check</goal>
						</goals>
					</execution>
				</executions>

				<configuration>
					<xmlOutput>true</xmlOutput>
					<threshold>Low</threshold>
					<effort>default</effort>
					<spotbugsXmlOutputDirectory>${project.build.directory}/spotbugs</spotbugsXmlOutputDirectory>
					<excludeFilterFile>${rootDir}/tools/maven/spotbugs-exclude.xml</excludeFilterFile>
					<failOnError>true</failOnError>
				</configuration>
			</plugin>

			<plugin>
				<groupId>org.codehaus.mojo</groupId>
				<artifactId>xml-maven-plugin</artifactId>
				<version>${xml-maven-plugin.version}</version>
				<executions>
					<execution>
						<phase>verify</phase>
						<goals>
							<goal>transform</goal>
						</goals>
					</execution>
				</executions>
				<configuration>
					<transformationSets>
						<transformationSet>
							<dir>${project.build.directory}/spotbugs</dir>
							<outputDir>${project.build.directory}/spotbugs</outputDir>
							<!-- A list of available stylesheets can be found here: https://github.com/findbugsproject/findbugs/tree/master/findbugs/src/xsl -->
							<stylesheet>plain.xsl</stylesheet>

							<fileMappers>
								<fileMapper
									implementation="org.codehaus.plexus.components.io.filemappers.FileExtensionMapper">
									<targetExtension>.html</targetExtension>
								</fileMapper>
							</fileMappers>
						</transformationSet>
					</transformationSets>
				</configuration>
				<dependencies>
					<dependency>
						<groupId>com.github.spotbugs</groupId>
						<artifactId>spotbugs-maven-plugin</artifactId>
						<version>${spotbugs-maven-plugin.version}</version>
					</dependency>
				</dependencies>
			</plugin>

			<!-- Surefire for unit tests and integration tests -->
			<plugin>
				<artifactId>maven-surefire-plugin</artifactId>
				<version>${maven-surefire-plugin.version}</version>
				<configuration>
					<trimStackTrace>false</trimStackTrace>
					<systemPropertyVariables>
						<log4j.configuration>file:${project.build.testOutputDirectory}/log4j-tests.properties</log4j.configuration>
						<project.basedir>${project.basedir}</project.basedir>
						<pulsar.systemtest.image>${pulsar.systemtest.image}</pulsar.systemtest.image>
					</systemPropertyVariables>
					<rerunFailingTestsCount>${testRetryCount}</rerunFailingTestsCount>
					<argLine>-Xms256m -Xmx2048m -XX:+UseG1GC</argLine>
				</configuration>
				<executions>
					<!--execute all the unit tests-->
					<execution>
						<id>default-test</id>
						<phase>test</phase>
						<goals>
							<goal>test</goal>
						</goals>
						<configuration>
							<includes>
								<include>${test.unit.pattern}</include>
							</includes>
						</configuration>
					</execution>
					<!--execute all the integration tests-->
					<execution>
						<id>integration-tests</id>
						<phase>integration-test</phase>
						<goals>
							<goal>test</goal>
						</goals>
						<configuration>
							<includes>
								<include>**/*.*</include>
							</includes>
							<excludes>
								<exclude>${test.unit.pattern}</exclude>
							</excludes>
							<reuseForks>false</reuseForks>
						</configuration>
					</execution>
				</executions>
			</plugin>

			<plugin>
				<artifactId>maven-deploy-plugin</artifactId>
				<version>${maven-deploy-plugin.version}</version>
			</plugin>
		</plugins>
	</build>

	<distributionManagement>
		<snapshotRepository>
			<id>ossrh</id>
			<url>https://s01.oss.sonatype.org/content/repositories/snapshots</url>
		</snapshotRepository>
		<repository>
			<id>ossrh</id>
			<url>https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/</url>
		</repository>
	</distributionManagement>
</project>
