Tag : maven

java jar with maven

Create a fat Jar file – Maven Assembly Plugin

In this tutorial, we will show you how to create a fat/uber jar with Maven Assembly Plugin. Which means create a Jar together with its dependency Jars into a single executable Jar file. Note Maven assembly plugin is not good in producing fat/uber jar, it may cause name conflict issue,Continue Reading

log4j logo

Maven – Exclude log4j.properties in Jar file

This example shows you how to use Maven to exclude the log4j.properties file from your Jar file. Note Please, DO NOT include the log4j.properties into the final Jar file, it will cause multiple log4j.properties files in the classpath, if someone is depending on your Jar, you may accidentally override theirContinue Reading

java jar with maven

Maven – Create a fat Jar file – One-JAR example

In this tutorial, we will show you how to use Maven build tool, One-JAR plugin to create a single Jar together with its dependency Jars into a single executable Jar file, so called fat Jar. Tools used : Maven 3.1.1 JDK 1.7 Joda-time 2.5 1. Create a simple Java projectContinue Reading

java jar with maven

Create a fat Jar file – Maven Shade Plugin

In this tutorial, we will show you how to use Maven Shade Plugin to create a Jar together with its dependency Jars into a single executable Jar file, so called fat Jar or uber Jar. Note Maven Shade plugin is a better plugin to create fat/uber jar, if compare withContinue Reading

maven-logo

Maven – Exclude logback.xml in Jar file

This example shows you how to use Maven to exclude the logback.xml file from the final Jar file. Note Please, DO NOT include the logback.xml into the final Jar file, it will cause multiple logback.xml files in the classpath, if someone is using your Jar, you may override other’s loggingContinue Reading

maven-logo

Maven site build is very slow – dependency report

Creating a Maven site, but the build is very slow to generate the dependency report. C:\mkyong_projects\>mvn site [INFO] Scanning for projects… [INFO] [INFO] ————————————– [INFO] Building Maven Webapp 1.0-SNAPSHOT [INFO] ————————————– [INFO] //… [INFO] Generating "Project License" report [INFO] Generating "Project Team" report [INFO] Generating "Project Summary" report [INFO] GeneratingContinue Reading

java_logo_100

Emma – Class x appears to be instrumented already

Review the “maven-emma-plugin” in pom.xml : pom.xml <project> //… <build> <plugins>   <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>emma-maven-plugin</artifactId> <version>1.0-alpha-3</version> <inherited>true</inherited> <executions> <execution> <phase>process-classes</phase> <goals> <goal>instrument</goal> </goals> </execution> </executions> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <inherited>true</inherited> <configuration> <forkMode>once</forkMode> <reportFormat>xml</reportFormat> <classesDirectory> ${project.build.directory}/generated-classes/emma/classes </classesDirectory> </configuration> </plugin>   </plugins> </build> </project> 1. Problem When I run the command mvnContinue Reading

apple-logo

Maven, JAVA_HOME is not defined correctly on Mac OSX

Apple recommends to set JAVA_HOME to “/usr/libexec/java_home“, for example : $ vim .bash_profile   export JAVA_HOME=/usr/libexec/java_home   $ source .bash_profile But, when execute the Maven command, it prompts following error messages : $ mvn -version Error: JAVA_HOME is not defined correctly. We cannot execute /usr/libexec/java_home/bin/java Solution To fixed it, updateContinue Reading

maven-logo

How to create a Web Application Project with Maven

Guide to create a web application with Maven, and add Spring MVC as web framework.

maven-logo

How to create a Java project with Maven

Create a simple Java project from Maven template, and also showing how to compile, run unit test, and package the project into a jar file.

maven-logo

How to create a manifest file with Maven

This tutorial will show you how to use the maven-jar-plugin to create a manifest file, and package / add it into the final jar file. The manifest file is normally used to define following tasks : Define the entry point of the Application, make the Jar executable. Add project dependencyContinue Reading

java jar with maven

How to create a jar file with Maven

In this tutorial, we will show you how to use Maven build tool, to create a single executable Jar, and how to deal with the project’s dependencies. Tools used : Maven 3.1.1 JDK 1.7 log4j 1.2.17 Joda-time 2.5 Eclipse 4.3 1. Create a simple Java project Create a Java projectContinue Reading

maven-logo

Maven plugin – execution order in same phase

In Maven, you can use the build lifecycle or phases to control the order of the plugin execution. In some scenario, you have to bound few plugins to same phase, but still want to control the order of the plugin execution. But, the order is not executed in the sameContinue Reading

maven-logo

How to create user defined properties in Maven

Custom properties or variables are useful to keep your Maven pom.xml file more easy to read and maintain. File : pom.xml <project> … <properties> <my.plugin.version>1.5</my.plugin.version> </properties> … </project> In above pom.xml, you can refer “my.plugin.version” via code ${my.plugin.version}. Example 1 A classic use case is used to define a jarContinue Reading

maven-logo

Eclipse code assist in Maven pom.xml

By default, code assist in editing a pom.xml is NOT supported in Eclipse IDE. It make Maven project hard to maintain, and who will remember who all those tags? Solution You need a pom.xml Maven editor, which is available in m2eclipse plugin. In Eclipse, menu, select “Help” -> “Install NewContinue Reading

Page 1 of 512345