You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by br...@apache.org on 2005/11/01 05:57:37 UTC
svn commit: r329973 - in /maven/components/trunk/sandbox/maven-one-plugin:
./ src/main/java/org/apache/maven/plugins/
src/main/resources/META-INF/plexus/ src/site/ src/site/apt/
Author: brett
Date: Mon Oct 31 20:57:24 2005
New Revision: 329973
URL: http://svn.apache.org/viewcvs?rev=329973&view=rev
Log:
add mojo for copying the artifact to the Maven 1.x repo, and add docs
Added:
maven/components/trunk/sandbox/maven-one-plugin/src/main/java/org/apache/maven/plugins/MavenOneRepositoryInstallMojo.java (with props)
maven/components/trunk/sandbox/maven-one-plugin/src/site/
maven/components/trunk/sandbox/maven-one-plugin/src/site/apt/
maven/components/trunk/sandbox/maven-one-plugin/src/site/apt/introduction.apt (with props)
maven/components/trunk/sandbox/maven-one-plugin/src/site/site.xml (with props)
Modified:
maven/components/trunk/sandbox/maven-one-plugin/pom.xml
maven/components/trunk/sandbox/maven-one-plugin/src/main/java/org/apache/maven/plugins/MavenOnePluginMojo.java
maven/components/trunk/sandbox/maven-one-plugin/src/main/resources/META-INF/plexus/components.xml
Modified: maven/components/trunk/sandbox/maven-one-plugin/pom.xml
URL: http://svn.apache.org/viewcvs/maven/components/trunk/sandbox/maven-one-plugin/pom.xml?rev=329973&r1=329972&r2=329973&view=diff
==============================================================================
--- maven/components/trunk/sandbox/maven-one-plugin/pom.xml (original)
+++ maven/components/trunk/sandbox/maven-one-plugin/pom.xml Mon Oct 31 20:57:24 2005
@@ -39,4 +39,14 @@
<version>1.0.4</version>
</dependency>
</dependencies>
+ <reporting>
+ <plugins>
+ <plugin>
+ <artifactId>maven-plugin-plugin</artifactId>
+ <configuration>
+ <goalPrefix>maven-one-plugin</goalPrefix>
+ </configuration>
+ </plugin>
+ </plugins>
+ </reporting>
</project>
Modified: maven/components/trunk/sandbox/maven-one-plugin/src/main/java/org/apache/maven/plugins/MavenOnePluginMojo.java
URL: http://svn.apache.org/viewcvs/maven/components/trunk/sandbox/maven-one-plugin/src/main/java/org/apache/maven/plugins/MavenOnePluginMojo.java?rev=329973&r1=329972&r2=329973&view=diff
==============================================================================
--- maven/components/trunk/sandbox/maven-one-plugin/src/main/java/org/apache/maven/plugins/MavenOnePluginMojo.java (original)
+++ maven/components/trunk/sandbox/maven-one-plugin/src/main/java/org/apache/maven/plugins/MavenOnePluginMojo.java Mon Oct 31 20:57:24 2005
@@ -105,7 +105,10 @@
try
{
- archiver.getArchiver().addDirectory( contentDirectory, DEFAULT_INCLUDES, DEFAULT_EXCLUDES );
+ if ( contentDirectory.exists() )
+ {
+ archiver.getArchiver().addDirectory( contentDirectory, DEFAULT_INCLUDES, DEFAULT_EXCLUDES );
+ }
addFile( archiver, new File( "plugin.jelly" ) );
addFile( archiver, new File( "plugin.properties" ) );
Added: maven/components/trunk/sandbox/maven-one-plugin/src/main/java/org/apache/maven/plugins/MavenOneRepositoryInstallMojo.java
URL: http://svn.apache.org/viewcvs/maven/components/trunk/sandbox/maven-one-plugin/src/main/java/org/apache/maven/plugins/MavenOneRepositoryInstallMojo.java?rev=329973&view=auto
==============================================================================
--- maven/components/trunk/sandbox/maven-one-plugin/src/main/java/org/apache/maven/plugins/MavenOneRepositoryInstallMojo.java (added)
+++ maven/components/trunk/sandbox/maven-one-plugin/src/main/java/org/apache/maven/plugins/MavenOneRepositoryInstallMojo.java Mon Oct 31 20:57:24 2005
@@ -0,0 +1,155 @@
+package org.apache.maven.plugins;
+
+/*
+ * 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.artifact.Artifact;
+import org.apache.maven.artifact.installer.ArtifactInstallationException;
+import org.apache.maven.artifact.installer.ArtifactInstaller;
+import org.apache.maven.artifact.repository.ArtifactRepository;
+import org.apache.maven.artifact.repository.ArtifactRepositoryFactory;
+import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.codehaus.plexus.util.IOUtil;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.util.Properties;
+
+/**
+ * Install the artifact in a maven one local repository
+ *
+ * @goal install-maven-one-repository
+ * @phase install
+ */
+public class MavenOneRepositoryInstallMojo
+ extends AbstractMojo
+{
+ /**
+ * @parameter expression="${project.packaging}"
+ * @required
+ * @readonly
+ */
+ protected String packaging;
+
+ /**
+ * @parameter expression="${project.file}"
+ * @required
+ * @readonly
+ */
+ private File pomFile;
+
+ /**
+ * @parameter expression="${project.artifact}"
+ * @required
+ * @readonly
+ */
+ private Artifact artifact;
+
+ /**
+ * @component
+ */
+ protected ArtifactInstaller installer;
+
+ /**
+ * @component
+ */
+ protected ArtifactRepositoryFactory factory;
+
+ /**
+ * @parameter expression="${mavenOneRepository}"
+ */
+ protected String mavenOneRepository;
+
+ /**
+ * @component roleHint="legacy"
+ */
+ private ArtifactRepositoryLayout legacyLayout;
+
+ public void execute()
+ throws MojoExecutionException
+ {
+ try
+ {
+ if ( mavenOneRepository == null )
+ {
+ File f = new File( System.getProperty( "user.home" ), "build.properties" );
+ if ( f.exists() )
+ {
+ Properties p = new Properties();
+ FileInputStream inStream = new FileInputStream( f );
+ try
+ {
+ p.load( inStream );
+ }
+ finally
+ {
+ IOUtil.close( inStream );
+ }
+ mavenOneRepository = p.getProperty( "maven.repo.local" );
+ }
+
+ if ( mavenOneRepository == null )
+ {
+ mavenOneRepository = System.getProperty( "user.home" ) + "/.maven/repository";
+ }
+ }
+
+ File f = new File( mavenOneRepository );
+ if ( !f.exists() )
+ {
+ f.mkdirs();
+ }
+
+ ArtifactRepository localRepository = factory.createDeploymentArtifactRepository( "mavenOneRepository",
+ f.toURL().toString(),
+ legacyLayout, false );
+
+ boolean isPomArtifact = "pom".equals( packaging );
+
+ if ( isPomArtifact )
+ {
+ installer.install( pomFile, artifact, localRepository );
+ }
+ else
+ {
+ File file = artifact.getFile();
+ if ( file == null )
+ {
+ throw new MojoExecutionException(
+ "The packaging for this project did not assign a file to the build artifact" );
+ }
+ installer.install( file, artifact, localRepository );
+ }
+
+ }
+ catch ( ArtifactInstallationException e )
+ {
+ throw new MojoExecutionException( e.getMessage(), e );
+ }
+ catch ( FileNotFoundException e )
+ {
+ throw new MojoExecutionException( e.getMessage(), e );
+ }
+ catch ( IOException e )
+ {
+ throw new MojoExecutionException( e.getMessage(), e );
+ }
+ }
+}
Propchange: maven/components/trunk/sandbox/maven-one-plugin/src/main/java/org/apache/maven/plugins/MavenOneRepositoryInstallMojo.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/components/trunk/sandbox/maven-one-plugin/src/main/java/org/apache/maven/plugins/MavenOneRepositoryInstallMojo.java
------------------------------------------------------------------------------
svn:keywords = "Author Date Id Revision"
Modified: maven/components/trunk/sandbox/maven-one-plugin/src/main/resources/META-INF/plexus/components.xml
URL: http://svn.apache.org/viewcvs/maven/components/trunk/sandbox/maven-one-plugin/src/main/resources/META-INF/plexus/components.xml?rev=329973&r1=329972&r2=329973&view=diff
==============================================================================
--- maven/components/trunk/sandbox/maven-one-plugin/src/main/resources/META-INF/plexus/components.xml (original)
+++ maven/components/trunk/sandbox/maven-one-plugin/src/main/resources/META-INF/plexus/components.xml Mon Oct 31 20:57:24 2005
@@ -26,5 +26,18 @@
</configuration>
</component>
+ <component>
+ <role>org.apache.maven.artifact.handler.ArtifactHandler</role>
+ <role-hint>maven-one-plugin</role-hint>
+ <implementation>org.apache.maven.artifact.handler.DefaultArtifactHandler</implementation>
+ <configuration>
+ <type>maven-one-plugin</type>
+ <directory>plugins</directory>
+ <extension>jar</extension>
+ <language>java</language>
+ <addedToClasspath>true</addedToClasspath>
+ </configuration>
+ </component>
+
</components>
</component-set>
Added: maven/components/trunk/sandbox/maven-one-plugin/src/site/apt/introduction.apt
URL: http://svn.apache.org/viewcvs/maven/components/trunk/sandbox/maven-one-plugin/src/site/apt/introduction.apt?rev=329973&view=auto
==============================================================================
--- maven/components/trunk/sandbox/maven-one-plugin/src/site/apt/introduction.apt (added)
+++ maven/components/trunk/sandbox/maven-one-plugin/src/site/apt/introduction.apt Mon Oct 31 20:57:24 2005
@@ -0,0 +1,67 @@
+ ----------
+Maven One Plugin
+ ----------
+Brett Porter
+ ----------
+1 November 2005
+ ----------
+
+Maven One Plugin
+
+ The Maven One Plugin is a plugin for Maven 2.0 that performs some integration tasks with Maven 1.x:
+
+ * Provides a packaging for Maven 1.x plugins, building using Maven 2.0
+
+ * Provides a hook for installation that will copy built artifacts into a local Maven 1.x repository, for
+ concurrent development with Maven 1.x projects
+
+* Maven 1.x Plugin Packaging
+
+ To build a Maven 1.x plugin using Maven 2.x, you need to include this plugin in the build section, and use a
+ <<<packaging>>> of <<<maven-one-plugin>>>. The following is an example of such a POM:
+
+-------
+<project>
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>maven</groupId>
+ <artifactId>maven-site-plugin</artifactId>
+ <packaging>maven-one-plugin</packaging>
+ <version>1.6-SNAPSHOT</version>
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-one-plugin</artifactId>
+ <extensions>true</extensions>
+ </plugin>
+ </plugins>
+ </build>
+</project>
+-------
+
+* Maven 1.x Local Repository Installation
+
+ To have your artifact installed into a local Maven 1.x repository, add the following lifecycle binding to your POM:
+
+-------
+<project>
+ ...
+ <plugin>
+ <artifactId>maven-one-plugin</artifactId>
+ <executions>
+ <execution>
+ <goals>
+ <goal>install-maven-one-repository</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ ...
+</project>
+-------
+
+ <<Note:>> The plugin section can be shared with the one above in the case of building a Maven 1.x plugin.
+
+ This will read the local repository location from <<<~/build.properties>>>, defaulting to <<<~/.maven/repository>>>.
+
+ For more information, see the {{{index.html} Goal Reference}}
+
Propchange: maven/components/trunk/sandbox/maven-one-plugin/src/site/apt/introduction.apt
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/components/trunk/sandbox/maven-one-plugin/src/site/apt/introduction.apt
------------------------------------------------------------------------------
svn:keywords = "Author Date Id Revision"
Added: maven/components/trunk/sandbox/maven-one-plugin/src/site/site.xml
URL: http://svn.apache.org/viewcvs/maven/components/trunk/sandbox/maven-one-plugin/src/site/site.xml?rev=329973&view=auto
==============================================================================
--- maven/components/trunk/sandbox/maven-one-plugin/src/site/site.xml (added)
+++ maven/components/trunk/sandbox/maven-one-plugin/src/site/site.xml Mon Oct 31 20:57:24 2005
@@ -0,0 +1,22 @@
+<project name="Maven One plugin">
+ <bannerLeft>
+ <name>Maven One plugin</name>
+ <src>http://maven.apache.org/images/apache-maven-project.png</src>
+ <href>http://maven.apache.org/</href>
+ </bannerLeft>
+ <bannerRight>
+ <src>http://maven.apache.org/images/maven-small.gif</src>
+ </bannerRight>
+ <body>
+ <links>
+ <item name="Maven 2" href="http://maven.apache.org"/>
+ </links>
+
+ <menu name="Maven One Plugin">
+ <item name="Introduction" href="introduction.html"/>
+ </menu>
+
+ ${reports}
+ </body>
+</project>
+
Propchange: maven/components/trunk/sandbox/maven-one-plugin/src/site/site.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/components/trunk/sandbox/maven-one-plugin/src/site/site.xml
------------------------------------------------------------------------------
svn:keywords = "Author Date Id Revision"