rcl*_*rcl 2 java build-automation build-process maven-2
我刚刚开始掌握maven2的设置,同时移植我的一个简单项目.我已经在Sonatype网站上查看了包命令行示例,但我对如何扩展和更改此项目的包装感到有些困惑.我试图找到关于这个主题的更多信息,但我想我或者是在考虑错误的问题,或者是错误的搜索错误.
基本上我想构建一个项目,它将是所有依赖项jar的zip,主jar本身,为方便起见的批处理脚本,以及应用程序的其他各种文件(如属性文件或其他东西).但是,我不希望这些都捆绑到jar中.我想拥有一个项目的压缩归档版本,其中包含所有jar的lib目录,包含属性文件和批处理脚本的根目录以及可能包含额外非必要文件的子文件夹.有一些像:
使用maven2构建这样的项目的正确方法是什么?我是否需要创建一个构建zip的父项目并将子项目作为模块包含在内?这只是一个简单的项目,不需要是多模块的......
建立在matt b的答案上.以下是如何使用引用的插件的一些示例.请注意,执行绑定到集成测试阶段,以确保在尝试打包之前已创建jar.
该appassembler - Maven的插件会生成批处理/ shell文件,下载的依赖关系(在本例中的lib目录),并把所有的内容在目标/ appassembler
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>appassembler-maven-plugin</artifactId>
<version>1.0</version>
<executions>
<execution>
<id>assemble-standalone</id>
<phase>integration-test</phase>
<goals>
<goal>assemble</goal>
<!--if you only want to create the repo and skip script generation,
use this goal instead-->
<!--goal>create-repository</goal-->
</goals>
<configuration>
<programs>
<program>
<mainClass>name.seller.rich.Foo</mainClass>
<name>foo</name>
</program>
</programs>
<platforms>
<platform>windows</platform>
<platform>unix</platform>
</platforms>
<repositoryLayout>flat</repositoryLayout>
<repositoryName>lib</repositoryName>
</configuration>
</execution>
</executions>
</plugin>
Run Code Online (Sandbox Code Playgroud)
该组件的插件可被用于包装appassembler输出到一个zip:
<profiles>
<profile>
<id>archive</id>
<build>
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.2-beta-2</version>
<executions>
<execution>
<phase>integration-test</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<descriptors>
<descriptor>src/main/assembly/archive.xml</descriptor>
</descriptors>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
Run Code Online (Sandbox Code Playgroud)
汇编描述符看起来像这样:
<assembly>
<id>archive</id>
<formats>
<format>zip</format>
</formats>
<fileSets>
<fileSet>
<directory>${project.build.directory}/appassembler</directory>
<outputDirectory>/</outputDirectory>
</fileSet>
</fileSets>
<!-- add any other filesets to include docs, readmes, licences etc here -->
</assembly>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1185 次 |
| 最近记录: |