maven-assembly-plugin

remove jar created by default in maven

旧时模样 提交于 2019-11-29 10:28:42
I am using maven assembly plugin. in my pom.xml, pakaging type: jar and i dont use maven jar plugin. Whenever i run mvn clean package, it create 2 jar files: one is from maven assembly, another one is created by default (due to packaging type =jar). I want to keep only the jar file created by assembly plugin only. How to do that? You may have your reasons but I doubt that it is a good solution to skip the default jar being built and deployed. Anyhow here is how you can disable the default jar being built. <build> <plugins> <plugin> <artifactId>maven-assembly-plugin</artifactId> <version>2.3<

Maven 项目打包需要注意到的那点事儿

老子叫甜甜 提交于 2019-11-29 09:30:34
1. 关于 Maven 打 war 包 对 J2EE 项目打 war 包。其实很简单,你只需要把 pom.xml 中的 <packaging>jar</packaging> 换成 <packaging>war</packaging> 就可以使用 mvn package 命令对其打 war 包了,而不需要添加任何 maven 插件。只要你遵循了 maven 规范 ,那你打成的 war 包就肯定包含了第三方依赖包: 把这个 war 包丢进 tomcat 的 webapps 目录,重启 tomcat 即可完成了该项目的部署。你唯一需要注意的是,在重启 tomcat 之前把你的 war 重命名为 项目访问路径.war。比如作者打成的 war 包是为 swifton-1.0.0.war,对该项目定义的访问路径是 /swifton,那么我在重启 tomcat 之前需要将其重命名为 swifton.war。 2. 可执行程序打 jar 包 关于可执行程序(需要指定一个 main 类)打 jar 包就没这么方便了,我们需要考虑以下几个问题: 配置文件需要打进 jar 包; 需要指定 main 入口类; 所依赖的第三方库也要打进 jar 包; 只有同时满足以上三点,我们才可以直接使用 java -jar swiftonrsa-1.0.0.jar 命令成功执行该程序。 为了让讨论不那么抽象,我们在

How to include external jars in maven jar build process?

岁酱吖の 提交于 2019-11-29 09:12:11
I want to build a .jar file with dependencies in maven. Unfortunately I have to include some external .jars in my buildpath. When I now try to build this project with maven package I will get an error that those external .jars are not found. How to adapt my pom file to add those jars? current: <plugins> <plugin> <artifactId>maven-compiler-plugin</artifactId> <version>2.3.2</version> <configuration> <source>1.6</source> <target>1.6</target> </configuration> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-dependency-plugin</artifactId> <executions> <execution>

Maven. How to include specific folder or file when assemblying project depending on is it dev build or production?

放肆的年华 提交于 2019-11-29 07:09:19
Using maven-assembly-plugin <plugin> <artifactId>maven-assembly-plugin</artifactId> <version>2.1</version> <configuration> <descriptors> <descriptor>descriptor.xml</descriptor> </descriptors> <finalName>xxx-impl-${pom.version}</finalName> <outputDirectory>target/assembly</outputDirectory> <workDirectory>target/assembly/work</workDirectory> </configuration> in descriptor.xml file we can specify <fileSets> <fileSet> <directory>src/install</directory> <outputDirectory>/</outputDirectory> </fileSet> </fileSets> Is it possible to include specific file from this folder or sub-folder depending on

How to exclude dependencies from maven assembly plugin : jar-with-dependencies?

折月煮酒 提交于 2019-11-29 05:22:12
问题 Maven's assembly plugin enables the creation of a big jar including all dependencies with descriptorRef jar-with-dependencies . How can one exclude some of these dependencies? It seems like it does not have such a configuration? Is there another solution? 回答1: This example indicates one way to do this: <dependencySets> <dependencySet> .... <excludes> <exclude>commons-lang:commons-lang</exclude> <exclude>log4j:log4j</exclude> </excludes> </dependencySet> .... </dependencySets> Essentially we

Maven - resource filtering : implications of the @ symbol in resource files

丶灬走出姿态 提交于 2019-11-29 03:23:15
I am using the Maven assembly plugin to prepare some configuration artifacts for different environments, and I am using resource filtering to substitute parameter values. I came across a weird behaviour where I had a property file with the contents as follows: ########################### # author.name@company.com # ############################ env.name=${replacement.value} The presence of the '@' symbol for the author's e-mail was causing all property references to be ignored. I have tried looking for documentation as to why this happens - but cannot find anything that answers this behaviour.

Merge properties files with Maven assembly

旧时模样 提交于 2019-11-29 01:52:10
I have a problem with maven assembly plugin. I have a maven project which use several jars. Each jar contains configuration files. With another project, I use maven assembly plugin to assemble all configurations in unique jar. All work fine but unfortunately, two files are the same name and the second overwrites the first. I don't achieve to tell maven to merge the two files instead of overwrite. Someone knows how to do that ? Thanks. It is not exactly what you are looking for, but I would use http://maven.apache.org/plugins/maven-antrun-plugin/ plugin to run ant concat task http://ant.apache

Maven: Include resources into JAR

删除回忆录丶 提交于 2019-11-28 21:19:19
I have some terrible beaviour. I have the following Maven configuration: <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> <artifactId>Test2Certificate</artifactId> <version>0.1.0-SNAPSHOT</version> <packaging>jar</packaging> <parent> <groupId>com.test</groupId> <artifactId>build</artifactId> <version>1.0.0</version> </parent> <properties> <compile.java.version>1.7</compile.java.version> <file.product

Maven best practice for generating artifacts for multiple environments [prod, test, dev] with CI/Hudson support?

点点圈 提交于 2019-11-28 20:33:53
I have a project that need to be deployed into multiple environments ( prod, test, dev ). The main differences mainly consist in configuration properties/files. My idea was to use profiles and overlays to copy/configure the specialized output. But I'm stuck into if I have to generate multiple artifacts with specialized classifiers (ex: "my-app-1.0-prod.zip/jar", "my-app-1.0-dev.zip/jar") or should I create multiple projects, one project for every environment ?! Should I use maven-assembly-plugin to generate multiple artifacts for every environment ? Anyway, I'll need to generate all them at

Maven: Packaging dependencies alongside project JAR?

痞子三分冷 提交于 2019-11-28 17:11:22
I'd like Maven to package a project alongside its run-time dependencies. I expect it to create a JAR file with the following manifest: ..... Main-Class : com.acme.MainClass Class-Path : lib/dependency1.jar lib/dependency2.jar ..... and create the following directory structure: target |-- .... |-- my-project.jar |-- lib |-- dependency1.jar |-- dependency2.jar Meaning, I want the main JAR to exclude any dependencies and I want all transitive dependencies to get copied into a "lib" sub-directory. Any ideas? I've like Maven to package a project with run-time dependencies. This part is unclear (it