All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.xiaoymin.maven.TemplateFactoryMavenMojo Maven / Gradle / Ivy

/*
 * Copyright © 2017-2023 TemplateFactory([email protected])
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */


package com.github.xiaoymin.maven;

import com.github.xiaoymin.template.TemplateEngine;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
import org.apache.maven.plugins.annotations.LifecyclePhase;
import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.Parameter;
import org.apache.maven.plugins.annotations.ResolutionScope;
import org.apache.maven.project.MavenProject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.File;

/***
 *
 * @since:template-engine 1.0
 * @author [email protected] 
 * 2020/06/06 14:35
 */
@Mojo(name = "generate", defaultPhase = LifecyclePhase.NONE, requiresDependencyResolution = ResolutionScope.NONE)
public class TemplateFactoryMavenMojo extends AbstractMojo {
    
    Logger logger = LoggerFactory.getLogger(TemplateFactoryMavenMojo.class);
    
    /**
     * Maven Project.
     *
     */
    @Parameter(property = "project", required = true, readonly = true)
    private MavenProject project;
    
    /**
     * Location of the configuration file.
     */
    @Parameter(property = "template.engine.generator.configurationFile", defaultValue = "${project.basedir}/src/main/resources/templateFactoryConfig.xml", required = true)
    private File configurationFile;
    
    @Override
    public void execute() throws MojoExecutionException, MojoFailureException {
        logger.info("Template Engine Start Working...");
        logger.info("projectName:{},baseDir:{}", project.getName(), project.getBasedir());
        if (configurationFile != null) {
            logger.info("配置文件不为空");
            // TemplateEngine.print(configurationFile);
            TemplateEngine.generator(configurationFile, project);
        } else {
            logger.info("配置文件为空,初始化失败...");
        }
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy