0%
此插件打包为jar,并对MANIFEST.MF作修改:mvn package
:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
| <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-jar-plugin</artifactId> <version>2.4</version> <configuration> <archive> <manifest> <addClasspath>true</addClasspath> <classpathPrefix>lib/</classpathPrefix> <mainClass>com.lwt.test.Test</mainClass> </manifest> <manifestEntries> <Class-Path>conf/</Class-Path> </manifestEntries> </archive> <includes> <include>**/*.class</include> </includes> </configuration> </plugin>
|
将依赖包解压并打包为一个单独jar包的插件:mvn assembly:assembly
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
| <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-assembly-plugin</artifactId> <version>2.2</version> <configuration> <archive> <manifest> <mainClass>com.lwt.test.Test</mainClass> </manifest> </archive> <descriptorRefs> <descriptorRef> jar-with-dependencies </descriptorRef> </descriptorRefs> </configuration> </plugin>
|
打包为jar并生成依赖的目录,里面存放依赖jar:mvn package
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
| <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-jar-plugin</artifactId> <version>2.4</version> <configuration> <archive> <manifest> <addClasspath>true</addClasspath> <classpathPrefix>dependency/</classpathPrefix> <mainClass>com.lwt.test.Test</mainClass> </manifest> </archive> </configuration> </plugin>
<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-dependency-plugin</artifactId> <version>2.10</version> <executions> <execution> <id>copy-dependencies</id> <phase>package</phase> <goals> <goal>copy-dependencies</goal> </goals> </execution> </executions> </plugin>
|
此插件能生成可执行批处理文件:mvn package appassembler:assemble
1 2 3 4 5 6 7 8 9 10 11 12 13
| <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>appassembler-maven-plugin</artifactId> <version>1.10</version> <configuration> <programs> <program> <mainClass>com.lwt.test.Test</mainClass> <id>app</id> </program> </programs> </configuration> </plugin>
|
引用
maven:打包jar的插件