• maven之自定义插件


    maven及依赖

    <dependencies>
    	<dependency>
    		<groupId>org.apache.maven</groupId>
    		<artifactId>maven-plugin-api</artifactId>
    		<version>3.6.0</version>
    	</dependency>
    	<dependency>
    		<groupId>org.apache.maven.plugin-tools</groupId>
    		<artifactId>maven-plugin-annotations</artifactId>
    		<version>3.6.0</version>
    		<scope>provided</scope>
    	</dependency>
    </dependencies>
    
    <build>
    	<plugins>
    		<plugin>
    			<groupId>org.apache.maven.plugins</groupId>
    			<artifactId>maven-compiler-plugin</artifactId>
    			<version>3.6.1</version>
    			<configuration>
    				<source>1.8</source>
    				<target>1.8</target>
    			</configuration>
    		</plugin>
    	</plugins>
    </build>
    

    插件开发

    /**
     * 	自定义的maven插件
     */
    @Mojo(name = "hello", defaultPhase = LifecyclePhase.PACKAGE )
    public class HelloPlugin extends AbstractMojo {
    
    	public void execute() throws MojoExecutionException, MojoFailureException {
    		System.err.println("hello...");
    	}
    
    }
    

    使用插件

    <plugin>
    	<groupId>com.pengsn</groupId>
    	<artifactId>hello</artifactId>
    	<version>0.0.1-SNAPSHOT</version>
    </plugin>
    

    如果觉得文章对您有用,请点下推荐。您的支持将鼓励我继续创作!

  • 相关阅读:
    【iOS】找工作的面试题集锦
    APP项目优化--启动速度优化篇
    【Swift】Timer定时器到底准不准确?
    leetcode刷题 495~
    leetcode刷题 464~
    leetcode刷题 441~
    leetcode刷题 420~
    leetcode刷题 396~
    leetcode刷题 373~
    leetcode刷题 307~
  • 原文地址:https://www.cnblogs.com/pengsn/p/13565327.html
Copyright © 2020-2023  润新知