Is there a way to pass JVM args via command line to Maven? [duplicate]
Asked Answered
A

1

153

Possible Duplicate:
Maven Jetty plugin - how to control VM arguments?

In particular, I want to do something like this:

mvn -DjvmArgs="-Xmx2000m -Xms1000m -XX:PermSize=512m -XX:MaxPermSize=512m" jetty:run -Pmyprofile

Oh, and I would like to do this without having to modify the pom files or set any environment variables.. etc

Allyson answered 21/9, 2012 at 6:25 Comment(3)
you have to set the MAVEN_OPTS enviroment variable, but that can be done on the command line: MAVEN_OPTS="-Xmx2000m" mvn jetty:runAztec
A little late, but you can use the -DargLine switch rather than using a global value. Full example hereLysin
It's never too late! https://mcmap.net/q/54214/-maven-spring-boot-run-debug-with-argumentsStewartstewed
C
160

I think MAVEN_OPTS would be most appropriate for you. See here: http://maven.apache.org/configure.html

In Unix:

Add the MAVEN_OPTS environment variable to specify JVM properties, e.g. export MAVEN_OPTS="-Xms256m -Xmx512m". This environment variable can be used to supply extra options to Maven.

In Win, you need to set environment variable via the dialogue box

Add ... environment variable by opening up the system properties (WinKey + Pause),... In the same dialog, add the MAVEN_OPTS environment variable in the user variables to specify JVM properties, e.g. the value -Xms256m -Xmx512m. This environment variable can be used to supply extra options to Maven.

Critter answered 21/9, 2012 at 6:32 Comment(9)
Is there a way to configure JVM argument in pom file?Tahsildar
@Tahsildar No, as this would be to late (the JVM would have been started already). But since Maven 3.3.1 you can create a .mvn/jvm.config file with just the options in it.Michaelis
is it possible to give it as runtime argsHorehound
WinKey + Pause how have I never learnt this before?! Very usefulHayrick
Tried this from a bash script but got: MAVEN_OPTS: readonly variableHemicycle
@MartinHöller .mvn/jvm.config only works during the build or when the fork count is zero (use -DforkCount=0 in command line) beauce a forked VM might be used during the tests.Whiteley
I can't make maven use my system certificates on macOS: I'm adding "-Djavax.net.ssl.trustStoreType=KeychainStore" to .mvn/jvm.config without success. Option is from general JVM answer: #14281078Norine
I don't have a pause key on my keyboard.Rolfe
@Rolfe -- this may help: superuser.com/questions/1437617/…Critter

© 2022 - 2024 — McMap. All rights reserved.