001/* 002 * Copyright 2017-2022 original authors 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * https://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016package io.micronaut.maven.testresources; 017 018import io.micronaut.maven.services.DependencyResolutionService; 019import org.apache.maven.execution.MavenSession; 020import org.apache.maven.plugin.MojoExecutionException; 021import org.apache.maven.plugins.annotations.Mojo; 022import org.apache.maven.plugins.annotations.ResolutionScope; 023import org.apache.maven.project.MavenProject; 024import org.apache.maven.toolchain.ToolchainManager; 025 026import javax.inject.Inject; 027 028/** 029 * Starts the Micronaut test resources server. 030 */ 031@Mojo(name = StartTestResourcesServerMojo.NAME, requiresDependencyResolution = ResolutionScope.COMPILE_PLUS_RUNTIME) 032public class StartTestResourcesServerMojo extends AbstractTestResourcesMojo { 033 public static final String NAME = "start-testresources-service"; 034 035 private final MavenProject mavenProject; 036 037 private final MavenSession mavenSession; 038 039 private final DependencyResolutionService dependencyResolutionService; 040 041 private final ToolchainManager toolchainManager; 042 043 @Inject 044 @SuppressWarnings("CdiInjectionPointsInspection") 045 public StartTestResourcesServerMojo(MavenProject mavenProject, 046 MavenSession mavenSession, 047 DependencyResolutionService dependencyResolutionService, 048 ToolchainManager toolchainManager) { 049 this.mavenProject = mavenProject; 050 this.mavenSession = mavenSession; 051 this.dependencyResolutionService = dependencyResolutionService; 052 this.toolchainManager = toolchainManager; 053 } 054 055 @Override 056 public final void execute() throws MojoExecutionException { 057 var helper = new TestResourcesHelper(testResourcesEnabled, shared, buildDirectory, explicitPort, clientTimeout, 058 serverIdleTimeoutMinutes, mavenProject, mavenSession, dependencyResolutionService, toolchainManager, 059 testResourcesVersion, classpathInference, testResourcesDependencies, sharedServerNamespace, debugServer, 060 foreground); 061 helper.start(); 062 063 } 064 065}