You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by jd...@apache.org on 2007/08/16 23:27:44 UTC

svn commit: r566860 - /maven/sandbox/trunk/plugins/maven-component-it-plugin/src/main/java/org/apache/maven/plugin/componentit/InjectLocalRepoLocationMojo.java

Author: jdcasey
Date: Thu Aug 16 14:27:43 2007
New Revision: 566860

URL: http://svn.apache.org/viewvc?view=rev&rev=566860
Log:
Adding mojo to inject current local repo path into the current project as a property that can be referenced in filters, etc.

Added:
    maven/sandbox/trunk/plugins/maven-component-it-plugin/src/main/java/org/apache/maven/plugin/componentit/InjectLocalRepoLocationMojo.java   (with props)

Added: maven/sandbox/trunk/plugins/maven-component-it-plugin/src/main/java/org/apache/maven/plugin/componentit/InjectLocalRepoLocationMojo.java
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/plugins/maven-component-it-plugin/src/main/java/org/apache/maven/plugin/componentit/InjectLocalRepoLocationMojo.java?view=auto&rev=566860
==============================================================================
--- maven/sandbox/trunk/plugins/maven-component-it-plugin/src/main/java/org/apache/maven/plugin/componentit/InjectLocalRepoLocationMojo.java (added)
+++ maven/sandbox/trunk/plugins/maven-component-it-plugin/src/main/java/org/apache/maven/plugin/componentit/InjectLocalRepoLocationMojo.java Thu Aug 16 14:27:43 2007
@@ -0,0 +1,58 @@
+package org.apache.maven.plugin.componentit;
+
+import org.apache.maven.artifact.repository.ArtifactRepository;
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.MojoFailureException;
+import org.apache.maven.project.MavenProject;
+
+import java.util.Properties;
+
+/**
+ * @goal inject-local-repository-path
+ * @author jdcasey
+ *
+ */
+public class InjectLocalRepoLocationMojo
+    extends AbstractMojo
+{
+
+    /**
+     * @parameter default-value="${localRepositoryPath}"
+     * @required
+     */
+    private String property;
+
+    /**
+     * @parameter default-value="${localRepository}"
+     * @required
+     * @readonly
+     */
+    private ArtifactRepository localRepository;
+
+    /**
+     * @parameter default-value="${project}"
+     * @required
+     * @readonly
+     */
+    private MavenProject project;
+
+    public void execute()
+        throws MojoExecutionException, MojoFailureException
+    {
+        Properties properties = project.getProperties();
+
+        if ( properties == null )
+        {
+            properties = new Properties();
+        }
+
+        String localRepoPath = localRepository.getBasedir();
+
+        getLog().info( "Injecting local-repository path: " + localRepoPath + " into project properties under key: " + property );
+
+        properties.setProperty( property, localRepoPath );
+        project.getModel().setProperties( properties );
+    }
+
+}

Propchange: maven/sandbox/trunk/plugins/maven-component-it-plugin/src/main/java/org/apache/maven/plugin/componentit/InjectLocalRepoLocationMojo.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/sandbox/trunk/plugins/maven-component-it-plugin/src/main/java/org/apache/maven/plugin/componentit/InjectLocalRepoLocationMojo.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"