我有多模块项目这是父pom.
<?xml version="1.0" encoding="UTF-8"?>
<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.atoms</groupId>
<artifactId>atoms-parent</artifactId>
<packaging>pom</packaging>
<version>1.0</version>
<url/>
<modules>
<module>atoms-persistence</module>
<module>atoms-reglas</module>
<module>atoms-webservice</module>
</modules>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.5</source>
<target>1.5</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<descriptors>
<descriptor>assemble.xml</descriptor>
</descriptors>
</configuration>
</plugin>
</plugins>
</build>
</project>
Run Code Online (Sandbox Code Playgroud)
在项目atoms-persitence中我有以下文件:
com.atoms.vo.*
com.atoms.service.*
com.atoms.dao.*
在原子 - reglas我有:
com.atoms.rules.*
我如何使用程序集插件来创建一个只包含以下类的jar:
com.atoms.vo.*和com.atoms.rules.*?
我用maven jersey-quickstart-grizzly archetype(来自http://download.java.net/maven/2)开始制作一个简单的REST Jersey应用程序.
如果我用maven命令运行它(mvn compile exec:java),它工作正常; 但如果我制作了一个可执行jar,它会返回以下错误:
11-nov-2011 10.58.33 com.sun.jersey.spi.container.ContainerResponse logException
GRAVE: Mapped exception to response: 500 (Internal Server Error)
javax.ws.rs.WebApplicationException: com.sun.jersey.api.MessageException: A mess
age body writer for Java class java.lang.String, and Java type class java.lang.S
tring, and MIME media type text/plain was not found
Run Code Online (Sandbox Code Playgroud)
我尝试用装配和阴影插件制作jar,在任何一种情况下我都有同样的问题.
我已经google了很多,我发现很多人都有同样的问题,但仍然没有解决方案
在组装期间,我希望将发布目录中的所有文件包含到程序集的根目录中.如果我执行以下操作:
<fileSet>
<directory>${basedir}/</directory>
<outputDirectory>/</outputDirectory>
<includes>
<include>src/main/resources/release/**</include>
</includes>
</fileSet>
Run Code Online (Sandbox Code Playgroud)
然后将所有文件添加到我的发行版中名为src/main/resources/release /的文件夹中.在包含字段时,有没有办法不包含文件夹路径?
我正在使用2.3版本的程序集插件.如果用汇编插件没有办法做到这一点有没有办法用其他插件做到这一点?(最好不要求助于蚂蚁插件).
在我的Maven构建结束时,为此明确目的而存在的一个模块从各种其他模块收集工件,并使用Assembly插件将它们压缩到存档中.完成后,它使用Deploy插件将它们部署到Nexus.
由于历史原因,此包装模块被调用bundle,因此工件最终被调用,因此mygroup:bundle被归类为Nexus.
我宁愿让它们显示在下面mygroup:myprojectname,但我无法弄清楚如何将它们部署到该位置.我已经尝试配置Deploy插件的deploy-file目标来更改坐标,但没有成功.作为一个额外的复杂功能,项目的主代码模块已被调用myprojectname,因此该组在部署时不为空.但是,由于分类器和类型,不需要覆盖任何内容.
没有重命名模块,我能以某种方式这样做吗?
我想使用maven程序集插件程序集
'<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<id>dist</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<descriptors>
<descriptor>src/main/dist.xml</descriptor>
</descriptors>
</configuration>
</execution>
</executions>
</plugin>'
Run Code Online (Sandbox Code Playgroud)
我的描述符文件是:
<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">
<id>dist</id>
<formats>
<format>dir</format>
</formats>
<files>
<file>
<source>pom.xml</source>
<outputDirectory>/ET</outputDirectory>
</file>
</files>
</assembly>
Run Code Online (Sandbox Code Playgroud)
结果是文件夹层次结构是:ET-> MyProject-MySnapshot-dist - > pom.xml
我希望结果是:ET-> pom.xml
我怎么配置它?
我的pom.xml包含以下内容来创建具有所有依赖项的项目的 jar。
现在我有一个src/main/resources运行应用程序所必需的属性文件(我想从 IDE 开始使用它),但我不想将其发送到创建的 jar 文件中,因为设置是单独维护的。
问题:如何获取包含所有依赖项的文件,但排除这些属性文件?
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<id>make-jar</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<archive>
<manifest>
<mainClass>x.Main</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
</execution>
</executions>
</plugin>
Run Code Online (Sandbox Code Playgroud) 我如何在jar文件中包含配置文件夹.假设我有一个服务项目 服务/ src/config/adp/flt/get.flt 配置文件夹中有一个flt文件.所以我想使用maven脚本在services.jar中包含该文件夹我尝试了不同的解决方案复制资源,但它正在目标文件夹上复制该文件夹而不是在services.jar中
maven-2 maven-plugin maven maven-assembly-plugin maven-release-plugin
我需要将一个jar文件重新打包到多个jar的内容中,所以我使用Maven程序集插件将jar解压缩到程序集目录.这是通过一个非常标准的汇编描述符完成的:
<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">
<id>assembly</id>
<formats>
<format>dir</format>
</formats>
<includeBaseDirectory>false</includeBaseDirectory>
<dependencySets>
<dependencySet>
<outputDirectory>lib</outputDirectory>
<unpack>true</unpack>
<unpackOptions>
<excludes>
<exclude>**/dll/**</exclude>
<exclude>**/dylib/**</exclude>
<exclude>**/so/**</exclude>
</excludes>
</unpackOptions>
<scope>runtime</scope>
<useTransitiveDependencies>false</useTransitiveDependencies>
<includes>
<include>com.corp*:*</include>
</includes>
<excludes>
<exclude>com.corp*:*-xb-*</exclude>
<exclude>com.corp*:juniper</exclude>
</excludes>
</dependencySet>
</dependencySets>
<files>
<file>
<source>about.txt</source>
<outputDirectory>/lib</outputDirectory>
<filtered>true</filtered>
</file>
</files>
</assembly>
Run Code Online (Sandbox Code Playgroud)
问题是,如何将整个东西打包到罐子里?我是否需要创建一个新的POM才能重新打包组件的输出?
谢谢
我使用maven-assembly-plugin创建一个更大的zip组件(未压缩占用超过3GB)时遇到问题.构建输出zip文件(压缩小于1GB)时会出现此问题.使用选项运行maven -e为我提供了更详细的信息:
[INFO] Building zip: xxx/HG19-UCSC-dist.zip
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 12:40.199s
[INFO] Finished at: Wed Oct 02 11:08:44 BST 2013
[INFO] Final Memory: 13M/723M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-assembly-plugin:2.2-beta-5:single (make-assembly) on project HG19: Execution make-assembly of goal org.apache.maven.plugins:maven-assembly-plugin:2.2-beta-5:single failed: invalid entry size -> [Help 1]
...
...
...
Caused by: org.apache.maven.plugin.PluginExecutionException: Execution make-assembly of goal org.apache.maven.plugins:maven-assembly-plugin:2.2-beta-5:single failed: invalid entry size
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:115)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
... 19 more
Caused by: java.lang.IllegalArgumentException: …Run Code Online (Sandbox Code Playgroud) 我是maven的新手,它是一门有趣的学科。使用以下命令成功创建具有依赖项的jar:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</configuration>
</plugin>
Run Code Online (Sandbox Code Playgroud)
现在,我必须包括一些shell脚本和生成的jar到tar中。为此,我尝试了以下方法:已添加
<descriptors>
<descriptor>hadoop-job.xml</descriptor>
</descriptors>
Run Code Online (Sandbox Code Playgroud)
以上脚本。
在hadoop-job.xml中,我将所需文件包含到tar中。
问题是tar首先生成,并说在目标中找不到* .jar。因为这两个配置都位于程序集插件中,所以是否有办法先安排jar创建,然后安排tar。还是有一个命令先执行并生成jar,然后再生成tar命令?
顺便说一句,我正在执行mvn clean assembly:assembly -Dbinary = true。帮我解决。谢谢。