ããã¯ããªã«ãããããŠæžãããã®ïŒ
Apache MavenãdaemonãšããŠå®è¡ã§ãããšããMaven Daemonã詊ããŠã¿ããããªãšããããšã§ã
Maven DaemonïŒmvndïŒ
Maven Daemonã®GitHubãªããžããªãŒã¯ãã¡ãã
GitHub - apache/maven-mvnd: Apache Maven Daemon
GradleãTakariã§ç¥ãããŠããæè¡ã䜿ã£ãŠãããé«éãªMavenãã«ããæäŸããããšãç®çãšããŠãããããªã®ã§ããã
This project aims at providing faster Maven builds using techniques known from Gradle and Takari.
Gradleã¯ããŠãããTakariã¯ãªãã§ããã£ãïŒãšæã£ããã§ãããéå»ã«Maven WrapperãéçºããŠãããšããã§ããã
Maven Wrapperã¯ä»ã¯Apacheã«ç§»ã£ãŠããŸãã
Apache Maven Wrapper – Maven Wrapper
ç¹åŸŽãšããŠã¯ä»¥äžã®ããã§ãã
- mvndã³ãã³ãã§å®è¡ããããMavenèªäœã¯çµã¿èŸŒãŸããŠããïŒMavenã®ã€ã³ã¹ããŒã«ã¯äžèŠïŒ
- å®éã®ãã«ãã¯ããã¯ã°ã©ãŠã³ãã§å®è¡ãããdaemonããã»ã¹ã§å®è¡ããã
- ã²ãšã€ã®daemonã€ã³ã¹ã¿ã³ã¹ã§ãmvndã¯ã©ã€ã¢ã³ãããã®é£ç¶ããèŠæ±ãåŠçã§ãã
- mvndã¯GraalVMã§äœããããã€ãã£ãã€ã¡ãŒãž
- ãã«ãã®ãªã¯ãšã¹ãã«å¯ŸããŠã¢ã€ãã«ã®daemonããªãå Žåã¯ãè€æ°ã®daemonã䞊è¡ã§çæå¯èœ
å©ç¹ãšããŠã¯ä»¥äžã®ããã§ãã
- ãã«ãæã®JavaVMèµ·åã®ãªãŒããŒããããåæžã§ãã
- Mavenãã©ã°ã€ã³ããã£ãã·ã¥ãã
- JITã³ã³ãã€ã©ã«ãã£ãŠçæããããã€ãã£ãã³ãŒãããã£ãã·ã¥ãããæšæºã®Mavenãšæ¯èŒãããšJITã³ã³ãã€ã«ã«ãããæéãçããªã
- ç¹°ãè¿ããã«ããããšJITæé©åãããã³ãŒããããåŸãããããã«ãªã
mvnd - the Maven Daemon / Introduction
ãŸããããã©ã«ãã§äžŠåãã«ããè¡ããšãšãã«ã䞊åãã«ãæã®ã³ã³ãœãŒã«åºåãæ¹åããŠããããã§ãã
mvnd - the Maven Daemon / Additional features
OSã¯LinuxãmacOSãWindowsãããã§ã倧äžå€«ãããªæãã§ããã
äœ¿ãæ¹èªäœã¯mvnã³ãã³ããmvndã³ãã³ãã«çœ®ãæããŠäœ¿ãã€ã¡ãŒãžã§ãããã«daemonã®æäœãå ãããŸãã
Maven Daemonåºæã®èšå®ãã¡ã€ã«ãããããã§ããé çœ®å Žæã¯ä»¥äžã§ãããäžã«ããã»ã©åªå 床ãé«ããªããŸãã
- ç°å¢å€æ°
MVND_PROPERTIES_PATHãŸãã¯ã·ã¹ãã ããããã£mvnd.propertiesPathã§æå®ãããã¡ã€ã« - ãããžã§ã¯ãã®ããŒã«ã«èšå®ãã¡ã€ã« âŠ
[PROJECT_HOME]/.mvn/mvnd.properties - ãŠãŒã¶ãŒåäœã®èšå®ãã¡ã€ã« âŠ
[USER_HOME]/.m2/mvnd.properties - ã·ã¹ãã å
šäœã®èšå®ãã¡ã€ã« âŠ
[MVND_HOME]/conf/mvnd.properties
mvnd - the Maven Daemon / Configuration
èšå®é ç®ã¯ãã¡ããåç §ã
https://github.com/apache/maven-mvnd/blob/1.0.1/dist/src/main/distro/conf/mvnd.properties
mvnd.daemonStorageãmvnd.idãmvnd.extClasspathãmvnd.coreExtensionsã¯ç¹æ®ãªããããã£ã§ãmvnd.daemonStorageã®ã¿
ã·ã¹ãã ããããã£ã§èšå®ãã§ããããã§ãã
å人çã«ã¯ããŸãMavenã®å®è¡éåºŠãæ°ã«ãªã£ãããšã¯ãªãã®ã§ããïŒãã¹ãã®å®è¡ãéãããããªã©ã¯ãããããããŸããâŠïŒã
1床詊ããŠãããããªãšããããšã§ã
ç°å¢
ä»åã®ç°å¢ã¯ãã¡ãã
$ java --version openjdk 21.0.3 2024-04-16 OpenJDK Runtime Environment (build 21.0.3+9-Ubuntu-1ubuntu122.04.1) OpenJDK 64-Bit Server VM (build 21.0.3+9-Ubuntu-1ubuntu122.04.1, mixed mode, sharing)
OSã¯Ubuntu Linux 22.04 LTSã§ãã
$ lsb_release -a No LSB modules are available. Distributor ID: Ubuntu Description: Ubuntu 22.04.4 LTS Release: 22.04 Codename: jammy $ uname -srvmpio Linux 5.15.0-113-generic #123-Ubuntu SMP Mon Jun 10 08:16:17 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux
Apache Mavenã¯ã€ã³ã¹ããŒã«äžèŠãšããããšãªã®ã§ãä»åã¯å°å ¥ããŠããŸããã
ãŸãSDKMANã¯å°å ¥æžã¿ãšããŸãã
$ sdk version SDKMAN! script: 5.18.2 native: 0.1.3
Maven DaemonïŒmvndïŒãã€ã³ã¹ããŒã«ãã
ãŸãã¯mvndãã€ã³ã¹ããŒã«ããŸãã
mvnd - the Maven Daemon / How to install mvnd
ã€ã³ã¹ããŒã«æ¹æ³ã¯ããã€ããããŸãã
ãã€ããªãããŠã³ããŒãããå Žåã¯ã以äžããååŸããŸãã
ä»åã¯SDKMANã§ã€ã³ã¹ããŒã«ããŸãã
$ sdk install mvnd
ããŒãžã§ã³ã確èªã
$ mvnd --version Apache Maven Daemon (mvnd) 1.0.1 linux-amd64 native client (621c13a190faf99724130a4dd0b8ec473a9cde44) Terminal: org.jline.terminal.impl.PosixSysTerminal with pty org.jline.terminal.impl.jni.linux.LinuxNativePty Apache Maven 3.9.8 (36645f6c9b5079805ea5009217e36f2cffd34256) Maven home: $HOME/.sdkman/candidates/mvnd/1.0.1/mvn Java version: 21.0.3, vendor: Ubuntu, runtime: /usr/lib/jvm/java-21-openjdk-amd64 Default locale: ja_JP, platform encoding: UTF-8 OS name: "linux", version: "5.15.0-113-generic", arch: "amd64", family: "unix"
Maven Daemon 1.0.1ãã€ã³ã¹ããŒã«ãããŸãããApache Mavenã¯3.9.8ã®ããã§ãã
ã¡ãªã¿ã«ããã®ã³ãã³ããå®è¡ããæç¹ã§Maven Daemonãèµ·åããŠããããŸãããªã®ã§ååã®å®è¡ã¯ã¡ãã£ãšéãã§ãã
$ jcmd -l 35414 jdk.jcmd/sun.tools.jcmd.JCmd -l 35163 org.codehaus.plexus.classworlds.launcher.Launcher
ãããªããã»ã¹ãèµ·åããŠããŸãã
$ ps aux | grep org.codehaus.plexus.classworlds.launcher.Launcher xxxxx 35163 1.6 0.6 7690780 99628 pts/4 Sl 21:10 0:05 /usr/lib/jvm/java-21-openjdk-amd64/bin/java -classpath $HOME/.sdkman/candidates/mvnd/1.0.1/mvn/boot/plexus-classworlds-2.8.0.jar -javaagent:$HOME/.sdkman/candidates/mvnd/1.0.1/mvn/lib/mvnd/mvnd-agent-1.0.1.jar -Dmvnd.home=$HOME/.sdkman/candidates/mvnd/1.0.1 -Dmaven.home=$HOME/.sdkman/candidates/mvnd/1.0.1/mvn -Dmaven.conf=$HOME/.sdkman/candidates/mvnd/1.0.1/mvn/conf -Dclassworlds.conf=$HOME/.sdkman/candidates/mvnd/1.0.1/bin/mvnd-daemon.conf -Dorg.slf4j.simpleLogger.logFile=$HOME/.m2/mvnd/registry/1.0.1/daemon-fc35606d.log -Dmvnd.java.home=/usr/lib/jvm/java-21-openjdk-amd64 -Dmvnd.id=fc35606d -Dmvnd.daemonStorage=$HOME/.m2/mvnd/registry/1.0.1 -Dmvnd.registry=$HOME/.m2/mvnd/registry/1.0.1/registry.bin -Dmvnd.socketFamily=inet -Dmvnd.home=$HOME/.sdkman/candidates/mvnd/1.0.1 -Djdk.java.options=--add-opens java.base/java.io=ALL-UNNAMED --add-opens java.base/java.lang=ALL-UNNAMED --add-opens java.base/java.util=ALL-UNNAMED --add-opens java.base/sun.net.www.protocol.jar=ALL-UNNAMED --add-opens java.base/sun.nio.fs=ALL-UNNAMED -Dmvnd.noDaemon=false -Dmvnd.debug=false -Dmvnd.debug.address=8000 -Dmvnd.idleTimeout=3h -Dmvnd.keepAlive=100ms -Dmvnd.extClasspath= -Dmvnd.coreExtensions= -Dmvnd.enableAssertions=false -Dmvnd.expirationCheckDelay=10s -Dmvnd.duplicateDaemonGracePeriod=10s -Dmvnd.socketFamily=inet org.codehaus.plexus.classworlds.launcher.Launcher xxxxx 35468 0.0 0.0 10320 2416 pts/4 S+ 21:16 0:00 grep --color=auto org.codehaus.plexus.classworlds.launcher.Launcher
ã€ã³ã¹ããŒã«ããããã£ã¬ã¯ããªã®äžèº«ã¯ãã¡ãã確ãã«Apache Mavenãã®ãã®ãå«ãŸããŠããŸãã
$ tree ~/.sdkman/candidates/mvnd/1.0.1
$HOME/.sdkman/candidates/mvnd/1.0.1
âââ LICENSE.txt
âââ NOTICE.txt
âââ README.adoc
âââ bin
â  âââ mvnd
â  âââ mvnd-bash-completion.bash
â  âââ mvnd-client.conf
â  âââ mvnd-daemon.conf
â  âââ mvnd.cmd
â  âââ mvnd.sh
â  âââ platform-linux-amd64
âââ conf
â  âââ mvnd.properties
âââ mvn
âââ LICENSE
âââ NOTICE
âââ README.txt
âââ bin
â  âââ m2.conf
â  âââ mvn
â  âââ mvn.cmd
â  âââ mvnDebug
â  âââ mvnDebug.cmd
â  âââ mvnyjp
âââ boot
â  âââ plexus-classworlds-2.8.0.jar
â  âââ plexus-classworlds.license
âââ conf
â  âââ logging
â  â  âââ java.util.logging.properties
â  â  âââ simplelogger.properties
â  âââ settings.xml
â  âââ toolchains.xml
âââ lib
âââ aopalliance-1.0.jar
âââ aopalliance.license
âââ commons-cli-1.8.0.jar
âââ commons-cli.license
âââ commons-codec-1.16.1.jar
âââ commons-codec.license
âââ ext
â  âââ README.txt
â  âââ hazelcast
â  â  âââ README.txt
â  âââ redisson
â  âââ README.txt
âââ failureaccess-1.0.2.jar
âââ failureaccess.license
âââ guava-33.2.1-jre.jar
âââ guava.license
âââ guice-5.1.0.jar
âââ guice.license
âââ httpclient-4.5.14.jar
âââ httpclient.license
âââ httpcore-4.4.16.jar
âââ httpcore.license
âââ jansi-2.4.1.jar
âââ jansi-native
â  âââ README.txt
â  âââ Windows
â  âââ arm64
â  â  âââ libjansi.so
â  âââ x86
â  â  âââ jansi.dll
â  âââ x86_64
â  âââ jansi.dll
âââ jansi.license
âââ javax.annotation-api-1.3.2.jar
âââ javax.annotation-api.license
âââ javax.inject-1.jar
âââ javax.inject.license
âââ jcl-over-slf4j-1.7.36.jar
âââ jcl-over-slf4j.license
âââ jul-to-slf4j-1.7.36.jar
âââ maven-artifact-3.9.8.jar
âââ maven-builder-support-3.9.8.jar
âââ maven-compat-3.9.8.jar
âââ maven-core-3.9.8.jar
âââ maven-embedder-3.9.8.jar
âââ maven-model-3.9.8.jar
âââ maven-model-builder-3.9.8.jar
âââ maven-plugin-api-3.9.8.jar
âââ maven-repository-metadata-3.9.8.jar
âââ maven-resolver-api-1.9.20.jar
âââ maven-resolver-connector-basic-1.9.20.jar
âââ maven-resolver-impl-1.9.20.jar
âââ maven-resolver-named-locks-1.9.20.jar
âââ maven-resolver-provider-3.9.8.jar
âââ maven-resolver-spi-1.9.20.jar
âââ maven-resolver-transport-file-1.9.20.jar
âââ maven-resolver-transport-http-1.9.20.jar
âââ maven-resolver-transport-wagon-1.9.20.jar
âââ maven-resolver-util-1.9.20.jar
âââ maven-settings-3.9.8.jar
âââ maven-settings-builder-3.9.8.jar
âââ maven-shared-utils-3.4.2.jar
âââ mvnd
â  âââ jline-native-3.26.2.jar
â  âââ jline-terminal-3.26.2.jar
â  âââ jline-terminal-ffm-3.26.2.jar
â  âââ jline-terminal-jni-3.26.2.jar
â  âââ mvnd-agent-1.0.1.jar
â  âââ mvnd-client-1.0.1.jar
â  âââ mvnd-common-1.0.1.jar
â  âââ mvnd-daemon-1.0.1.jar
â  âââ mvnd-helper-agent-1.0.1.jar
â  âââ mvnd-native-1.0.1.jar
â  âââ plexus-interactivity-api-1.3.jar
â  âââ takari-smart-builder-0.6.6.jar
âââ mvnd-logging-1.0.1.jar
âââ org.eclipse.sisu.inject-0.9.0.M3.jar
âââ org.eclipse.sisu.inject.license
âââ org.eclipse.sisu.plexus-0.9.0.M3.jar
âââ org.eclipse.sisu.plexus.license
âââ plexus-cipher-2.0.jar
âââ plexus-cipher.license
âââ plexus-component-annotations-2.1.0.jar
âââ plexus-component-annotations.license
âââ plexus-interpolation-1.27.jar
âââ plexus-interpolation.license
âââ plexus-sec-dispatcher-2.0.jar
âââ plexus-sec-dispatcher.license
âââ plexus-utils-3.5.1.jar
âââ plexus-utils.license
âââ plexus-xml-3.0.0.jar
âââ plexus-xml.license
âââ slf4j-api-1.7.36.jar
âââ slf4j-api.license
âââ wagon-file-3.5.3.jar
âââ wagon-http-3.5.3.jar
âââ wagon-http-shared-3.5.3.jar
âââ wagon-provider-api-3.5.3.jar
17 directories, 115 files
Maven Daemonåºæã®æäœãè¡ã£ãŠã¿ã
æåã«Maven Daemonåºæã®æäœãèŒããŠãããŸãã
mvnd --statusã§ãçŸåšèµ·åããŠããMaven Daemonã®äžèЧã衚瀺ããŸãã
$ mvnd --status
ID PID Address Status RSS Last activity Java home
fc35606d 35163 inet:/127.0.0.1:43263 Idle 98m 2024-07-13T21:10:50.652 /usr/lib/jvm/java-21-openjdk-amd64
mvnd --stopã§ãçŸåšèµ·åããŠããMaven Daemonããã¹ãŠåæ¢ããŸãã
$ mvnd --stop Stopping 1 running daemons
mvnd --helpã§ããã«ãã®è¡šç€ºã§ããApache Mavenã®ãã«ãã«å ããŠãMaven Daemonåºæã®å
容ãåºåãããŠããŸãã
$ mvnd --help
usage: mvnd [options] [<goal(s)>] [<phase(s)>]
Options:
-am,--also-make If project list is specified, also build projects required by the list
-amd,--also-make-dependents If project list is specified, also build projects that depend on projects on the list
-B,--batch-mode Run in non-interactive (batch) mode (disables output color)
-b,--builder <arg> The id of the build strategy to use
-C,--strict-checksums Fail the build if checksums don't match
-c,--lax-checksums Warn if checksums don't match
--color <arg> Defines the color mode of the output. Supported are 'auto', 'always', 'never'.
-cpu,--check-plugin-updates Ineffective, only kept for backward compatibility
-D,--define <arg> Define a user property
-e,--errors Produce execution error messages
-emp,--encrypt-master-password <arg> Encrypt master security password
-ep,--encrypt-password <arg> Encrypt server password
-f,--file <arg> Force the use of an alternate POM file (or directory with pom.xml)
-fae,--fail-at-end Only fail the build afterwards; allow all non-impacted builds to continue
-ff,--fail-fast Stop at first failure in reactorized builds
-fn,--fail-never NEVER fail the build, regardless of project result
-gs,--global-settings <arg> Alternate path for the global settings file
-gt,--global-toolchains <arg> Alternate path for the global toolchains file
-h,--help Display help information
-itr,--ignore-transitive-repositories If set, Maven will ignore remote repositories introduced by transitive dependencies.
-l,--log-file <arg> Log file where all build output will go (disables output color)
-llr,--legacy-local-repository UNSUPPORTED: Use of this option will make Maven invocation fail.
-N,--non-recursive Do not recurse into sub-projects
-npr,--no-plugin-registry Ineffective, only kept for backward compatibility
-npu,--no-plugin-updates Ineffective, only kept for backward compatibility
-nsu,--no-snapshot-updates Suppress SNAPSHOT updates
-ntp,--no-transfer-progress Do not display transfer progress when downloading or uploading
-o,--offline Work offline
-P,--activate-profiles <arg> Comma-delimited list of profiles to activate
-pl,--projects <arg> Comma-delimited list of specified reactor projects to build instead of all projects. A project can be specified by [groupId]:artifactId or by its
relative path
-q,--quiet Quiet output - only show errors
-r,--resume Resume reactor from the last failed project, using the resume.properties file in the build directory
--raw-streams Do not decorate output and error streams
-rf,--resume-from <arg> Resume reactor from specified project
-s,--settings <arg> Alternate path for the user settings file
-t,--toolchains <arg> Alternate path for the user toolchains file
-T,--threads <arg> Thread count, for instance 4 (int) or 2C/2.5C (int/float) where C is core multiplied
-U,--update-snapshots Forces a check for missing releases and updated snapshots on remote repositories
-up,--update-plugins Ineffective, only kept for backward compatibility
-v,--version Display version information
-V,--show-version Display version information WITHOUT stopping build
-X,--debug Produce execution debug output
mvnd specific options:
--completion <string> Print the completion for the given shell to stdout. Only --completion bash is supported at this time.
--diag Terminal diagnosis
--purge Delete log files under the mvnd.registry directory that are older than mvnd.logPurgePeriod
--status Prints the status of daemon instances registered in the registry specified by mvnd.registry
--stop Stop all daemon instances registered in the registry specified by mvnd.registry
-f,--file <path> The pom or directory to build
-Djava.home=<path> Java home for starting the daemon.
This is a discriminating start parameter.
Env. variable: JAVA_HOME
-Djdk.java.options=<string> The JDK_JAVA_OPTIONS option
This is a discriminating start parameter.
Default:
Env. variable: JDK_JAVA_OPTIONS
-Dmaven.multiModuleProjectDirectory=<path> The root directory of the current multi module Maven project
-Dmaven.repo.local=<path> The path to the Maven local repository
This is a discriminating start parameter.
-Dmaven.settings=<path>;-s,--settings <path> The location of the maven settings file
This is a discriminating start parameter.
-Dmvnd.buildTime=<boolean> Log mojos execution time at the end of the build.
-Dmvnd.builder=<string>;-b,--builder <string> The builder implementation the daemon should use.
Default: smart
-Dmvnd.cancelConnectTimeout=<duration> Timeout to connect to a cancelled daemon.
Default: 3 seconds
-Dmvnd.connectTimeout=<duration> Overall timeout to connect to a daemon.
Default: 10 seconds
-Dmvnd.coreExtensionsExclude=<string> Internal option to specify comma separated list of maven extension G:As to exclude (to not load them from .mvn/extensions.xml). This option makes
possible for example that a project that with vanilla Maven would use takari-smart-builder extension, remain buildable with mvnd (where use of this
extension would cause issues). Value is expected as comma separated pairs.
Default: io.takari.maven:takari-smart-builder
-Dmvnd.daemonStorage=<path> The directory under which the daemon stores its registry, log files, etc. Default: ${user.home}/.m2/mvnd
Env. variable: MVND_DAEMON_STORAGE
-Dmvnd.debug=<boolean> If true, the daemon will be launched in debug mode with the following JVM argument: -agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=8000;
otherwise the debug argument is not passed to the daemon.
This is a discriminating start parameter.
Default: false
-Dmvnd.debug.address=<string> The tcp address used to launch the debug mode. Defaults to 8000, which is similar to localhost:8000. In order to remote debug from a different
computer, you need to allow remote connections using *:8000 for example. Use a port with a value of 0 to have mvnd to choose one.
This is a discriminating start parameter.
Default: 8000
-Dmvnd.duplicateDaemonGracePeriod=<duration> Period after which idle duplicate daemons will be shut down. Duplicate daemons are daemons with the same set of discriminating start parameters.
This is a discriminating start parameter.
Default: 10 seconds
-Dmvnd.enableAssertions=<boolean> If true, the -ea option will be passed to the daemon; otherwise the -ea option is not passed to the daemon.
This is a discriminating start parameter.
Default: false
-Dmvnd.expirationCheckDelay=<duration> The daemon will check this often whether it should exit.
This is a discriminating start parameter.
Default: 10 seconds
-Dmvnd.home=<path> The daemon installation directory. The client normally sets this according to where its mvnd executable is located
This is a discriminating start parameter.
Env. variable: MVND_HOME
-Dmvnd.idleTimeout=<duration> A time period after which an unused daemon will terminate by itself.
This is a discriminating start parameter.
Default: 3 hours
-Dmvnd.jvmArgs=<string> Additional JVM args to pass to the daemon. The content of the .mvn/jvm.config file will prepended (and thus with a lesser priority) to the user
supplied value for this parameter before being used as startup options for the daemon JVM.
This is a discriminating start parameter.
-Dmvnd.keepAlive=<duration> If the daemon does not send any message to the client in this period of time, send a keep-alive message so that the client knows that the daemon is
still alive.
This is a discriminating start parameter.
Default: 100 ms
-Dmvnd.logPurgePeriod=<duration> Daemon log files older than this value will be removed automatically.
Default: 7 days
-Dmvnd.maxHeapSize=<memory_size> The -Xmx value to pass to the daemon. This option takes precedence over options specified in -Dmvnd.jvmArgs.
This is a discriminating start parameter.
-Dmvnd.maxLostKeepAlive=<integer> The maximum number of keep alive messages that can be missed by the client before the client considers the daemon to be dead.
Default: 30
-Dmvnd.minHeapSize=<memory_size> The -Xms value to pass to the daemon. This option takes precedence over options specified in -Dmvnd.jvmArgs.
This is a discriminating start parameter.
-Dmvnd.minThreads=<integer> The minimum number of threads to use when constructing the default -T parameter for the daemon. This value is ignored if the user passes -T, --threads
or -Dmvnd.threads on the command line or if he sets mvnd.threads in ~/.m2/mvnd.properties.
Default: 1
-Dmvnd.noBuffering=<boolean> If true the log messages are displayed continuously like with stock Maven; otherwise buffer the messages and output at the end of the build, grouped by
module. Passing -B or --batch-mode on the command line enables this too for the given build.
Default: false
-Dmvnd.noDaemon=<boolean> If true, the client and daemon will run in the same JVM that exits when the build is finished; otherwise the client starts/connects to a long living
daemon process. This option is only available with non-native clients and is useful mostly for debugging.
This is a discriminating start parameter.
Default: false
Env. variable: MVND_NO_DAEMON
-Dmvnd.noModelCache=<boolean> If true, the daemon will not use its in-memory metadata cache and instead re-read the metadata from the pom.xml files in the local repository. This is
mostly useful for testing purposes.
Default: false
-Dmvnd.pluginRealmEvictPattern=<string> Pattern that will force eviction of the plugin realms if one of its dependencies matches. The overall pattern is a comma separated list of either: a
glob pattern starting with 'glob:' (the default syntax if no scheme is specified), a regex pattern starting with 'regex:', a maven expression, either
'mvn:[groupId]:[artifactId]:[version]', 'mvn:[groupId]:[artifactId]' or 'mvn:[artifactId]'. This pattern will be evaluated against the full path of
the dependencies, so it is usually desirable to start with 'glob:**/' to support any location of the local repository.
Default:
-Dmvnd.propertiesPath=<path> The location of the user supplied mvnd.properties file.
Env. variable: MVND_PROPERTIES_PATH
-Dmvnd.rawStreams;--raw-streams Whether or not decorate output and error streams
Default: false
-Dmvnd.registry=<path> The path to the daemon registry. Default: ${mvnd.daemonStorage}/registry.bin
-Dmvnd.rollingWindowSize=<integer> The number of log lines to display for each Maven module that is built in parallel. The value can be increased or decreased by pressing + or - key
during the build respectively. This option has no effect with -Dmvnd.noBuffering=true, -B or --batch-mode.
Default: 0
-Dmvnd.serial;-1,--serial Use one thread, no log buffering and the default project builder to behave like a standard maven
Default: false
-Dmvnd.socketConnectTimeout=<duration> Timeout to establish the socket connection.
Default: 1 seconds
-Dmvnd.socketFamily=<string> Socket family to use
This is a discriminating start parameter.
Default: inet
-Dmvnd.threadStackSize=<memory_size> The -Xss value to pass to the daemon. This option takes precedence over options specified in -Dmvnd.jvmArgs.
This is a discriminating start parameter.
-Dmvnd.threads=<string>;-T,--threads <string> The number of threads to pass to the daemon; same syntax as Maven's -T/--threads option.
-Dstyle.color=<string>;--color <string> Whether the output should be styled using ANSI color codes; possible values: auto, always, never
Default: auto
-Duser.dir=<path> The current working directory
-Duser.home=<path> The user home directory
mvnd value types:
boolean true or false; empty string is also interpreted as true - so -Dmvnd.noBuffering is equivalent to -Dmvnd.noBuffering=true
duration An unlabeled whole number of milliseconds or a whole number followed by an optional space and a unit which may be one of the following (in EBNF
notation): d[ay[s]], h[our[s]], m[in[ute[s]]], s[ec[ond[s]]] or m[illi]s[ec[ond[s]]]. Examples: 7 days, 7days, 7d, 100 milliseconds, 100 millis,
100ms, 100
integer A whole number
memory_size An amount of memory as accepted by the -Xm* family of HotSpot JVM options. Examples: 1024m, 2g, 5G
path A local file system path
string A string
ãªãããã«ãã衚瀺ããã ãã§ãMaven Daemonãç«ã¡äžããã®ã§ããâŠã
Maven Daemonã䜿ã£ãŠã¿ã
ã§ã¯ã䜿ã£ãŠã¿ãŸããç°¡åãªMavenãããžã§ã¯ããäœæã
pom.xml
<?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>org.littlewings</groupId> <artifactId>mvnd-example</artifactId> <version>0.0.1-SNAPSHOT</version> <properties> <maven.compiler.release>21</maven.compiler.release> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> </properties> <dependencies> <dependency> <groupId>org.junit.jupiter</groupId> <artifactId>junit-jupiter</artifactId> <version>5.10.3</version> <scope>test</scope> </dependency> <dependency> <groupId>org.assertj</groupId> <artifactId>assertj-core</artifactId> <version>3.26.3</version> <scope>test</scope> </dependency> </dependencies> </project>
src/main/java/org/littlewings/mvnd/CalcService.java
package org.littlewings.mvnd; public class CalcService { public int plus(int a, int b) { return a + b; } public int minus(int a, int b) { return a - b; } }
src/test/java/org/littlewings/mvnd/CalcServiceTest.java
package org.littlewings.mvnd; import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; class CalcServiceTest { @Test void testPlus() { CalcService calcService = new CalcService(); assertThat(calcService.plus(3, 5)).isEqualTo(8); } @Test void testMinus() { CalcService calcService = new CalcService(); assertThat(calcService.minus(5, 2)).isEqualTo(3); } }
$ mvnd --stop Stopping 1 running daemons
clean compileã§èšæž¬ã
$ mvnd clean compile ãçç¥ã [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ [INFO] Total time: 1.126 s (Wall Clock) [INFO] Finished at: 2024-07-13T21:35:26+09:00 [INFO] ------------------------------------------------------------------------
2åç®ã
$ mvnd clean compile ãçç¥ã [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ [INFO] Total time: 0.155 s (Wall Clock) [INFO] Finished at: 2024-07-13T21:35:52+09:00 [INFO] ------------------------------------------------------------------------
ãã®ãããéããªããŸããâŠã
éåžžã®Mavenãšæ¯èŒããŠã¿ãŸããããSDKMANã§ã€ã³ã¹ããŒã«ã
$ sdk install maven
Apache Maven 3.9.8ãã€ã³ã¹ããŒã«ãããŸããã
$ mvn --version Apache Maven 3.9.8 (36645f6c9b5079805ea5009217e36f2cffd34256) Maven home: $HOME/.sdkman/candidates/maven/current Java version: 21.0.3, vendor: Ubuntu, runtime: /usr/lib/jvm/java-21-openjdk-amd64 Default locale: ja_JP, platform encoding: UTF-8 OS name: "linux", version: "5.15.0-113-generic", arch: "amd64", family: "unix"
éåžžã®Apache Mavenã§å®è¡ã
$ mvn clean compile ãçç¥ã [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ [INFO] Total time: 1.172 s [INFO] Finished at: 2024-07-13T21:37:38+09:00 [INFO] ------------------------------------------------------------------------
Maven Daemonã®ååå®è¡ãšå€ãããªãé床ã§ããã
ä»åºŠã¯ãã¹ããå®è¡ããŠã¿ãŸããMaven Daemonã¯èµ·åæžã¿ã§ãã
$ mvnd clean test ãçç¥ã [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ [INFO] Total time: 0.816 s (Wall Clock) [INFO] Finished at: 2024-07-13T21:38:39+09:00 [INFO] ------------------------------------------------------------------------
$ mvn clean test ãçç¥ã [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ [INFO] Total time: 2.369 s [INFO] Finished at: 2024-07-13T21:39:03+09:00 [INFO] ------------------------------------------------------------------------
ã ãã¶éããªããŸãããã¡ãã£ãšé©ããŸããã
Logbackããã«ãããŠã¿ã
ããã§çµããã«ããŠãããã®ã§ããããããªã«å°ãããããžã§ã¯ãã ãšæ©æµããããã«ãããããããŸããã
é©åœãªOSSã®ãããžã§ã¯ãããã«ãããŠã¿ããããªãšããããšã§ãä»åã¯Logbackãéžã¶ããšã«ããŸããã
GitHub - qos-ch/logback: The reliable, generic, fast and flexible logging framework for Java.
Logbackãã¯ããŒã³ãçŸæç¹ã®ããŒãžã§ã³ã§ãã1.5.6ã察象ã«ããŸãã
$ git clone https://github.com/qos-ch/logback $ cd logback $ git checkout v_1.5.6
Maven Daemonã§ã³ã³ãã€ã«ãäŸåã©ã€ãã©ãªãŒã®ããŠã³ããŒãã¯äºåã«å®äºããŠãããã®ãšããŸãã
$ mvnd clean compile ãçç¥ã [INFO] ------------------------------------------------------------------------ [INFO] Reactor Summary for Logback-Parent 1.5.6: [INFO] [INFO] Logback-Parent ..................................... SUCCESS [ 0.002 s] [INFO] Logback Core Module ................................ SUCCESS [ 1.368 s] [INFO] Logback Core Blackbox Testing ...................... SUCCESS [ 0.036 s] [INFO] Logback Classic Module ............................. SUCCESS [ 0.929 s] [INFO] Logback Classic Blackbox Testing ................... SUCCESS [ 0.014 s] [INFO] Logback Examples Module ............................ SUCCESS [ 0.314 s] [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ [INFO] Total time: 2.634 s (Wall Clock) [INFO] Finished at: 2024-07-13T21:46:21+09:00 [INFO] ------------------------------------------------------------------------
ãšããã§ãMaven Daemonã§å®è¡ãããšéäžã®çµæãã»ãšãã©è¡šç€ºããããæåŸã«ãŸãšããŠåºåãããŸããã
Apache Mavenã§ã³ã³ãã€ã«ã
$ mvn clean compile ãçç¥ã [INFO] ------------------------------------------------------------------------ [INFO] Reactor Summary for Logback-Parent 1.5.6: [INFO] [INFO] Logback-Parent ..................................... SUCCESS [ 0.365 s] [INFO] Logback Core Module ................................ SUCCESS [ 6.015 s] [INFO] Logback Core Blackbox Testing ...................... SUCCESS [ 0.017 s] [INFO] Logback Classic Module ............................. SUCCESS [ 2.032 s] [INFO] Logback Classic Blackbox Testing ................... SUCCESS [ 0.047 s] [INFO] Logback Examples Module ............................ SUCCESS [ 0.674 s] [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ [INFO] Total time: 9.541 s [INFO] Finished at: 2024-07-13T21:46:43+09:00 [INFO] ------------------------------------------------------------------------
ãã¹ããå®è¡ããŠã¿ãŸãããã
$ mvnd clean test ãçç¥ã [INFO] ------------------------------------------------------------------------ [INFO] Reactor Summary for Logback-Parent 1.5.6: [INFO] [INFO] Logback-Parent ..................................... SUCCESS [ 0.002 s] [INFO] Logback Core Module ................................ SUCCESS [ 16.484 s] [INFO] Logback Core Blackbox Testing ...................... SUCCESS [ 3.195 s] [INFO] Logback Classic Module ............................. SUCCESS [ 33.182 s] [INFO] Logback Classic Blackbox Testing ................... SUCCESS [ 18.106 s] [INFO] Logback Examples Module ............................ SUCCESS [ 0.388 s] [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ [INFO] Total time: 01:07 min (Wall Clock) [INFO] Finished at: 2024-07-13T21:48:44+09:00 [INFO] ------------------------------------------------------------------------
$ mvn clean test ãçç¥ã [INFO] ------------------------------------------------------------------------ [INFO] Reactor Summary for Logback-Parent 1.5.6: [INFO] [INFO] Logback-Parent ..................................... SUCCESS [ 0.376 s] [INFO] Logback Core Module ................................ SUCCESS [ 39.107 s] [INFO] Logback Core Blackbox Testing ...................... SUCCESS [ 3.081 s] [INFO] Logback Classic Module ............................. SUCCESS [ 35.640 s] [INFO] Logback Classic Blackbox Testing ................... SUCCESS [ 19.308 s] [INFO] Logback Examples Module ............................ SUCCESS [ 0.579 s] [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ [INFO] Total time: 01:38 min [INFO] Finished at: 2024-07-13T21:51:57+09:00 [INFO] ------------------------------------------------------------------------
ãããã¡ãªã³ã°ãåã
Maven Daemonã䜿ããšããµã€ãã«Apache Mavenã䜿ã£ãŠããæãšã³ã³ãœãŒã«ã®æ§åãå€ãã£ãŠæžæãæ°ãããŸããããã¯ãããã¡ãªã³ã°
ãããŠãããããªã®ã§ãããç¡å¹ã«ããå Žåã¯-Dmvnd.noBuffering=trueãæå®ããŸãã
$ mvnd clean test -Dmvnd.noBuffering=true
èšå®ããã¡ã€ã«ã§æå®ãããå Žåã¯mvnd.propertiesã䜿ããŸãããã
bashã®ã³ãã³ãè£å®ãèšå®ãã
bashã®ã³ãã³ãè£å®ã®èšå®ããããŸãã
mvnd - the Maven Daemon / How to install mvnd / Set up completion
$HOME/.bashrcã«ã以äžã®å
容ã远å ããŸãããã
source [Maven Daemonã®ã€ã³ã¹ããŒã«ãã£ã¬ã¯ããª]/bin/mvnd-bash-completion.bash
mvnd-bash-completion.bashã«ãã¹ãéã£ãŠããå Žåã¯ã以äžã§è¿œèšã§ããããã
$ echo "source $(which mvnd-bash-completion.bash)" >> ~/.bashrc
æ°ããã·ã§ã«ãèµ·åãããšè£å®ãã§ããããã«ãªã£ãŠããŸãã
$ mvnd clean generate-test-resources package pre-integration-test process-sources site-deploy compile generate-test-sources post-clean pre-site process-test-classes test deploy initialize post-integration-test prepare-package process-test-resources test-compile generate-resources install post-site process-classes process-test-sources validate generate-sources integration-test pre-clean process-resources site verify
ãããã«
Maven Daemonã詊ããŠã¿ãŸããã
確ãã«ã ãã¶é床æ¹åãããŸãããããšã¯ãããããªãšããã§äœ¿ã£ãŠã¿ãŠãç¹ã«åé¡ãªããããªããã¡ãã«åãæ¿ããŠããããããããŸããã
æ§åãèŠã€ã€ã詊ããŠããããšæããŸãã