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 tests.
030 */
031@Mojo(
032    name = ValidateTestConfigurationMojo.MOJO_NAME,
033    requiresDependencyResolution = ResolutionScope.TEST
034)
035public class ValidateTestConfigurationMojo extends AbstractConfigurationValidationMojo {
036    public static final String MOJO_NAME = "validate-test-configuration";
037
038    @Inject
039    public ValidateTestConfigurationMojo(MavenProject project, CompilerService compilerService) {
040        super(project, compilerService);
041    }
042
043    @Override
044    protected String scenarioName() {
045        return "test";
046    }
047
048    @Override
049    protected ConfigurationValidationConfiguration.ValidationSet validationSet(ConfigurationValidationConfiguration cfg) {
050        return cfg.getTest();
051    }
052
053    @Override
054    protected List<String> defaultEnvironments() {
055        return List.of("test");
056    }
057
058    @Override
059    protected List<String> defaultClasspath(MavenProject project) {
060        return ConfigurationValidationClasspath.defaultTestClasspath(project);
061    }
062
063    @Override
064    protected String[] dependencyScopes() {
065        return new String[] { JavaScopes.TEST };
066    }
067
068    @Override
069    protected List<Path> defaultResourceDirectories() {
070        return List.of(Path.of("src/main/resources"), Path.of("src/test/resources"));
071    }
072}