Author: brett Date: Wed Apr 20 11:26:48 2011 New Revision: 1095366 URL: http://svn.apache.org/viewvc?rev=1095366&view=rev Log: [MNG-4384] add an example mojo
Added: maven/sandbox/trunk/examples/plugins/maven-security-mojo/ maven/sandbox/trunk/examples/plugins/maven-security-mojo/pom.xml (with props) maven/sandbox/trunk/examples/plugins/maven-security-mojo/src/ maven/sandbox/trunk/examples/plugins/maven-security-mojo/src/main/ maven/sandbox/trunk/examples/plugins/maven-security-mojo/src/main/java/ maven/sandbox/trunk/examples/plugins/maven-security-mojo/src/main/java/org/ maven/sandbox/trunk/examples/plugins/maven-security-mojo/src/main/java/org/apache/ maven/sandbox/trunk/examples/plugins/maven-security-mojo/src/main/java/org/apache/maven/ maven/sandbox/trunk/examples/plugins/maven-security-mojo/src/main/java/org/apache/maven/examples/ maven/sandbox/trunk/examples/plugins/maven-security-mojo/src/main/java/org/apache/maven/examples/MyMojo.java (with props) maven/sandbox/trunk/examples/plugins/maven-security-mojo/src/main/resources/ maven/sandbox/trunk/examples/plugins/maven-security-mojo/src/main/resources/META-INF/ maven/sandbox/trunk/examples/plugins/maven-security-mojo/src/main/resources/META-INF/plexus/ maven/sandbox/trunk/examples/plugins/maven-security-mojo/src/main/resources/META-INF/plexus/components.xml (with props) Added: maven/sandbox/trunk/examples/plugins/maven-security-mojo/pom.xml URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/examples/plugins/maven-security-mojo/pom.xml?rev=1095366&view=auto ============================================================================== --- maven/sandbox/trunk/examples/plugins/maven-security-mojo/pom.xml (added) +++ maven/sandbox/trunk/examples/plugins/maven-security-mojo/pom.xml Wed Apr 20 11:26:48 2011 @@ -0,0 +1,39 @@ +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + 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>org.apache.maven.examples</groupId> + <artifactId>maven-security-mojo</artifactId> + <packaging>maven-plugin</packaging> + <version>1.0-SNAPSHOT</version> + <name>maven-security-mojo Maven Mojo</name> + <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.sonatype.plexus</groupId> + <artifactId>plexus-sec-dispatcher</artifactId> + <version>1.3</version> + </dependency> + </dependencies> + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-plugin-plugin</artifactId> + <version>2.6</version> + <configuration> + <prefix>sec</prefix> + </configuration> + </plugin> + </plugins> + </build> +</project> Propchange: maven/sandbox/trunk/examples/plugins/maven-security-mojo/pom.xml ------------------------------------------------------------------------------ svn:eol-style = native Added: maven/sandbox/trunk/examples/plugins/maven-security-mojo/src/main/java/org/apache/maven/examples/MyMojo.java URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/examples/plugins/maven-security-mojo/src/main/java/org/apache/maven/examples/MyMojo.java?rev=1095366&view=auto ============================================================================== --- maven/sandbox/trunk/examples/plugins/maven-security-mojo/src/main/java/org/apache/maven/examples/MyMojo.java (added) +++ maven/sandbox/trunk/examples/plugins/maven-security-mojo/src/main/java/org/apache/maven/examples/MyMojo.java Wed Apr 20 11:26:48 2011 @@ -0,0 +1,52 @@ +package org.apache.maven.examples; + +/* + * Copyright 2001-2005 The Apache Software Foundation. + * + * 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. + */ + +import org.apache.maven.plugin.AbstractMojo; +import org.apache.maven.plugin.MojoExecutionException; +import org.sonatype.plexus.components.sec.dispatcher.SecDispatcher; +import org.sonatype.plexus.components.sec.dispatcher.SecDispatcherException; + +/** + * Goal which decrypts a password using Maven settings. + * + * @goal decrypt + */ +public class MyMojo + extends AbstractMojo +{ + /** + * Password to decrypt. + * @parameter expression="${password}" + * @required + */ + private String password; + + /** @component role-hint="mojo" */ + private SecDispatcher securityDispatcher; + + public void execute() + throws MojoExecutionException + { + try { + // obviously, using it instead of echoing it is recommended :) + getLog().info( securityDispatcher.decrypt( password ) ); + } catch ( SecDispatcherException e ) { + throw new MojoExecutionException( e.getMessage(), e ); + } + } +} Propchange: maven/sandbox/trunk/examples/plugins/maven-security-mojo/src/main/java/org/apache/maven/examples/MyMojo.java ------------------------------------------------------------------------------ svn:eol-style = native Added: maven/sandbox/trunk/examples/plugins/maven-security-mojo/src/main/resources/META-INF/plexus/components.xml URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/examples/plugins/maven-security-mojo/src/main/resources/META-INF/plexus/components.xml?rev=1095366&view=auto ============================================================================== --- maven/sandbox/trunk/examples/plugins/maven-security-mojo/src/main/resources/META-INF/plexus/components.xml (added) +++ maven/sandbox/trunk/examples/plugins/maven-security-mojo/src/main/resources/META-INF/plexus/components.xml Wed Apr 20 11:26:48 2011 @@ -0,0 +1,24 @@ +<component-set> + <components> + <component> + <role>org.sonatype.plexus.components.sec.dispatcher.SecDispatcher</role> + <role-hint>mojo</role-hint> + <implementation>org.sonatype.plexus.components.sec.dispatcher.DefaultSecDispatcher</implementation> + <description>Maven Security dispatcher</description> + <requirements> + <requirement> + <role>org.sonatype.plexus.components.cipher.PlexusCipher</role> + <field-name>_cipher</field-name> + </requirement> + </requirements> + <configuration> + <_configuration-file>~/.m2/settings-security.xml</_configuration-file> + </configuration> + </component> + <component> + <role>org.sonatype.plexus.components.cipher.PlexusCipher</role> + <role-hint>mojo</role-hint> + <implementation>org.sonatype.plexus.components.cipher.DefaultPlexusCipher</implementation> + </component> + </components> +</component-set> Propchange: maven/sandbox/trunk/examples/plugins/maven-security-mojo/src/main/resources/META-INF/plexus/components.xml ------------------------------------------------------------------------------ svn:eol-style = native