栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Java

maven生命周期和分模块开发

Java 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

maven生命周期和分模块开发

生命周期

Maven对项目构建的生命周期划分为3套

clean: 清理工作
default: 核心工作,编译,测试,打包,部署等
site: 产生报告,发布站点等

每个生命周期包含了多个阶段。这些阶段在执行的时候是有固定顺序的。后面的阶段一定要等前面的阶段执行完成后才能被执行。

# clean生命周期
pre-clean: 执行一些需要在clean之前完成的工作
clean: 移除所有上一次构建生成的文件
post-clean: 执行一些需要在clean之后完成的工作
# default生命周期
validate				validate the project is correct and all necessary information is available.
initialize				initialize build state, e.g. set properties or create directories.
generate-sources		generate any source code for inclusion in compilation.
process-sources			process the source code, for example to filter any values.
generate-resources		generate resources for inclusion in the package.
process-resources		copy and process the resources into the destination directory, ready for packaging.
compile					compile the source code of the project.
process-classes			post-process the generated files from compilation, for example to do bytecode enhancement on Java classes.
generate-test-sources	generate any test source code for inclusion in compilation.
process-test-sources	process the test source code, for example to filter any values.
generate-test-resources	create resources for testing.
process-test-resources	copy and process the resources into the test destination directory.
test-compile			compile the test source code into the test destination directory
process-test-classes	post-process the generated files from test compilation, for example to do bytecode enhancement on Java classes.
test					run tests using a suitable unit testing framework. These tests should not require the code be packaged or deployed.
prepare-package			perform any operations necessary to prepare a package before the actual packaging. This often results in an unpacked, processed version of the package.
package					take the compiled code and package it in its distributable format, such as a JAR.
pre-integration-test	perform actions required before integration tests are executed. This may involve things such as setting up the required environment.
integration-test		process and deploy the package if necessary into an environment where integration tests can be run.
post-integration-test	perform actions required after integration tests have been executed. This may including cleaning up the environment.
verify					run any checks to verify the package is valid and meets quality criteria.
install					install the package into the local repository, for use as a dependency in other projects locally.
deploy					done in an integration or release environment, copies the final package to the remote repository for sharing with other developers and projects.
# site生命周期
pre-site		execute processes needed prior to the actual project site generation
site			generate the project's site documentation
post-site		execute processes needed to finalize the site generation, and to prepare for site deployment
site-deploy		deploy the generated site documentation to the specified web server
分模块开发
# 模块的聚合

# 创建一个新的模块,用于构建管理, 该模块中只有pom文件。
# 操作这一个模块(compile,clean,install), 其他模块都跟着联动(compile,clean,install)
pom
# 不写packaging的模块默认打包方式是jar包

# 管理的 模块列表

	module1
	module2

# 模块的继承

# 创建一个新的模块,统一管理资源依赖的版本


	
		
			org.springframework
			spring-context
			5.2.0.RELEASE
		
	

子工程在使用的时候

# 定义该工程的父工程

	
	
	
	# 填写父工程的pom文件路径
	


# 一般子工程和父工程应属于同样的组织Id和版本, 所以填写之后, 子工程的groupId和version可以不写

# 子工程的依赖模块可以不再写版本

	
		org.springframework
		spring-context
	

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/1032784.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号