<?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>org.springframework.boot</groupId>
		<artifactId>spring-boot-starter-parent</artifactId>
		<version>2.7.8</version>
		<!--<relativePath />--> <!-- lookup parent from repository -->
	</parent>
	<groupId>mbap</groupId>
	<artifactId>mbap-parent</artifactId>
	<version>2.7.8</version>
	<packaging>pom</packaging>

	<!-- 设定统一版本 -->
	<properties>
		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
		<java.version>17</java.version>
		<spring-cloud.version>2021.0.5</spring-cloud.version>
		<spring-boot.version>2.7.8</spring-boot.version>
		<spring-cloud-alibaba.version>2021.0.4.0</spring-cloud-alibaba.version>
		<aspectj.version>1.8.9</aspectj.version>
		<!--docker打包 -->
		<docker.repostory>registry.cn-zhangjiakou.aliyuncs.com</docker.repostory>
		<docker.registry.name>tpccn</docker.registry.name>
		<!-- 私服打包用到的变量 -->
		<nexus.server.id>nexus-release</nexus.server.id>
		<nexus.server.ip>maven.tpccn.com</nexus.server.ip>
		<nexus.release.url>http://${nexus.server.ip}/nexus/content/repositories/mbap</nexus.release.url>
		<!-- 时间 -->
		<timestamp>${maven.build.timestamp}</timestamp>
		<maven.build.timestamp.format>yyyyMMddHHmmss</maven.build.timestamp.format>
		<dockerHost>https://work1:2375</dockerHost>
	</properties>
	<!-- 规定核心业务版本 -->
	<dependencyManagement>
		<dependencies>
			<dependency>
				<groupId>org.springframework.cloud</groupId>
				<artifactId>spring-cloud-dependencies</artifactId>
				<version>${spring-cloud.version}</version>
				<type>pom</type>
				<scope>import</scope>
			</dependency>
			<dependency>
				<groupId>org.springframework.boot</groupId>
				<artifactId>spring-boot-dependencies</artifactId>
				<version>2.7.8</version>
				<type>pom</type>
				<scope>import</scope>
			</dependency>
			<!--spring cloud alibaba -->
			<dependency>
				<groupId>com.alibaba.cloud</groupId>
				<artifactId>spring-cloud-alibaba-dependencies</artifactId>
				<version>${spring-cloud-alibaba.version}</version>
				<type>pom</type>
				<scope>import</scope>
			</dependency>
			<dependency>
				<groupId>org.kie.modules</groupId>
				<artifactId>org-apache-commons-lang3</artifactId>
				<version>6.5.0.Final</version>
				<type>pom</type>
			</dependency>
			<!-- 代码打包加密 -->
			<dependency>
		      <groupId>ant</groupId>
		      <artifactId>ant</artifactId>
		      <version>1.6.5</version>
		    </dependency>
		    <dependency>
		      <groupId>com.google.guava</groupId>
		      <artifactId>guava</artifactId>
		      <version>30.1-jre</version>
		    </dependency>
		    <dependency>
			  <groupId>com.yworks</groupId>
			  <artifactId>yguard</artifactId>
			  <version>3.0.0</version>
			</dependency>
		</dependencies>
	</dependencyManagement>
	<!-- 私服仓库配置 -->
	<distributionManagement>
		<repository>
			<id>${nexus.server.id}</id>
			<url>${nexus.release.url}</url>
		</repository>
	</distributionManagement>
	<repositories>
		<repository>
			<snapshots>
				<enabled>false</enabled>
			</snapshots>
			<id>nexus</id>
			<name>nexus repository</name>
			<url>http://${nexus.server.ip}/nexus/content/groups/public/</url>
		</repository>
	</repositories>
	<pluginRepositories>
		<pluginRepository>
			<releases>
				<updatePolicy>never</updatePolicy>
			</releases>
			<snapshots>
				<enabled>false</enabled>
			</snapshots>
			<id>nexus</id>
			<name>nexus repository</name>
			<url>http://${nexus.server.ip}/nexus/content/groups/public/</url>
		</pluginRepository>
	</pluginRepositories>
	<!-- 工具服务打包命令配置 -->
	<profiles>
		<!-- r2 parent,r2repo,r2zip都依赖 -->
		<profile>
			<activation>
				<property>
					<name>r2parent</name>
					<value>true</value>
				</property>
			</activation>
			<properties>
				<versionId>r${svn.revision}.V${timestamp}</versionId>
			</properties>
			<build>
				<plugins>
					<!-- Use the svn revision number for the built artifact -->
					<plugin>
						<groupId>org.codehaus.mojo</groupId>
						<artifactId>buildnumber-maven-plugin</artifactId>
						<version>1.4</version>
						<executions>
							<execution>
								<phase>validate</phase>
								<goals>
									<goal>create</goal>
								</goals>
							</execution>
						</executions>
						<configuration>
							<buildNumberPropertyName>svn.revision</buildNumberPropertyName>
							<doCheck>false</doCheck>
							<doUpdate>true</doUpdate>
							<providerImplementations>
								<svn>javasvn</svn>
							</providerImplementations>
						</configuration>
						<dependencies>
							<dependency>
								<groupId>com.google.code.maven-scm-provider-svnjava</groupId>
								<artifactId>maven-scm-provider-svnjava</artifactId>
								<version>2.1.2</version>
								<exclusions>
									<exclusion>
										<groupId>org.tmatesoft.svnkit</groupId>
										<artifactId>svnkit</artifactId>
									</exclusion>
								</exclusions>
							</dependency>
						</dependencies>
					</plugin>
					<plugin>
						<groupId>org.apache.maven.plugins</groupId>
						<artifactId>maven-antrun-plugin</artifactId>
						<version>3.1.0</version>
						<executions>
							<execution>
								<id>default-cli</id>
								<phase>package</phase>
								<configuration>
									<target>
										<property name="compile_classpath"
											refid="maven.compile.classpath" />
										<property name="project.build.sourceDirectory"
											value="${project.build.sourceDirectory}" />
										<property name="project.build.directory"
											value="${project.build.directory}" />
										<property name="project.build.outputDirectory"
											value="${project.build.outputDirectory}" />
										<property name="project.build.finalName"
											value="${project.build.finalName}" />
										<property name="project.artifactId"
											value="${project.artifactId}" />
										<property name="svn.revision" value="${svn.revision}" />
										<property name="timestamp" value="${timestamp}" />
										<ant antfile="${ant.build}.xml" />
									</target>
								</configuration>
								<goals>
									<goal>run</goal>
								</goals>
							</execution>
						</executions>
					</plugin>
				</plugins>
			</build>
		</profile>

		<!-- release to local repositories   本地打包命令 -->
		<profile>
			<id>r2repo</id>
			<properties>
				<ant.build>build_obf</ant.build>
			</properties>
			<build>
				<plugins>
					<plugin>
						<groupId>org.apache.maven.plugins</groupId>
						<artifactId>maven-install-plugin</artifactId>
						<version>2.5.2</version>
						<executions>
							<execution>
								<goals>
									<goal>install-file</goal>
								</goals>
								<phase>package</phase>
								<configuration>
									<groupId>${project.groupId}</groupId>
									<artifactId>${project.artifactId}</artifactId>
									<version>${project.version}</version>
									<packaging>jar</packaging>
									<pomFile>${project.basedir}/pom.xml</pomFile>
									<file>${project.build.directory}/${project.build.finalName}.jar</file>
									<javadoc>${project.build.directory}/${project.build.finalName}-javadoc.jar</javadoc>
								</configuration>
							</execution>
						</executions>
					</plugin>
				</plugins>
			</build>
		</profile>

		<!-- release to nexus repositories 打包并提交到nexus私服仓库-->
		<profile>
			<id>r2nexus</id>
			<properties>
				<ant.build>build_r2nexus</ant.build>
			</properties>
			<build>
				<plugins>
					<plugin>
						<groupId>org.apache.maven.plugins</groupId>
						<artifactId>maven-deploy-plugin</artifactId>
						<version>2.8.2</version>
						<executions>
							<execution>
								<goals>
									<goal>deploy-file</goal>
								</goals>
								<phase>package</phase>
								<configuration>
									<repositoryId>${nexus.server.id}</repositoryId>
									<groupId>${project.groupId}</groupId>
									<artifactId>${project.artifactId}</artifactId>
									<version>${project.version}</version>
									<packaging>jar</packaging>
									<pomFile>${project.basedir}/pom.xml</pomFile>
									<file>${project.build.directory}/${project.build.finalName}.jar</file>
									<javadoc>${project.build.directory}/${project.build.finalName}-javadoc.jar</javadoc>
									<url>${nexus.release.url}</url>
								</configuration>
							</execution>
						</executions>
					</plugin>
				</plugins>
			</build>
		</profile>
		<!-- release to zip -->
		<profile>
			<id>r2zip</id>
			<properties>
				<ant.build>build_r2zip</ant.build>
			</properties>
		</profile>
	</profiles>

	<!-- 运行服务打包配置如组织架构模板等需要发布到web的服务 -->
	<build>
		<finalName>${project.name}-${project.version}</finalName>
		<plugins>
			<plugin>
				<artifactId>maven-compiler-plugin</artifactId>
				<configuration>
					<target>${maven.compiler.target}</target>
					<source>${maven.compiler.source}</source>
					<encoding>${project.build.sourceEncoding}</encoding>
				</configuration>
			</plugin>
			<!-- Docker maven plugin -->
			<plugin>
				<groupId>com.spotify</groupId>
				<artifactId>docker-maven-plugin</artifactId>
				<version>1.2.0</version>
				<configuration>
					<!--镜像名称 -->
					<!-- <imageName>${docker.image.prefix}/${project.name}</imageName> -->
					<imageName>${docker.repostory}/${docker.registry.name}/${project.artifactId}:${project.version}</imageName>
					<!-- 指定Dockerfile所在的路径 -->
					<dockerDirectory>src/main/docker</dockerDirectory>

					<!--指定推送的镜像(2375) 192.16.100.37/17 -->
					<dockerHost>${dockerHost}</dockerHost>
					<!-- <dockerHost>http://183.203.212.182:7013</dockerHost> -->
					<dockerCertPath>src/main/docker</dockerCertPath>
					<resources>
						<resource>
							<targetPath>/</targetPath>
							<directory>${project.build.directory}</directory>
							<include>${project.build.finalName}.jar</include>
						</resource>
					</resources>

					<!--推送阿里云相关 -->
					<serverId>docker-aliyun</serverId>
					<!--表示阿里云的docker仓库地址。阿里云的容器镜像服务地址 -->
					<registryUrl>${docker.repostory}</registryUrl>
					<!-- 表示推送镜像到仓库。 -->
					<pushImage>true</pushImage>
				</configuration>
			</plugin>
		</plugins>
	</build>
</project>