001/* 002 * Copyright 2017-2026 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.jsonschema; 017 018import io.micronaut.maven.services.CompilerService; 019import org.apache.maven.plugins.annotations.Mojo; 020import org.apache.maven.plugins.annotations.ResolutionScope; 021import org.apache.maven.project.MavenProject; 022import org.eclipse.aether.util.artifact.JavaScopes; 023 024import javax.inject.Inject; 025import java.nio.file.Path; 026import java.util.List; 027 028/** 029 * Validates Micronaut configuration for the "dev" environment. 030 * <p> 031 * This mojo is automatically executed by {@code mn:run}. 032 */ 033@Mojo( 034 name = ValidateDevConfigurationMojo.MOJO_NAME, 035 requiresDependencyResolution = ResolutionScope.COMPILE_PLUS_RUNTIME 036) 037public class ValidateDevConfigurationMojo extends AbstractConfigurationValidationMojo { 038 public static final String MOJO_NAME = "validate-dev-configuration"; 039 040 @Inject 041 public ValidateDevConfigurationMojo(MavenProject project, CompilerService compilerService) { 042 super(project, compilerService); 043 } 044 045 @Override 046 protected String scenarioName() { 047 return "dev"; 048 } 049 050 @Override 051 protected ConfigurationValidationConfiguration.ValidationSet validationSet(ConfigurationValidationConfiguration cfg) { 052 return cfg.getDev(); 053 } 054 055 @Override 056 protected List<String> defaultEnvironments() { 057 return List.of("dev"); 058 } 059 060 @Override 061 protected List<String> defaultClasspath(MavenProject project) { 062 return ConfigurationValidationClasspath.defaultDevClasspath(project); 063 } 064 065 @Override 066 protected String[] dependencyScopes() { 067 return new String[] { JavaScopes.PROVIDED, JavaScopes.COMPILE, JavaScopes.RUNTIME }; 068 } 069 070 @Override 071 protected List<Path> defaultResourceDirectories() { 072 return List.of(Path.of("src/main/resources")); 073 } 074}