Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I move maven2 "target" folder to another device?

Tags:

I would really like to make maven write the "target" folder to a different device (ramdisk), which I would normally consider to be a different path. Is there any maven2-compliant way to do this ?

I am trying to solve this problem on windows, and a maven-compliant strategy would be preferred.

like image 695
krosenvold Avatar asked Jun 17 '09 06:06

krosenvold


People also ask

Can we delete target folder in Maven?

To delete the target directory, run mvn clean on your project directly from the command line. That will delete the target directory as expected. In contrast, running Run As > Maven clean from Eclipse for some reason leaves the target directory and subdirectories classes and test-classes.

What does the target folder do?

The target folder is the maven default output folder. When a project is build or packaged, all the content of the sources, resources and web files will be put inside of it, it will be used for construct the artifacts and for run tests.

What is target folder in Maven project?

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 does target folder contain?

A folder, hardcopy or electronic, containing target intelligence and related materials prepared for planning and executing action against a specific target.


2 Answers

If you happen to have all of your projects extending a corporate parent pom, then you could try adding Yet Another Layer of Indirection as follows:

Corporate POM:

<build>   <directory>${my.build.directory}</directory> </build> <properties>   <!-- sensible default -->   <my.build.directory>target</my.build.directory> </properties> 

In your settings.xml:

<properties>   <!-- Personal overridden value, perhaps profile-specific -->   <my.build.directory>/mnt/other/device/${project.groupId}-${project.artifactId}/target</my.build.directory> </properties> 

If the local POM definition takes precedence over the settings.xml definition, then you could try omitting the default value at the cost of having every Maven instance in your control (developers, build machines, etc) specify ${my.build.directory} in its settings.xml.

like image 187
Brian Laframboise Avatar answered Sep 30 '22 03:09

Brian Laframboise


Actually, Maven is not as constrained as everybody thinks, all the POMs are extended of one Super POM in which is defined the name of the target folder

<build>   <directory>target</directory>   <outputDirectory>target/classes</outputDirectory>   <finalName>${artifactId}-${version}</finalName>   <testOutputDirectory>target/test-classes</testOutputDirectory>  .  .  . </build> 

Of course you can overwrite with any value you want, so just go ahead and change the <directory /> element (and other related elements) in your POM

like image 33
victor hugo Avatar answered Sep 30 '22 03:09

victor hugo