maven-常用plugin备忘
来源:互联网 发布:windows phone 10微信 编辑:程序博客网 时间:2024/05/16 09:43
tomcat
<plugin> <groupId>org.apache.tomcat.maven</groupId> <artifactId>tomcat7-maven-plugin</artifactId> <version>2.1</version> <configuration> <path>/device-manager-provider</path> <uriEncoding>utf-8</uriEncoding> <port>8001</port> <server>tomcat</server> <systemProperties> <systemProperty> <name>JAVA_OPTS</name> <value>-Xms256m -Xmx768m -XX:+UseConcMarkSweepGC -XX:MaxPermSize=256m -XX:NewRatio=6 -XX:+CMSClassUnloadingEnabled -XX:+CMSPermGenSweepingEnabled </value> </systemProperty> </systemProperties> </configuration></plugin>
dependency
maven-dependency-plugin是处理与依赖相关的插件。它有很多可用的goal,大部分是和依赖构建、分析和解决相关的goal,这部分goal可以直接用maven的命令操作,例如:mvn dependency:tree、mvn dependency:analyze;这类操作在平时的maven应用中很少会用到。这里主要介绍除此之外的、用得最多的几个操作:copy, copy-dependencies和它们对应的unpack, unpack-dependencies
<plugin> <artifactId>maven-dependency-plugin</artifactId> <executions> <execution> <id>unpack</id> <phase>package</phase> <!--在打包的的生命周期中,绑定unpack goal--> <goals> <goal>unpack</goal> <!--goal 为解压--> </goals> <configuration> <artifactItems> <artifactItem> <!--指定解压的jar包--> <groupId>com.alibaba</groupId> <artifactId>dubbo</artifactId> <version>${project.parent.version}</version> <!--把解压出来的包中的指定文件输出到指定目录,${project.build.directory}默认为target --> <outputDirectory>${project.build.directory}/dubbo</outputDirectory <!--把解压出来的包中的指定文件输出到指定目录--> <includes>META-INF/assembly/**</includes> </artifactItem> </artifactItems> </configuration> </execution> </executions></plugin>
<build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-dependency-plugin</artifactId> <version>2.8</version> <executions> <execution> <phase>package</phase> <!--在打包的生命周期中完成copy的goal--> <goals> <goal>copy</goal> </goals> <configuration> <artifactItems> <!--要copy的内容--> <artifactItem> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>4.11</version> </artifactItem> <artifactItem> <groupId>org.slf4j</groupId> <artifactId>slf4j-log4j12</artifactId> <version>1.7.7</version> <outputDirectory>lib2</outputDirectory> </artifactItem> </artifactItems> <outputDirectory>lib</outputDirectory> </configuration> </execution> </executions> </plugin> </plugins> </build> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-dependency-plugin</artifactId> <version>2.8</version> <executions> <execution> <!--这里没有指定任何配置,所有的参数都用默认值, 则当前工程的所有依赖(直接、间接的)都会被拷到target/dependency目录下> <phase>package</phase> <goals> <goal>copy-dependencies</goal> </goals> </execution> </executions> </plugin> <!--要排除所有camel的依赖--><configuration> <excludeGroupIds>org.apache.camel</excludeGroupIds> </configuration> <!--要排除除camel-spring外的所有其他依赖--> <configuration> <includeArtifactIds>camel-spring</includeArtifactIds> </configuration>
assembly打包
assembly-plugin 打包,把需要打包的jar包,资源都复制到目标文件中,jar包之间不会合并
<plugin> <artifactId>maven-assembly-plugin</artifactId> <!--assembly.xml配置文件路径--> <configuration> <descriptor>src/main/assembly/assembly.xml</descriptor> </configuration> <executions> <execution> <id>make-assembly</id> <phase>package</phase> <goals><goal>single</goal></goals> </execution> </executions></plugin>assembly.xml<assembly><id>assembly</id><formats><format>tar.gz</format></formats><includeBaseDirectory>true</includeBaseDirectory><fileSets><fileSet><!--把target/dubbo/META-INF/assembly/bin 输出到bin 目录--><directory>${project.build.directory}/dubbo/META-INF/assembly/bin</directory><outputDirectory>bin</outputDirectory><fileMode>0755</fileMode></fileSet><fileSet><!--把src/main/assembly/conf 输出到conf 目录--><directory>src/main/assembly/conf</directory><outputDirectory>conf</outputDirectory><fileMode>0644</fileMode></fileSet></fileSets><!--把依赖包输出到lib目录--><dependencySets><dependencySet><outputDirectory>lib</outputDirectory></dependencySet></dependencySets></assembly>发布包到仓库 distributionManagement
pom:
<distributionManagement> <repository> <id>xxx-releases</id> <name>Nexus Release Repository</name> <url>http://192.168.41.25:8081/nexus/content/repositories/releases</url> </repository> <snapshotRepository> <id>xxx-snapshots</id> <name>Nexus Snapshot Repository</name> <url>http://192.168.41.25:8081/nexus/content/repositories/snapshots</url> </snapshotRepository> </distributionManagement>
maven settings.xml<server> <id>xxx-releases</id> <username>deployment</username> <password>xxx</password> </server> <server> <id>xxx-snapshots</id> <username>deployment</username> <password>xxx</password> </server> </servers>maven-shade-plugin 打包
shade-plugin把所有依赖的包,文件都整合到一个jar包中
<plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-shade-plugin</artifactId><version>1.4</version><executions><execution><phase>package</phase><goals><goal>shade</goal></goals><configuration><createSourcesJar>true</createSourcesJar><promoteTransitiveDependencies>true</promoteTransitiveDependencies><artifactSet><!--jar中包含的lib--><includes><include>com.alibaba:hessian-lite</include><include>com.alibaba:dubbo-common</include><include>com.alibaba:dubbo-remoting-api</include><include>com.alibaba:dubbo-remoting-netty</include><include>com.alibaba:dubbo-remoting-mina</include></includes><!--jar中排除的lib--><excludes> <exclude>junit:junit</exclude> <exclude>jmock:*</exclude> <exclude>*:xml-apis</exclude> <exclude>org.apache.maven:lib:tests</exclude> <exclude>log4j:log4j:jar:</exclude></excludes></artifactSet><transformers><!-- 是否生成含有main函数的可执行jar <transformers> <transformer implementation = "org.apache.maven.plugins.shade.resource.MainifestResourceTransformer"> <mainClass>mainclass</mainClass> </transformer> --><!--加入资源文件--><transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer"><resource>META-INF/dubbo/internal/com.alibaba.dubbo.common.compiler.Compiler</resource></transformer><transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer"><resource>META-INF/dubbo/internal/com.alibaba.dubbo.common.extension.ExtensionFactory</resource></transformer></transformers></configuration></execution></executions></plugin>
阅读全文
0 0
- maven-常用plugin备忘
- 备忘-tomcat-maven-plugin的使用
- 备忘-tomcat-maven-plugin的使用
- 备忘-tomcat-maven-plugin的使用
- 一些常用的Maven Plugin配置
- 一些常用的Maven Plugin配置
- Maven零散笔记——常用配置(tomcat-maven-plugin)
- Maven常用插件介绍:Maven-assembly-plugin插件
- Maven配置总结-常用配置(tomcat-maven-plugin)
- Maven Plugin
- maven备忘
- maven appassembler-maven-plugin
- maven:maven-assembly-plugin
- 常用备忘
- maven native2ascii-maven-plugin 例子
- cobertura-maven-plugin插件 maven
- maven搭配android-maven-plugin
- MAVEN ERROR maven-resources-plugin
- 5-10 公路村村通 (Kruskal+并查集)
- java 百钱买百鸡
- 使用notepad++ 安装NppFTP 远程连接Linux
- JAVA排序,从小到大的Vector
- ubuntu下php的编译安装与部署
- maven-常用plugin备忘
- 共享经济其实很“自私”,区块链技术想给它一条出路
- Python6:oriented objective programming
- 使用反射调用一个类的方法
- information_schema中Innodb相关表用于分析sql查询锁的使用情况介绍
- 用Tensorflow实现CNN文本分类(详细解释及TextCNN代码解释)
- 影响相机图像质量的因素-镜头
- leetcode 349. Intersection of Two Arrays-[Java]
- 将properties转换成json格式