[java|maven] pom.xml file template

pom.xml file

<?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>
    <groupId>cn.com.xxx.xxx</groupId>
    <artifactId>xxx-xxxx-parent</artifactId>
    <version>1.4.0-xxx</version>
    <packaging>pom</packaging>
    <name>xxx xxx Parent</name>

    <properties>
    	<!--配置变量-->
        <xxx.version>1.4.0-xxxx</xxx.version>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>

	<!--添加子模块-->
    <modules>
        <module>core</module>
        <module>distribution</module>
    </modules>
    
    <!--配置仓库地址-->
    <repositories>
        <repository>
            <id>aliyun</id>
            <name>Aliyun Repository</name>
            <url>http://maven.aliyun.com/repository/central</url>
            <snapshots>
                <enabled>true</enabled>
            </snapshots>
        </repository>
    </repositories>
    
    <!-- 配置发布地址-->
    <distributionManagement>
        <repository>
            <id>xxx</id>
            <name>xxx Releases Repository</name>
            <url>http://repo.xxxx.cn:1111/repository/maven-releases/</url>
        </repository>
    </distributionManagement>

	<!--编译配置-->
    <build>
    	<!--编译插件配置-->
        <plugins>
        	<!--maven编译插件配置-->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.1</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                    <encoding>${source.encoding}</encoding>
                </configuration>
            </plugin>

			<!--tar.gz打包插件-->
			<plugin>
				<artifactId>maven-assembly-plugin</artifactId>
				<version>2.4.1</version>
				<executions>
					<execution>
						<id>bin</id>
						<phase>package</phase>
						<goals>
							<goal>attached</goal>
						</goals>
						<configuration>
							<descriptors>
								<descriptor>src/main/assemblies/bin.xml</descriptor>
							</descriptors>
							<tarLongFileMode>gnu</tarLongFileMode>
						</configuration>
					</execution>
				</executions>
			</plugin>

			<!--脚本执行插件-->
			<plugin>
				<artifactId>exec-maven-plugin</artifactId>
				<version>1.6.0</version>
				<groupId>org.codehaus.mojo</groupId>
				<executions>
					<execution><!-- Run our version calculation script -->
						<id>Create auto runnable package</id>
						<phase>package</phase>
						<goals>
							<goal>exec</goal>
						</goals>
						<configuration>
							<executable>bash</executable>
							<commandlineArgs>src/main/scripts/package.sh ${project.artifactId} ${project.version}</commandlineArgs>
						</configuration>
					</execution>
				</executions>
			</plugin>
        </plugins>
    </build>
</project>

bin.xml

<assembly>
	<id>bin</id>
	<formats>
		<format>tar.gz</format>
	</formats>
	<includeBaseDirectory>true</includeBaseDirectory>
	<fileSets>
		<fileSet>
			<includes>
				<include>conf/**</include>
				<include>lib/**</include>
			</includes>
		</fileSet>
		<fileSet>
			<directory>log</directory>
			<outputDirectory>log</outputDirectory>
		</fileSet>
		<fileSet>
			<directory>bin</directory>
			<outputDirectory>bin</outputDirectory>
			<includes>
				<include>*.sh</include>
			</includes>
			<fileMode>755</fileMode>
		</fileSet>
		<fileSet>
			<directory>../core/src/main/resources</directory>
			<outputDirectory>conf</outputDirectory>
			<includes>
				<include>logback.xml</include>
			</includes>
		</fileSet>
	</fileSets>
	<dependencySets>
		<dependencySet>
			<outputDirectory>lib</outputDirectory>
			<useProjectArtifact>false</useProjectArtifact>
		</dependencySet>
	</dependencySets>
</assembly>

Guess you like

Origin blog.csdn.net/macaiyun0629/article/details/108442130