You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by "Björn Michael (Jira)" <ji...@apache.org> on 2023/10/04 09:21:00 UTC
[jira] [Commented] (MNG-6661) Override project.build.directory via user property
[ https://issues.apache.org/jira/browse/MNG-6661?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17771778#comment-17771778 ]
Björn Michael commented on MNG-6661:
------------------------------------
A user property to set {{project.build.directory}} would be very useful.
The existing workarounds via custom profile and self-defined property are described at SO [Maven: How to change path to target directory from command line?|https://stackoverflow.com/a/3908061]
but it requires touching the POM of each project.
On the other hand, a similar user property to override the local maven repository path exists {{-Dmaven.repo.local=/tmp/build-from-scratch}} so why not for the build directory?
h3. Usage examples
* Build tools can specify a different build directory via CLI e.g. Jenkins
* Troubleshooting - create a fresh build in a different directory and compare the outputs of both builds
* User properties can be set via settings.xml i.e. project POM files aren't modified. See below
This should work after introducing the user propery: use a different build directory for Eclipse IDE defined in *settings.xml* (inspired by [jetcd|https://github.com/etcd-io/jetcd/commit/450c0dd9afd154b80db7f37e00c1ff462eb2fdb9#diff-9c5fb3d1b7e3b0f54bc5c4182965c4fe1f9023d449017cece3005d3f90e8e4d8])
{noformat}
<profile>
<id>eclipse-ide</id>
<activation>
<property>
<name>m2e.version</name>
</property>
</activation>
<properties>
<!-- Put the IDE's build output in a folder other than target, so that IDE builds don't interact with Maven builds -->
<maven.buildDir>${project.basedir}/target-eclipse</maven.buildDir>
</properties>
</profile>
{noformat}
> Override project.build.directory via user property
> --------------------------------------------------
>
> Key: MNG-6661
> URL: https://issues.apache.org/jira/browse/MNG-6661
> Project: Maven
> Issue Type: Improvement
> Components: Core
> Reporter: Sergey Ponomarev
> Assignee: Robert Scholte
> Priority: Minor
>
> I would like to improve a build speed of a big project. The project uses a lot of IO operation during a build. So I decided to put all /target directories into RAM disk while keeping sources on a hard drive.
> I mounted a RAM disk to /mnt/ramdisk and created a profile:
> {code:xml}
> <profile>
> <activation>
> <activeByDefault>true</activeByDefault>
> </activation>
> <id>ramDisk</id>
> <properties>
> <project.build.directory>/mnt/ramdisk/${project.groupId}/${project.artifactId}/target</project.build.directory>
> </properties>
> </profile>
> {code}
> In fact this is an equivalent of specifying -Dproject.build.directory
> But unfortunately this doesn't work because the property here (i.e. "user property") is ignored.
> To make it working I should add into pom.xml this:
> {code}
> <build>
> <directory>${project.build.directory}</directory>
> {code}
> I.e. explicitly reuse the user property project.build.directory as configuration.
> Don't be confused, we can call the user property anyhow e.g. ${ram_dir} but I just wan't to reuse existing property.
> I found a ticket that looks similar https://issues.apache.org/jira/browse/MNG-2598 but this is another story.
> So could we implement this?
--
This message was sent by Atlassian Jira
(v8.20.10#820010)