Questions tagged [maven-jar-plugin]

This plugin provides the capability to build and sign jars.

The Maven Jar Plugin provides the capability to build and sign jars. This is one of the most common plugins used in Maven.

If the packaging of your project is set to jar, this plugin is executed whenever it passes the package phase, according to default Maven bindings.

Goals Overview

From the official documentation :

  • jar:jar create a jar file for your project sources.
  • jar:test-jar create a jar file for your project test classes.

Check the official usage page for a first look at this plugin.

171 questions
1
vote
0 answers

Custom (self defined) Properties not getting read in the pom file

We want to insert the current git commit hash in our MANIFEST.MF. Unfortunately, we aren´t allowed to use maven-git-commit-id-plugin, so we took the following approach: create a class that reads the commit hash and sets it in a system property run…
1
vote
1 answer

Maven not generating Main Class entry in MANIFEST.MF

I am trying to build a project in Java that should run if executed with double click. That's not been working so I debugged with cmd and there was no main class entry in the manifest. So i added the contents of this answer (adopted to my…
Marvin
  • 129
  • 1
  • 13
1
vote
1 answer

How to stop/prevent maven default goal execution

I have a parent pom which is serving required version number variables of my other components & more importantly "maven-jar-plugin"(version 3.0.2). That same pom is having default profile which will make its multi-module child build a jar. Now the…
Anbu
  • 15
  • 6
1
vote
2 answers

How can I add a file to a classpath but not to a jar with maven?

I want to add some configs to the classpath (generated by maven-jar-plugin), but I don't want them inside a jar, but in an external folder. That way I'll be able to edit configs without repackaging. I found one solution How to add a classpath entry…
MercurieVV
  • 404
  • 6
  • 14
1
vote
1 answer

Replacing variables when packaging the pom.xml into JAR

I have a Java Maven project with several modules. When referencing to the parent module from the individual modules, the following information is added to project A\module-sample-app\pom.xml: org.apache.maven
gautam
  • 21
  • 8
1
vote
2 answers

Maven exec works, but java -jar does not

I have simple maven project with only one dependency. I can install it and run it command-line via Exec Maven Plugin: mvn exec:java -D"exec.mainClass"="com.MyClass" After packaging maven generates a .jar file in my directory. With a help of Maven…
Serob_b
  • 965
  • 12
  • 29
1
vote
0 answers

How to exclude class from default jar but keep it in jar-with-dependencies?

I want to remove class from default jar but keep the same class self-executable jar-with-dependencies. At this setting, its removed class from both jars and I can't include it back in jar-with-dependencies.
1
vote
1 answer

Maven build to include file in root folder of jar

I am using spring boot applications for my project. In one of the project, I need to include one config.properties file in the jar root path. enter image description here Because In my project, one of external jar is expecting this property file…
1
vote
0 answers

Maven - export a jar with a bundled file

I am trying to export a jar with a bundled file (readme.md) via the pom.xml I want the exported jar to look like this: I tried using maven jar plugin as depicted below. However, I get a java file but no readme.md inside it. Here is my…
Hesham Yassin
  • 4,341
  • 2
  • 21
  • 23
1
vote
2 answers

How to use real jar names in manifest classpath using maven-jar-plugin/maven-war-plugin

For some reason my client needs my artifacts without version in their names (MyArtifact.jar instead of MyArtifact-1.23.345.jar) Therefor I added this configuration to my parent pom:
1
vote
1 answer

Is it possible to build a "sub jar" of a Maven project?

I have a situation at the moment where I have: Project A which is built into a fat jar using Maven assembly plugin. Project B which uses the jar built in Project A. It is added to the project as a resource and launched in a separate process using a…
1
vote
0 answers

Maven project in Spring Tool Suite: dependency is not resolved with classifier tag with project opened

I have a Maven Project in Spring Tool Suite, with this simple structure: [parent_project] pom.xml [Module1] pom.xml [Module2] pom.xml I want to make a double version of the Module1 project, so I used the classifier tag…
Alessandro C
  • 3,310
  • 9
  • 46
  • 82
1
vote
1 answer

How to build executable jar using maven-jar-plugin and groovy?

I have an example app with a main class in Groovy and a main class in Java. maven-jar-plugin successfully builds an executable jar when the Java class is specified as the main class but not when the Groovy class is. Let me demonstrate. Here is my…
tytk
  • 2,082
  • 3
  • 27
  • 39
1
vote
1 answer

Is it possible to change (or add) a custom keyed Class-path entry in the Manifest?

While using the maven-jar-plugin: is it possible to create a custom classpath key entry in the Manifest with the same content as Class-Path? e.g. in this case Cluster-Dependencies: Manifest-Version: 1.0 Class-Path: scala-library-2.10.6.jar…
SkyWalker
  • 13,729
  • 18
  • 91
  • 187
1
vote
1 answer

How to disable jar creation in commandline in a maven project?

I have a maven project for which I'm running two separate builds. In one build I want to save the build time by disabling the jar creation of maven modules in it.(There are 45 maven modules). There is a Maven-Jar-Plugin that is being used to create…