maven 项目构建项目软件包(打包)
2013-08-02 16:19
344 查看
现在在这家公司主要使用的是 maven 构建项目,之前使用的很少。昨天刚刚整理的 maven 使用maven-assembly-plugin 打包的配置文件跟有大家分享一下。
1、pom.xml
2、src/main/assemble/assembly.xml
3、运行
1、生成目录
clean assembly:directory
2、生成目录
clean assembly:assembly
1、pom.xml
<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>com.mttqq.jetty</groupId> <artifactId>jettyserver</artifactId> <version>0.0.1</version> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> </properties> <dependencies> <dependency> <groupId>org.eclipse.jetty</groupId> <artifactId>jetty-server</artifactId> <version>9.0.4.v20130625</version> </dependency> </dependencies> <build> <plugins> <!-- 设置默认程序入口 --> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-jar-plugin</artifactId> <configuration> <archive> <manifest> <addClasspath>true</addClasspath> <classpathPrefix>lib/</classpathPrefix> <mainClass>com.mttqq.boostaup.Launcher</mainClass> </manifest> </archive> </configuration> </plugin> <!-- <plugin> --> <!-- <groupId>org.apache.maven.plugins</groupId> --> <!-- <artifactId>maven-javadoc-plugin</artifactId> --> <!-- <version>2.7</version> --> <!-- <executions> --> <!-- <execution> --> <!-- <id>attach-javadocs</id> --> <!-- <goals> --> <!-- <goal>jar</goal> --> <!-- </goals> --> <!-- </execution> --> <!-- </executions> --> <!-- </plugin> --> <!-- 发布项目 --> <plugin> <artifactId>maven-assembly-plugin</artifactId> <version>2.2-beta-5</version> <configuration> <descriptors> <descriptor>src/main/assemble/assembly.xml</descriptor> </descriptors> </configuration> </plugin> </plugins> </build> </project>
2、src/main/assemble/assembly.xml
<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd"> <!-- 1、“构建项目软件包” (打包) 2、查看更多配置请参考下面地址: http://maven.apache.org/plugins/maven-assembly-plugin/assembly.html 3、项目本配置说明 1、maven本版: apache-maven-3.0.5 http://mirror.bjtu.edu.cn/apache/maven/maven-3/3.0.5/binaries/apache-maven-3.0.5-bin.zip 2、IDE本版: eclipse Kepler Release 注意操作系统的 32位还是 64 位 http://www.eclipse.org/downloads/download.php?file=/technology/epp/downloads/release/kepler/R/eclipse-jee-kepler-R-win32-x86_64.zip --> <!-- 1、文件格式:<artifactId>-<version>-<id>.zip 1.1 <artifactId> 在 pom.xml 文件中又叫 项目名或模块名 1.2 <version> 也存在 pom.xml 文件中本版号 1.3 <id> 就存在文件中, --> <id>bin</id> <!-- 2、输出的后缀名 一般使用的有 jar、zip、tar.gz、tar.bz2 这里的格式名,是为了 适应不能操作系统所准备 --> <formats> <!-- <format>tar.gz</format> --> <!-- <format>tar.bz2</format> --> <format>zip</format> </formats> <!-- 3、导出项目依赖 3.1 将项目依赖导出成 jar 主要设置 unpack : false , 如果设置成 true 导出的依赖文件则为 class 3.2 导出项目依赖文件输出到目录 默认根目录,如果想出到 lib 目录或 ext --> <dependencySets> <dependencySet> <unpack>false</unpack> <scope>runtime</scope> <outputDirectory>/lib</outputDirectory> </dependencySet> </dependencySets> <!-- 4、文件或文件夹设置 4.1 输出文件 本项目基本只有公司内部几个人开发, 主要输出的文件有两类,1、说明文档。2、运行文件 。3、依赖文件 4.2 输出文件夹 输出的文件夹主要是根据你的项目来定。 本项系统主要是打包 web 服务器所以要配置的 目录有 1、web项目文件夹 、如 webapps 2、工作文件夹、如 work 4.3 注意事项 1、设置输入文件夹 <outputDirectory> 主要 2、设置文件夹不排除输出 <useDefaultExcludes>true</useDefaultExcludes> 3、项目文件夹设置 <directory> 这里说明一下, ${project.basedir} 项目下的文件夹 ${project.build.directory} 项目编译后的目录 --> <fileSets> <fileSet> <directory>${project.basedir}</directory> <outputDirectory>/</outputDirectory> <includes> <include>README*</include> <include>LICENSE*</include> <include>NOTICE*</include> </includes> </fileSet> <fileSet> <!-- 项目输入目录 --> <directory>${project.build.directory}</directory> <outputDirectory>/</outputDirectory> <includes> <include>*.jar</include> </includes> </fileSet> <fileSet> <directory>${project.basedir}/webapps</directory> <useDefaultExcludes>true</useDefaultExcludes> </fileSet> <fileSet> <directory>${project.basedir}/work</directory> <useDefaultExcludes>true</useDefaultExcludes> </fileSet> <fileSet> <directory>${project.basedir}/src/main/scripts</directory> <outputDirectory>/</outputDirectory> <includes> <include>startup.bat</include> </includes> <useDefaultExcludes>true</useDefaultExcludes> </fileSet> </fileSets> </assembly>
3、运行
1、生成目录
clean assembly:directory
2、生成目录
clean assembly:assembly
相关文章推荐
- maven用于项目构建和管理。包含创建Project、编译、测试、打包、发布
- IntelliJ IDEA 将 Maven 构建的 Java 项目打包
- IntelliJ IDEA 将 Maven 构建的 Java 项目打包
- 使用IntelliJ IDEA和Maven构建Java web项目并打包部署
- Maven配置和打包以及使用Eclipse构建Maven项目
- maven构建的spring boot项目打包成可执行的jar(fat jar)
- SpringBoot+Maven 多模块项目的构建、运行、打包
- IntelliJ IDEA 将 Maven 构建的 Java 项目打包
- Maven是基于项目对象模型(POM),可以通过一小段描述信息来管理项目的构建,报告和文档的软件项目管理工具。
- maven打包步骤_maven 构建项目
- IntelliJ IDEA 将 Maven 构建的 Java 项目打包
- IntelliJ IDEA 将 Maven 构建的 Java 项目打包
- SpringBoot+Maven 多模块项目的构建、运行、打包实战
- 使用maven构建,打包Java项目完整实例
- 使用Maven构建SSM架构的JavaWeb项目的过程笔记(三):beans.xml
- 构建springmvc+myabtis+dubbo分布式平台-maven构建config配置项目
- 【Maven】使用Maven构建多模块项目《转载》
- eclipse+maven构建web项目——HelloWorld,从构建项目开始学习JavaWeb
- struts2入门 -Idea maven 构建项目
- Maven 项目打包成可执行Jar文件