Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change maven build directory?

Tags:

I have a maven project which I compile with Netbeans. I there a way to specify a different build directory where the compiled binary code is copied after compilation?

like image 965
user1285928 Avatar asked Jul 20 '12 21:07

user1285928


People also ask

What is Maven target directory?

The target directory is used to house all output of the build. The src directory contains all of the source material for building the project, its site and so on. It contains a subdirectory for each type: main for the main build artifact, test for the unit test code and resources, site and so on.

What is project build outputDirectory in Maven?

sourceDirectory , scriptSourceDirectory , and testSourceDirectory provide access to the source directories for the project. outputDirectory and testOutputDirectory provide access to the directories where Maven is going to put bytecode or other build output.

What directory are build artifacts placed in by Maven?

Maven's local repository is a directory on the local machine that stores all the project artifacts. When we execute a Maven build, Maven automatically downloads all the dependency jars into the local repository. Usually, this directory is named . m2.

What is Basedir in POM XML?

basedir : The directory that the current project resides in. This means this points to where your Maven projects resides on your system. It corresponds to the location of the pom. xml file.


2 Answers

Sure. Update your POM with:

<build>   <directory>my_new_build_path</directory> </build> 

Part 2: To specify the output path for a WAR:

<plugin>     <groupId>org.apache.maven.plugins</groupId>     <artifactId>maven-war-plugin</artifactId>     <version>2.0</version>     <configuration>         <warName>test-web-app</warName>         <outputDirectory>my_output_path</outputDirectory>     </configuration> </plugin> 
like image 101
Reimeus Avatar answered Oct 11 '22 23:10

Reimeus


<project>   <build>     <outputDirectory>target/classes</outputDirectory>   </build> </project> 
like image 42
Michał Kalinowski Avatar answered Oct 12 '22 00:10

Michał Kalinowski