Home / Class/ RunMojo Class — spring-boot Architecture

RunMojo Class — spring-boot Architecture

Architecture documentation for the RunMojo class in RunMojo.java from the spring-boot codebase.

Entity Profile

Source Code

build-plugin/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/RunMojo.java lines 45–107

@Mojo(name = "run", requiresProject = true, defaultPhase = LifecyclePhase.VALIDATE,
		requiresDependencyResolution = ResolutionScope.TEST)
@Execute(phase = LifecyclePhase.TEST_COMPILE)
public class RunMojo extends AbstractRunMojo {

	/**
	 * Whether the JVM's launch should be optimized.
	 * @since 2.2.0
	 */
	@Parameter(property = "spring-boot.run.optimizedLaunch", defaultValue = "true")
	private boolean optimizedLaunch;

	/**
	 * Flag to include the test classpath when running.
	 * @since 1.3.0
	 */
	@Parameter(property = "spring-boot.run.useTestClasspath", defaultValue = "false")
	private boolean useTestClasspath;

	@Inject
	public RunMojo(ToolchainManager toolchainManager) {
		super(toolchainManager);
	}

	@Override
	protected RunArguments resolveJvmArguments() {
		RunArguments jvmArguments = super.resolveJvmArguments();
		if (this.optimizedLaunch) {
			jvmArguments.getArgs().addFirst("-XX:TieredStopAtLevel=1");
		}
		return jvmArguments;
	}

	@Override
	protected void run(JavaProcessExecutor processExecutor, File workingDirectory, List<String> args,
			Map<String, String> environmentVariables) throws MojoExecutionException, MojoFailureException {
		processExecutor
			.withRunProcessCustomizer(
					(runProcess) -> Runtime.getRuntime().addShutdownHook(new Thread(new RunProcessKiller(runProcess))))
			.run(workingDirectory, args, environmentVariables);
	}

	@Override
	protected boolean isUseTestClasspath() {
		return this.useTestClasspath;
	}

	private static final class RunProcessKiller implements Runnable {

		private final RunProcess runProcess;

		private RunProcessKiller(RunProcess runProcess) {
			this.runProcess = runProcess;
		}

		@Override
		public void run() {
			this.runProcess.kill();
		}

	}

}

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free