Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to place the output jar into another folder with maven?

Tags:

maven

jar

I'd like to place my output jar and jar-with-dependencies into another folder (not in target/ but in ../libs/).

How can I do that?

like image 531
yelo3 Avatar asked Jul 14 '11 06:07

yelo3


People also ask

Where does maven put the jar?

By default, you can find it here: Windows: C:\Users\USERNAME\. m2\repository.


2 Answers

You can use the outputDirectory parameter of the maven-jar-plugin for this purpose:

<project>   ...   <build>     <plugins>       ...       <plugin>         <groupId>org.apache.maven.plugins</groupId>         <artifactId>maven-jar-plugin</artifactId>         <version>2.3.1</version>         <configuration>           <outputDirectory>../libs</outputDirectory>         </configuration>       </plugin>       ...     </plugins>   </build>   ... </project> 

But as cdegroot wrote, you should probably better not fight the maven way.

like image 185
Torsten Avatar answered Sep 21 '22 02:09

Torsten


If you want to copy the artifact into a directory outside your project, solutions might be:

  • maven-jar-plugin and configure outputDirectory
  • maven-antrun-plugin and copy task
  • copy-maven-plugin by Evgeny Goldin

Example for the copy-maven-plugin is:

<plugin>     <groupId>com.github.goldin</groupId>     <artifactId>copy-maven-plugin</artifactId>     <version>0.2.5</version>     <executions>         <execution>             <id>deploy-to-local-directory</id>             <phase>install</phase>             <goals>                 <goal>copy</goal>             </goals>             <configuration>                 <skipIdentical>false</skipIdentical>                 <failIfNotFound>false</failIfNotFound>                 <resources>                     <resource>                         <description>Copy artifact to another directory</description>                         <targetPath>/your/local/path</targetPath>                         <directory>${project.build.directory}</directory>                         <includes>                             <include>*.jar</include>                         </includes>                     </resource>                 </resources>             </configuration>         </execution>     </executions> </plugin> 
like image 28
timomeinen Avatar answered Sep 20 '22 02:09

timomeinen