I created a new maven project in IntelliJ and set packaging to jar but when I build it, the target folder does not contain a jar. I\'m sure its something really dumb on my p
You should build you project using IDEA's Maven Projects
view.
View -> Tool Windows -> Maven Projects
or open it from left bottom corner menu:
And then build your project with maven goals - i.e. package:
If packaging is set to jar
in pom.xml
, you will get a jar in target
dir.
Assuming that the screen-shot shows the complete pom file, you are missing the entries that define the artifact. Try adding something like this following immediately after the tag:
<modelVersion>4.0.0</modelVersion>
<groupId>com.mycompany.example</groupId>
<artifactId>stackoverflow-question</artifactId>
<version>0.0.1-SNAPSHOT</version>
You should end up with stackoverflow-question-0.0.1-SNAPSHOT.jar in your /target directory. You may need to refresh the directory to see it (You certainly have to in Eclipse)
Go to the maven project and double click clean and package.
For just do following:
You need to have "jar" in packaging section of your pom.xml. You can add this before dependencies section:
<packaging>**jar**</packaging>
Then go to View -> Tool Windows -> Maven and in Maven window expand everything and double click on "package" in Lifecycle section.
You need the maven jar plugin in order to create a jar
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<classpathPrefix>lib/</classpathPrefix>
<mainClass>add your main class</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
https://maven.apache.org/plugins/maven-jar-plugin/