Maven 2 assembly with dependencies: jar under scope “system” not included

I’m not surprised that system scope dependencies are not added (after all, dependencies with a system scope must be explicitly provided by definition). Actually, if you really don’t want to put that dependency in your local repository (for example because you want to distribute it as part of your project), this is what I would … Read more

Using maven to output the version number to a text file

Sure. Create a text file somewhere in src/main/resources, call it version.txt (or whatever) File content: ${project.version} now in your pom.xml, inside the build element, put this block: <build> <resources> <resource> <directory>src/main/resources</directory> <filtering>true</filtering> <includes> <include>**/version.txt</include> </includes> </resource> <resource> <directory>src/main/resources</directory> <filtering>false</filtering> <excludes> <exclude>**/version.txt</exclude> </excludes> </resource> … </resources> </build> after every build, the file (which you can find … Read more

Building a fat jar using maven

Note: If you are a spring-boot application, read the end of answer Add following plugin to your pom.xml The latest version can be found at … <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-assembly-plugin</artifactId> <version>CHOOSE LATEST VERSION HERE</version> <configuration> <descriptorRefs> <descriptorRef>jar-with-dependencies</descriptorRef> </descriptorRefs> </configuration> <executions> <execution> <id>assemble-all</id> <phase>package</phase> <goals> <goal>single</goal> </goals> </execution> </executions> </plugin> </plugins> </build> … After configuring … Read more

Is it possible to rename a maven jar-with-dependencies?

You can specify the finalName property to give the jar the name you want, and specify that appendAssemblyId should be false to avoid the “jar-with-dependencies” suffix. The configuration below will output a jar called “test.jar” <plugin> <artifactId>maven-assembly-plugin</artifactId> <version>2.2-beta-4</version> <executions> <execution> <id>jar-with-dependencies</id> <phase>package</phase> <goals> <goal>single</goal> </goals> <configuration> <descriptorRefs> <descriptorRef>jar-with-dependencies</descriptorRef> </descriptorRefs> <finalName>test</finalName> <appendAssemblyId>false</appendAssemblyId> </configuration> </execution> </executions> </plugin> … Read more