Website Monitor Plugin
This section will show how to use a Plexus component from within a Maven mojo.
Setting up a Maven Plugin Project
Creating a Maven plugin Project using an archetype
Maven Archetypes are discussed in detail here.
- From the command prompt, change directory to the location where you want to setup the maven plugin project.
- Run the following command to set up a skeleton Maven Plugin project.
mvn archetype:create -DarchetypeGroupId=org.apache.maven.archetypes -DarchetypeArtifactId=maven-archetype-mojo \ -DarchetypeVersion=1.0-SNAPSHOT -DgroupId=org.codehaus.plexus -DartifactId=plexus-website-monitor-plugin
The maven-archetype-mojo
sets up a skeleton Maven plugin project 'plexus-website-monitor-plugin
' for us with reasonable defaults.
Updating pom.xml dependencies
- Locate pom.xml under the '
plexus-website-monitor-plugin
' folder. - Edit it and add a
dependency
to the plexus-website-monitor-component that we have developed in earlier chapters.The pom.xml should look like this now:
<?xml version="1.0"?> <project> <modelVersion>4.0.0</modelVersion> <groupId>org.codehaus.plexus</groupId> <artifactId>plexus-website-monitor-plugin</artifactId> <packaging>maven-plugin</packaging> <name>Maven Mojo Archetype</name> <version>1.0-SNAPSHOT</version> <url>http://maven.apache.org</url> <dependencies> <dependency> <groupId>org.apache.maven</groupId> <artifactId>maven-plugin-api</artifactId> <version>2.0</version> </dependency> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>3.8.1</version> <scope>test</scope> </dependency> <dependency> <groupId>org.codehaus.plexus</groupId> <artifactId>plexus-website-monitor-component</artifactId> <version>1.0-SNAPSHOT</version> </dependency> </dependencies> </project>
Setting up an Eclipse project
Note that this step assumes that we have Plexus Website Monitor Component available in our local repository or downloadable from a remote repository.
- Run the following command to generate Eclipse project and set up library path to dependencies.
mvn eclipse:eclipse
- From the Eclipse workbench, use 'File > Import > Existing projects into workspace' to import the created maven plugin project.
The website monitor plugin should now be set up as a project under Eclipse.