mvn archetype:generate -DgroupId=com.example -DartifactId=custom-maven-plugin -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false <dependencies> <dependency> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-plugin-api</artifactId> <version>3.8.1</version> </dependency> <dependency> <groupId>org.apache.maven.plugin-tools</groupId> <artifactId>maven-plugin-annotations</artifactId> <version>3.6.1</version> <scope>provided</scope> </dependency> </dependencies> import org.apache.maven.plugin.AbstractMojo; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.Parameter; @Mojo(name = "greeting") public class GreetingMojo extends AbstractMojo { @Parameter(property = "greeting.message", defaultValue = "Hello, Maven Plugin!") private String message; public void execute() throws MojoExecutionException, MojoFailureException { getLog().info(message); } } mvn clean package <plugin> <groupId>com.example</groupId> <artifactId>custom-maven-plugin</artifactId> <version>1.0-SNAPSHOT</version> </plugin> mvn com.example:custom-maven-plugin:greeting


上一篇:
下一篇:
切换中文