feat(greeting.plugin): initial commit
This commit is contained in:
parent
3c50c07181
commit
a278e2e614
|
@ -0,0 +1,31 @@
|
||||||
|
|
||||||
|
# Files
|
||||||
|
.classpath
|
||||||
|
.externalToolBuilders
|
||||||
|
.gradle
|
||||||
|
.project
|
||||||
|
.pydevproject
|
||||||
|
.settings
|
||||||
|
.sonar
|
||||||
|
*~
|
||||||
|
*.ipr
|
||||||
|
*.iml
|
||||||
|
*.iws
|
||||||
|
*.swp
|
||||||
|
*.DS_Store
|
||||||
|
*.snap.debug
|
||||||
|
dependency-reduced-pom.xml
|
||||||
|
|
||||||
|
# Directories
|
||||||
|
.idea/
|
||||||
|
.run/
|
||||||
|
.venv/
|
||||||
|
_site/
|
||||||
|
build/
|
||||||
|
dist/
|
||||||
|
docs/_build/
|
||||||
|
gen-java/
|
||||||
|
gen-javabean/
|
||||||
|
gen-py/
|
||||||
|
node_modules/
|
||||||
|
target/
|
|
@ -0,0 +1,20 @@
|
||||||
|
# Overview
|
||||||
|
This project shows how to create a Maven plugin.
|
||||||
|
|
||||||
|
# Preparation
|
||||||
|
Copy settings into user folder like this.
|
||||||
|
|
||||||
|
```
|
||||||
|
cp settings.xml ~/.m2/
|
||||||
|
```
|
||||||
|
|
||||||
|
# Execution
|
||||||
|
Call the following instructions to execute the plugin on the command line.
|
||||||
|
|
||||||
|
```
|
||||||
|
mvn clean install
|
||||||
|
mvn hello:sayhi
|
||||||
|
```
|
||||||
|
|
||||||
|
# Links
|
||||||
|
[Example](https://maven.apache.org/guides/plugin/guide-java-plugin-development.html#Plugin_Naming_Convention_and_Apache_Maven_Trademark)
|
|
@ -0,0 +1,53 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||||
|
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
<groupId>de.swingbe.greeting.plugin</groupId>
|
||||||
|
<artifactId>hello-maven-plugin</artifactId>
|
||||||
|
<version>1.0.0</version>
|
||||||
|
<packaging>maven-plugin</packaging>
|
||||||
|
|
||||||
|
<name>Sample Parameter-less Maven Plugin</name>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<!--maven-compiler-plugin results in error without statung source and target-->
|
||||||
|
<maven.compiler.target>1.8</maven.compiler.target>
|
||||||
|
<maven.compiler.source>1.8</maven.compiler.source>
|
||||||
|
<!-- Other properties -->
|
||||||
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
</properties>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.maven</groupId>
|
||||||
|
<artifactId>maven-plugin-api</artifactId>
|
||||||
|
<version>3.0</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- dependencies to annotations -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.maven.plugin-tools</groupId>
|
||||||
|
<artifactId>maven-plugin-annotations</artifactId>
|
||||||
|
<version>3.4</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>de.swingbe.greeting.plugin</groupId>
|
||||||
|
<artifactId>hello-maven-plugin</artifactId>
|
||||||
|
<version>1.0.0</version>
|
||||||
|
<configuration>
|
||||||
|
<greeting>Welcome</greeting>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
|
||||||
|
</project>
|
|
@ -0,0 +1,24 @@
|
||||||
|
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 https://maven.apache.org/xsd/settings-1.0.0.xsd">
|
||||||
|
|
||||||
|
<localRepository/>
|
||||||
|
|
||||||
|
<interactiveMode/>
|
||||||
|
|
||||||
|
<offline/>
|
||||||
|
|
||||||
|
<pluginGroups>
|
||||||
|
<pluginGroup>de.swingbe.greeting.plugin</pluginGroup>
|
||||||
|
</pluginGroups>
|
||||||
|
|
||||||
|
<servers/>
|
||||||
|
|
||||||
|
<mirrors/>
|
||||||
|
|
||||||
|
<proxies/>
|
||||||
|
|
||||||
|
<profiles/>
|
||||||
|
|
||||||
|
<activeProfiles/>
|
||||||
|
|
||||||
|
</settings>
|
|
@ -0,0 +1,22 @@
|
||||||
|
package de.swingbe.greeting.plugin;
|
||||||
|
|
||||||
|
//provide infrastructure required to implement a MOJO except for the execute method
|
||||||
|
import org.apache.maven.plugin.AbstractMojo;
|
||||||
|
import org.apache.maven.plugin.MojoExecutionException;
|
||||||
|
import org.apache.maven.plugins.annotations.Mojo;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Says "Hi" to the user.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
//required annotation that controls how and when the MOJO is executed
|
||||||
|
@Mojo( name = "sayhi")
|
||||||
|
public class GreetingMojo extends AbstractMojo
|
||||||
|
{
|
||||||
|
public void execute() throws MojoExecutionException
|
||||||
|
{
|
||||||
|
//defined in AbstractMojo
|
||||||
|
//returns logger objects that allows plugins to display messages
|
||||||
|
getLog().info( "Hello, world." );
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue