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.
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.
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.
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.
A folder, hardcopy or electronic, containing target intelligence and related materials prepared for planning and executing action against a specific target.
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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With