diff --git a/maven-plugins/maven-clean-plugin/pom.xml b/maven-plugins/maven-clean-plugin/pom.xml index fc3c0633a3..44d13806b8 100644 --- a/maven-plugins/maven-clean-plugin/pom.xml +++ b/maven-plugins/maven-clean-plugin/pom.xml @@ -7,11 +7,11 @@ maven-plugin-parent 2.0-SNAPSHOT - maven-clean-plugin + maven maven-clean-plugin plugin Maven Clean Plugin - 1.0-SNAPSHOT + 1.0-SNAPSHOT 2001 org.apache.maven.plugin.clean diff --git a/maven-plugins/maven-compiler-plugin/pom.xml b/maven-plugins/maven-compiler-plugin/pom.xml index cae4a0e8b6..282bafe1d6 100644 --- a/maven-plugins/maven-compiler-plugin/pom.xml +++ b/maven-plugins/maven-compiler-plugin/pom.xml @@ -15,6 +15,11 @@ 2001 org.apache.maven + + plexus + plexus + 0.16-SNAPSHOT + plexus plexus-compiler-api diff --git a/maven-plugins/maven-install-plugin/pom.xml b/maven-plugins/maven-install-plugin/pom.xml index e76cb106f3..b885b6662b 100644 --- a/maven-plugins/maven-install-plugin/pom.xml +++ b/maven-plugins/maven-install-plugin/pom.xml @@ -20,5 +20,20 @@ maven-core 2.0-SNAPSHOT + + maven + maven-model + 2.0-SNAPSHOT + + + maven + maven-artifact + 2.0-SNAPSHOT + + + maven + wagon-api + 1.0-alpha-1-SNAPSHOT + diff --git a/maven-plugins/maven-install-plugin/src/main/java/org/apache/maven/plugin/install/InstallMojo.java b/maven-plugins/maven-install-plugin/src/main/java/org/apache/maven/plugin/install/InstallMojo.java index e89990fab4..f1279eee3a 100644 --- a/maven-plugins/maven-install-plugin/src/main/java/org/apache/maven/plugin/install/InstallMojo.java +++ b/maven-plugins/maven-install-plugin/src/main/java/org/apache/maven/plugin/install/InstallMojo.java @@ -16,62 +16,61 @@ * limitations under the License. */ +import org.apache.maven.artifact.Artifact; +import org.apache.maven.artifact.DefaultArtifact; +import org.apache.maven.artifact.installer.ArtifactInstaller; +import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.plugin.AbstractPlugin; import org.apache.maven.plugin.PluginExecutionRequest; import org.apache.maven.plugin.PluginExecutionResponse; import org.apache.maven.project.MavenProject; -import org.apache.maven.Maven; - -import java.util.ArrayList; -import java.util.List; /** * @goal install * * @description installs project's main artifact in local repository * -* @parameter - * name="project" - * type="org.apache.maven.project.MavenProject" - * required="true" - * validator="" - * expression="#project" - * description="" + * @parameter name="project" + * type="org.apache.maven.project.MavenProject" + * required="true" + * validator="" + * expression="#project" + * description="" * - * @parameter - * name="maven" - * type="org.apache.maven.Maven" - * required="true" - * validator="" - * expression="#component.org.apache.maven.Maven" - * description="""" + * @parameter name="installer" + * type="org.apache.maven.artifact.installer.ArtifactInstaller" + * required="true" + * validator="" + * expression="#component.org.apache.maven.artifact.installer.ArtifactInstaller" + * description="" + * + * @parameter name="localRepository" + * type="org.apache.maven.artifact.repository.ArtifactRepository" + * required="true" + * validator="" + * expression="#localRepository" + * description="" + * + * @prereq build * - * @author Michal Maczka - * @version $Id$ */ public class InstallMojo extends AbstractPlugin { - public void execute( PluginExecutionRequest request, PluginExecutionResponse response ) throws Exception { - MavenProject project = (MavenProject) request.getParameter( "project" ); - String type = project.getType(); + ArtifactInstaller artifactInstaller = (ArtifactInstaller) request.getParameter( "installer" ); - Maven maven = ( Maven ) request.getParameter( "maven" ); + ArtifactRepository localRepository = (ArtifactRepository) request.getParameter( "localRepository" ); - String goal = type + ":install"; - - List goals = new ArrayList( 1 ); - - goals.add( goal ); - - maven.execute( project, goals ); + Artifact artifact = new DefaultArtifact( project.getGroupId(), + project.getArtifactId(), + project.getVersion(), + project.getType() ); + artifactInstaller.install( project.getBuild().getDirectory(), artifact, localRepository ); } - - } diff --git a/maven-plugins/maven-jar-plugin/pom.xml b/maven-plugins/maven-jar-plugin/pom.xml index 7e4199dd2d..23a1f091da 100644 --- a/maven-plugins/maven-jar-plugin/pom.xml +++ b/maven-plugins/maven-jar-plugin/pom.xml @@ -14,6 +14,11 @@ 1.0-SNAPSHOT org.apache.maven.plugin.jar + + plexus + plexus + 0.16-SNAPSHOT + maven maven-artifact @@ -24,5 +29,15 @@ maven-core 2.0-SNAPSHOT + + maven + maven-model + 2.0-SNAPSHOT + + + maven + wagon-api + 1.0-alpha-1-SNAPSHOT + diff --git a/maven-plugins/maven-jar-plugin/src/main/java/org/apache/maven/plugin/jar/AbstractJarMojo.java b/maven-plugins/maven-jar-plugin/src/main/java/org/apache/maven/plugin/jar/AbstractJarMojo.java index 3c28c0a330..3fc46ec0e7 100644 --- a/maven-plugins/maven-jar-plugin/src/main/java/org/apache/maven/plugin/jar/AbstractJarMojo.java +++ b/maven-plugins/maven-jar-plugin/src/main/java/org/apache/maven/plugin/jar/AbstractJarMojo.java @@ -17,24 +17,21 @@ * limitations under the License. */ +import org.apache.maven.plugin.AbstractPlugin; +import org.codehaus.plexus.util.DirectoryScanner; +import org.codehaus.plexus.util.StringUtils; + import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.util.Iterator; import java.util.Map; -import java.util.Properties; import java.util.jar.Attributes; import java.util.jar.JarEntry; import java.util.jar.JarOutputStream; import java.util.jar.Manifest; -import org.apache.maven.artifact.MavenArtifact; -import org.apache.maven.plugin.AbstractPlugin; -import org.apache.maven.project.MavenProject; -import org.codehaus.plexus.util.DirectoryScanner; -import org.codehaus.plexus.util.StringUtils; - /** * Base class for tasks that build archives in JAR file format. * @@ -52,9 +49,12 @@ public abstract class AbstractJarMojo * @param tag the property tag to look for; for example "jar.bundle" * @param pathTag the property tag that specifies the target path; for example, jar.target.path */ + + /* protected void addTaggedDependencies(Map includes, MavenProject project, String tag, String pathTag) { addTaggedDependencies(includes, "", project, tag, pathTag); } + */ /** * Add artifacts from tagged dependencies to the archive. For example, the definition: @@ -77,9 +77,11 @@ protected void addTaggedDependencies(Map includes, MavenProject project, String * @param tag the property tag to look for; for example "jar.bundle" * @param pathTag the property tag that specifies the target path; for example, jar.target.path */ + + /* protected void addTaggedDependencies(Map includes, String prefix, MavenProject project, String tag, String pathTag) { for (Iterator i = project.getArtifacts().iterator(); i.hasNext();) { - MavenArtifact artifact = (MavenArtifact) i.next(); + Artifact artifact = (Artifact) i.next(); Properties properties = artifact.getDependency().getProperties(); if (Boolean.valueOf(properties.getProperty(tag)).booleanValue()) { File file = new File(artifact.getPath()); @@ -88,6 +90,7 @@ protected void addTaggedDependencies(Map includes, String prefix, MavenProject p } } } + */ /** * Add all files in the specified directory to the archive. @@ -95,31 +98,33 @@ protected void addTaggedDependencies(Map includes, String prefix, MavenProject p * @param includes a map of items to be include in the outpur * @param baseDir the directory to add */ - protected void addDirectory(Map includes, File baseDir) throws IOException { - addDirectory(includes, "", baseDir); + protected void addDirectory( Map includes, File baseDir ) throws IOException + { + addDirectory( includes, "", baseDir ); } /** * Add all files in the specified directory to the archive. * * @param includes a map of items to be include in the outpur - * @param prefix value to be added to the front of jar entry names + * @param prefix value to be added to the front of jar entry names * @param baseDir the directory to add */ - protected void addDirectory(Map includes, String prefix, File baseDir) throws IOException { + protected void addDirectory( Map includes, String prefix, File baseDir ) throws IOException + { addDirectory( includes, null, null, prefix, baseDir ); } /** * Add all files in the specified directory to the archive. * - * @param includes a map of items to be include in the outpur + * @param includes a map of items to be include in the outpur * @param includesPattern Sets the list of include patterns to use * @param excludesPattern Sets the list of exclude patterns to use - * @param prefix value to be added to the front of jar entry names - * @param baseDir the directory to add + * @param prefix value to be added to the front of jar entry names + * @param baseDir the directory to add */ - protected void addDirectory(Map includes, String includesPattern, String excludesPattern, String prefix, File baseDir) + protected void addDirectory( Map includes, String includesPattern, String excludesPattern, String prefix, File baseDir ) throws IOException { if ( !baseDir.exists() ) @@ -128,7 +133,7 @@ protected void addDirectory(Map includes, String includesPattern, String exclude } DirectoryScanner scanner = new DirectoryScanner(); - scanner.setBasedir(baseDir); + scanner.setBasedir( baseDir ); if ( includesPattern != null ) { scanner.setIncludes( StringUtils.split( includesPattern, "," ) ); @@ -140,10 +145,11 @@ protected void addDirectory(Map includes, String includesPattern, String exclude } scanner.scan(); String[] files = scanner.getIncludedFiles(); - for (int i = 0; i < files.length; i++) { + for ( int i = 0; i < files.length; i++ ) + { String file = files[i]; - file = file.replace('\\', '/'); // todo shouldn't the scanner return platform independent names? - includes.put(prefix + file, new File(baseDir, file)); + file = file.replace( '\\', '/' ); // todo shouldn't the scanner return platform independent names? + includes.put( prefix + file, new File( baseDir, file ) ); } } @@ -154,16 +160,20 @@ protected void addDirectory(Map includes, String includesPattern, String exclude * @param includes a Mapof items to include; the key is the jar entry name * @throws IOException if there is a problem writing the archive or reading the sources */ - protected void createJar(File jarFile, Map includes) throws IOException { + protected void createJar( File jarFile, Map includes ) throws IOException + { File parentJarFile = jarFile.getParentFile(); if ( !parentJarFile.exists() ) { parentJarFile.mkdirs(); } - JarOutputStream jos = createJar(jarFile, createManifest()); - try { - addEntries(jos, includes); - } finally { + JarOutputStream jos = createJar( jarFile, createManifest() ); + try + { + addEntries( jos, includes ); + } + finally + { jos.close(); } } @@ -173,11 +183,12 @@ protected void createJar(File jarFile, Map includes) throws IOException { * * @return a default manifest; the Manifest-Version and Created-By attributes are initialized */ - protected Manifest createManifest() { + protected Manifest createManifest() + { Manifest mf = new Manifest(); Attributes attrs = mf.getMainAttributes(); - attrs.putValue(Attributes.Name.MANIFEST_VERSION.toString(), "1.0"); - attrs.putValue("Created-By", "2.0 (Apache Maven)"); + attrs.putValue( Attributes.Name.MANIFEST_VERSION.toString(), "1.0" ); + attrs.putValue( "Created-By", "2.0 (Apache Maven)" ); return mf; } @@ -189,16 +200,23 @@ protected Manifest createManifest() { * @return a JarOutputStream that can be used to write to that file * @throws IOException if there was a problem opening the file */ - protected JarOutputStream createJar(File jarFile, Manifest mf) throws IOException { + protected JarOutputStream createJar( File jarFile, Manifest mf ) throws IOException + { jarFile.getParentFile().mkdirs(); - FileOutputStream fos = new FileOutputStream(jarFile); - try { - return new JarOutputStream(fos, mf); - } catch (IOException e) { - try { + FileOutputStream fos = new FileOutputStream( jarFile ); + try + { + return new JarOutputStream( fos, mf ); + } + catch ( IOException e ) + { + try + { fos.close(); jarFile.delete(); - } catch (IOException e1) { + } + catch ( IOException e1 ) + { // ignore } throw e; @@ -212,12 +230,14 @@ protected JarOutputStream createJar(File jarFile, Manifest mf) throws IOExceptio * @param includes a Map of entries to add * @throws IOException if there is a problem writing the archive or reading the sources */ - protected void addEntries(JarOutputStream jos, Map includes) throws IOException { - for (Iterator i = includes.entrySet().iterator(); i.hasNext();) { + protected void addEntries( JarOutputStream jos, Map includes ) throws IOException + { + for ( Iterator i = includes.entrySet().iterator(); i.hasNext(); ) + { Map.Entry entry = (Map.Entry) i.next(); String name = (String) entry.getKey(); File file = (File) entry.getValue(); - addEntry(jos, name, file); + addEntry( jos, name, file ); } } @@ -229,16 +249,21 @@ protected void addEntries(JarOutputStream jos, Map includes) throws IOException * @param source the file to add * @throws IOException if there is a problem writing the archive or reading the sources */ - protected void addEntry(JarOutputStream jos, String name, File source) throws IOException { - FileInputStream fis = new FileInputStream(source); - try { - jos.putNextEntry(new JarEntry(name)); + protected void addEntry( JarOutputStream jos, String name, File source ) throws IOException + { + FileInputStream fis = new FileInputStream( source ); + try + { + jos.putNextEntry( new JarEntry( name ) ); int count; - while ((count = fis.read(buffer)) > 0) { - jos.write(buffer, 0, count); + while ( ( count = fis.read( buffer ) ) > 0 ) + { + jos.write( buffer, 0, count ); } jos.closeEntry(); - } finally { + } + finally + { fis.close(); } } diff --git a/maven-plugins/maven-jar-plugin/src/main/java/org/apache/maven/plugin/jar/JarDeployMojo.java b/maven-plugins/maven-jar-plugin/src/main/java/org/apache/maven/plugin/jar/JarDeployMojo.java index 511b21aa23..8589cb96cd 100644 --- a/maven-plugins/maven-jar-plugin/src/main/java/org/apache/maven/plugin/jar/JarDeployMojo.java +++ b/maven-plugins/maven-jar-plugin/src/main/java/org/apache/maven/plugin/jar/JarDeployMojo.java @@ -22,6 +22,10 @@ import org.apache.maven.project.MavenProject; import org.apache.maven.artifact.installer.ArtifactInstaller; import org.apache.maven.artifact.deployer.ArtifactDeployer; +import org.apache.maven.artifact.repository.ArtifactRepository; +import org.apache.maven.artifact.Artifact; +import org.apache.maven.artifact.DefaultArtifact; +import org.apache.maven.repository.RepositoryUtils; import org.codehaus.plexus.util.FileUtils; import java.io.File; @@ -29,25 +33,7 @@ /** * @goal deploy * - * @description deploys a jar to remote repository - * - * @prereq jar:jar - * - * @parameter - * name="jarName" - * type="String" - * required="true" - * validator="" - * expression="#maven.final.name" - * description="" - * - * @parameter - * name="outputDirectory" - * type="String" - * required="true" - * validator="" - * expression="#project.build.directory" - * description="" + * @description deploys a JAR to remote repository * * @parameter * name="project" @@ -71,16 +57,18 @@ public class JarDeployMojo public void execute( PluginExecutionRequest request, PluginExecutionResponse response ) throws Exception { - String outputDirectory = (String) request.getParameter( "outputDirectory" ); - - String jarName = (String) request.getParameter( "jarName" ); - - File jarFile = new File( outputDirectory, jarName + ".jar" ); - MavenProject project = (MavenProject) request.getParameter( "project" ); ArtifactDeployer artifactDeployer = (ArtifactDeployer) request.getParameter( "deployer" ); - artifactDeployer.deploy( jarFile, "jar", project ); + ArtifactRepository deploymentRepository = + RepositoryUtils.mavenRepositoryToWagonRepository( project.getDistributionManagement().getRepository() ); + + Artifact artifact = new DefaultArtifact( project.getGroupId(), + project.getArtifactId(), + project.getVersion(), + project.getType() ); + + artifactDeployer.deploy( project.getBuild().getDirectory(), artifact, deploymentRepository ); } } diff --git a/maven-plugins/maven-jar-plugin/src/main/java/org/apache/maven/plugin/jar/JarInstallMojo.java b/maven-plugins/maven-jar-plugin/src/main/java/org/apache/maven/plugin/jar/JarInstallMojo.java index dde0124047..7fe2673325 100644 --- a/maven-plugins/maven-jar-plugin/src/main/java/org/apache/maven/plugin/jar/JarInstallMojo.java +++ b/maven-plugins/maven-jar-plugin/src/main/java/org/apache/maven/plugin/jar/JarInstallMojo.java @@ -16,53 +16,43 @@ * limitations under the License. */ +import org.apache.maven.artifact.Artifact; +import org.apache.maven.artifact.DefaultArtifact; +import org.apache.maven.artifact.installer.ArtifactInstaller; +import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.plugin.AbstractPlugin; import org.apache.maven.plugin.PluginExecutionRequest; import org.apache.maven.plugin.PluginExecutionResponse; import org.apache.maven.project.MavenProject; -import org.apache.maven.artifact.installer.ArtifactInstaller; -import org.codehaus.plexus.util.FileUtils; - -import java.io.File; /** * @goal install * - * @description install a jar in local repository + * @description installs project's main artifact in local repository + * + * @parameter name="project" + * type="org.apache.maven.project.MavenProject" + * required="true" + * validator="" + * expression="#project" + * description="" + * + * @parameter name="installer" + * type="org.apache.maven.artifact.installer.ArtifactInstaller" + * required="true" + * validator="" + * expression="#component.org.apache.maven.artifact.installer.ArtifactInstaller" + * description="" + * + * @parameter name="localRepository" + * type="org.apache.maven.artifact.repository.ArtifactRepository" + * required="true" + * validator="" + * expression="#localRepository" + * description="" * * @prereq jar:jar * - * @parameter - * name="jarName" - * type="String" - * required="true" - * validator="" - * expression="#maven.final.name" - * description="" - * - * @parameter - * name="outputDirectory" - * type="String" - * required="true" - * validator="" - * expression="#project.build.directory" - * description="" - * - * @parameter - * name="project" - * type="org.apache.maven.project.MavenProject" - * required="true" - * validator="" - * expression="#project" - * description="" - * - * @parameter - * name="installer" - * type="org.apache.maven.artifact.installer.ArtifactInstaller" - * required="true" - * validator="" - * expression="#component.org.apache.maven.artifact.installer.ArtifactInstaller" - * description="" */ public class JarInstallMojo extends AbstractPlugin @@ -70,16 +60,17 @@ public class JarInstallMojo public void execute( PluginExecutionRequest request, PluginExecutionResponse response ) throws Exception { - String outputDirectory = (String) request.getParameter( "outputDirectory" ); - - String jarName = (String) request.getParameter( "jarName" ); - - File jarFile = new File( outputDirectory, jarName + ".jar" ); - MavenProject project = (MavenProject) request.getParameter( "project" ); ArtifactInstaller artifactInstaller = (ArtifactInstaller) request.getParameter( "installer" ); - artifactInstaller.install( jarFile, "jar", project ); + ArtifactRepository localRepository = (ArtifactRepository) request.getParameter( "localRepository" ); + + Artifact artifact = new DefaultArtifact( project.getGroupId(), + project.getArtifactId(), + project.getVersion(), + project.getType() ); + + artifactInstaller.install( project.getBuild().getDirectory(), artifact, localRepository ); } } diff --git a/maven-plugins/maven-plugin-plugin/pom.xml b/maven-plugins/maven-plugin-plugin/pom.xml index fd633873c9..b8c096c531 100644 --- a/maven-plugins/maven-plugin-plugin/pom.xml +++ b/maven-plugins/maven-plugin-plugin/pom.xml @@ -7,7 +7,7 @@ maven-plugin-parent 2.0-SNAPSHOT - maven-plugin-plugin + maven maven-plugin-plugin plugin Maven @@ -17,7 +17,7 @@ maven - maven-core + maven-plugin-tools 2.0-SNAPSHOT diff --git a/maven-plugins/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/PluginDeployMojo.java b/maven-plugins/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/PluginDeployMojo.java deleted file mode 100644 index a85efe60be..0000000000 --- a/maven-plugins/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/PluginDeployMojo.java +++ /dev/null @@ -1,79 +0,0 @@ -package org.apache.maven.plugin.plugin; - -import java.io.File; - -import org.apache.maven.plugin.AbstractPlugin; -import org.apache.maven.plugin.PluginExecutionRequest; -import org.apache.maven.plugin.PluginExecutionResponse; -import org.apache.maven.project.MavenProject; -import org.apache.maven.artifact.installer.ArtifactInstaller; -import org.apache.maven.artifact.deployer.ArtifactDeployer; - -import org.codehaus.plexus.util.FileUtils; - -/* - * LICENSE - */ - -/** - * @goal deploy - * - * @description Installs a plugin into local repository - * - * @prereq plugin:plugin - * - * @parameter - * name="outputDirectory" - * type="String" - * required="true" - * validator="" - * expression="#project.build.directory" - * description="" - * - * @parameter - * name="jarName" - * type="String" - * required="true" - * validator="" - * expression="#maven.final.name" - * description="" - * - * @parameter - * name="project" - * type="org.apache.maven.project.MavenProject" - * required="true" - * validator="" - * expression="#project" - * description="" - * - * @parameter - * name="deployer" - * type="org.apache.maven.artifact.deployer.ArtifactDeployer" - * required="true" - * validator="" - * expression="#component.org.apache.maven.artifact.deployer.ArtifactDeployer" - * description="" - * - * @author Trygve Laugstøl - * @author Michal Maczka - * @version $Id$ - */ -public class PluginDeployMojo - extends AbstractPluginMojo -{ - public void execute( PluginExecutionRequest request, PluginExecutionResponse response ) - throws Exception - { - - File jarFile = getJarFile( request ); - - MavenProject project = (MavenProject) request.getParameter( "project" ); - - ArtifactDeployer artifactDeployer = ( ArtifactDeployer ) request.getParameter( "deployer" ); - - artifactDeployer.deploy( jarFile, "plugin", project ); - - } - - -} diff --git a/maven-plugins/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/PluginInstallMojo.java b/maven-plugins/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/PluginInstallMojo.java deleted file mode 100644 index 64a52d0ac0..0000000000 --- a/maven-plugins/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/PluginInstallMojo.java +++ /dev/null @@ -1,81 +0,0 @@ -package org.apache.maven.plugin.plugin; - -import java.io.File; - -import org.apache.maven.plugin.AbstractPlugin; -import org.apache.maven.plugin.PluginExecutionRequest; -import org.apache.maven.plugin.PluginExecutionResponse; -import org.apache.maven.project.MavenProject; -import org.apache.maven.artifact.installer.ArtifactInstaller; - -import org.codehaus.plexus.util.FileUtils; - -/* - * LICENSE - */ - -/** - * @goal install - * - * @description Installs a plugin into local repository - * - * @prereq plugin:plugin - * - * @parameter - * name="outputDirectory" - * type="String" - * required="true" - * validator="" - * expression="#project.build.directory" - * description="" - * - * @parameter - * name="jarName" - * type="String" - * required="true" - * validator="" - * expression="#maven.final.name" - * description="" - * - * @parameter - * name="project" - * type="org.apache.maven.project.MavenProject" - * required="true" - * validator="" - * expression="#project" - * description="" - * - * @parameter - * name="installer" - * type="org.apache.maven.artifact.installer.ArtifactInstaller" - * required="true" - * validator="" - * expression="#component.org.apache.maven.artifact.installer.ArtifactInstaller" - * description="" - * - * @author Trygve Laugstøl - * @author Michal Maczka - * @version $Id$ - */ -public class PluginInstallMojo - extends AbstractPluginMojo -{ - public void execute( PluginExecutionRequest request, PluginExecutionResponse response ) - throws Exception - { - - File jarFile = getJarFile( request ); - - MavenProject project = (MavenProject) request.getParameter( "project" ); - - ArtifactInstaller artifactInstaller = (ArtifactInstaller) request.getParameter( "installer" ); - - System.out.println( "artifactInstaller: " + artifactInstaller ); - - artifactInstaller.install( jarFile, "plugin", project ); - - - } - - -} diff --git a/maven-plugins/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/PluginMojo.java b/maven-plugins/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/PluginMojo.java deleted file mode 100644 index 908cdb175f..0000000000 --- a/maven-plugins/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/PluginMojo.java +++ /dev/null @@ -1,27 +0,0 @@ -package org.apache.maven.plugin.plugin; - -import org.apache.maven.plugin.AbstractPlugin; -import org.apache.maven.plugin.PluginExecutionRequest; -import org.apache.maven.plugin.PluginExecutionResponse; - -/** - * @goal plugin - * - * @description Creates a plugin jar - * - * @prereq plugin:descriptor - * - * @prereq jar:jar - * - * - * @author Michal Maczka - * @version $Id$ - */ -public class PluginMojo extends AbstractPlugin -{ - - public void execute( PluginExecutionRequest request, PluginExecutionResponse response ) throws Exception - { - - } -} diff --git a/maven-plugins/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/PluginSetupMojo.java b/maven-plugins/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/PluginSetupMojo.java deleted file mode 100644 index 61799bac66..0000000000 --- a/maven-plugins/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/PluginSetupMojo.java +++ /dev/null @@ -1,121 +0,0 @@ -package org.apache.maven.plugin.plugin; - -import java.io.File; - -import org.apache.maven.plugin.AbstractPlugin; -import org.apache.maven.plugin.PluginExecutionRequest; -import org.apache.maven.plugin.PluginExecutionResponse; - -import org.codehaus.plexus.util.FileUtils; - -/* - * LICENSE - */ - -/** - * @goal setup - * - * @description Installs a plugin into the maven installation. - * - * @prereq plugin:plugin - * - * @parameter - * name="outputDirectory" - * type="String" - * required="true" - * validator="" - * expression="#project.build.directory" - * description="" - * - * @parameter - * name="jarName" - * type="String" - * required="true" - * validator="" - * expression="#maven.final.name" - * description="" - * - * @parameter - * name="pluginHome" - * type="String" - * required="true" - * validator="" - * expression="#maven.plugin.home" - * description="" - * - * @author Trygve Laugstøl - * @author Michal Maczka - * @version $Id$ - */ -public class PluginSetupMojo - extends AbstractPluginMojo -{ - public void execute( PluginExecutionRequest request, PluginExecutionResponse response ) - throws Exception - { - - - String pluginHomeName = (String) request.getParameter( "pluginHome" ); - - // ---------------------------------------------------------------------- - // - // ---------------------------------------------------------------------- - - File jarFile = getJarFile( request ); - - File pluginHome = getPluginHome( pluginHomeName ); - - System.out.println( "Installing " + jarFile + " in " + pluginHome ); - - FileUtils.copyFileToDirectory( jarFile, pluginHome ); - } - - private File getPluginHome( String pluginHomeName ) - throws Exception - { - File pluginHome; - - if ( pluginHomeName == null || - pluginHomeName.trim().length() == 0 || - pluginHomeName.equals( "maven.plugin.home" ) ) - { - String mavenHomeName = System.getProperty( "maven.home" ); - - if ( mavenHomeName == null ) - { - String userHomeName = System.getProperty( "user.home" ); - - System.out.println( "userHomeName: " + userHomeName ); - - File mavenHome = new File( userHomeName, ".m2" ); - - if ( !mavenHome.exists() ) - { - mavenHome = new File( userHomeName, "m2" ); - - if ( !mavenHome.exists() ) - { - pluginHome = new File( mavenHome, "plugins" ); - } - else - { - throw new Exception( "Cannot find the maven plugins directory." ); - } - } - else - { - pluginHome = new File( mavenHome, "plugins" ); - } - } - else - { - pluginHome = new File( mavenHomeName, "plugins" ); - } - } - else - { - pluginHome = new File( pluginHomeName ); - } - return pluginHome; - } -} diff --git a/maven-plugins/maven-pom-plugin/pom.xml b/maven-plugins/maven-pom-plugin/pom.xml index ee820a9efc..82a34c385f 100644 --- a/maven-plugins/maven-pom-plugin/pom.xml +++ b/maven-plugins/maven-pom-plugin/pom.xml @@ -12,14 +12,26 @@ Maven POM Plugin 1.0-SNAPSHOT org.apache.maven.plugin.pom - maven maven-core 2.0-SNAPSHOT + + maven + maven-artifact + 2.0-SNAPSHOT + + + maven + maven-model + 2.0-SNAPSHOT + + + maven + wagon-api + 1.0-alpha-1-SNAPSHOT + - - diff --git a/maven-plugins/maven-pom-plugin/src/main/java/org/apache/maven/plugin/pom/PomDeployMojo.java b/maven-plugins/maven-pom-plugin/src/main/java/org/apache/maven/plugin/pom/PomDeployMojo.java index fcfb8af3af..0262b74f74 100644 --- a/maven-plugins/maven-pom-plugin/src/main/java/org/apache/maven/plugin/pom/PomDeployMojo.java +++ b/maven-plugins/maven-pom-plugin/src/main/java/org/apache/maven/plugin/pom/PomDeployMojo.java @@ -1,4 +1,4 @@ -package org.apache.maven.plugin.jar; +package org.apache.maven.plugin.pom; /* * Copyright 2001-2004 The Apache Software Foundation. @@ -16,13 +16,15 @@ * limitations under the License. */ +import org.apache.maven.artifact.Artifact; +import org.apache.maven.artifact.DefaultArtifact; +import org.apache.maven.artifact.deployer.ArtifactDeployer; +import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.plugin.AbstractPlugin; import org.apache.maven.plugin.PluginExecutionRequest; import org.apache.maven.plugin.PluginExecutionResponse; import org.apache.maven.project.MavenProject; -import org.apache.maven.artifact.installer.ArtifactInstaller; -import org.apache.maven.artifact.deployer.ArtifactDeployer; -import org.codehaus.plexus.util.FileUtils; +import org.apache.maven.repository.RepositoryUtils; import java.io.File; @@ -57,6 +59,16 @@ public void execute( PluginExecutionRequest request, PluginExecutionResponse res ArtifactDeployer artifactDeployer = (ArtifactDeployer) request.getParameter( "deployer" ); - artifactDeployer.deploy( project.getFile(), "pom", project ); + ArtifactRepository deploymentRepository = + RepositoryUtils.mavenRepositoryToWagonRepository( project.getDistributionManagement().getRepository() ); + + Artifact artifact = new DefaultArtifact( project.getGroupId(), + project.getArtifactId(), + project.getVersion(), + "pom" ); + + File pom = new File( project.getFile().getParentFile(), "pom.xml" ); + + artifactDeployer.deploy( pom, artifact, deploymentRepository ); } } diff --git a/maven-plugins/maven-pom-plugin/src/main/java/org/apache/maven/plugin/pom/PomInstallMojo.java b/maven-plugins/maven-pom-plugin/src/main/java/org/apache/maven/plugin/pom/PomInstallMojo.java index c216448063..dbf5639003 100644 --- a/maven-plugins/maven-pom-plugin/src/main/java/org/apache/maven/plugin/pom/PomInstallMojo.java +++ b/maven-plugins/maven-pom-plugin/src/main/java/org/apache/maven/plugin/pom/PomInstallMojo.java @@ -1,4 +1,4 @@ -package org.apache.maven.plugin.jar; +package org.apache.maven.plugin.pom; /* * Copyright 2001-2004 The Apache Software Foundation. @@ -16,35 +16,43 @@ * limitations under the License. */ +import org.apache.maven.artifact.Artifact; +import org.apache.maven.artifact.DefaultArtifact; +import org.apache.maven.artifact.installer.ArtifactInstaller; +import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.plugin.AbstractPlugin; import org.apache.maven.plugin.PluginExecutionRequest; import org.apache.maven.plugin.PluginExecutionResponse; import org.apache.maven.project.MavenProject; -import org.apache.maven.artifact.installer.ArtifactInstaller; -import org.codehaus.plexus.util.FileUtils; import java.io.File; /** * @goal install * - * @description install a jar in local repository + * @description installs project's main artifact in local repository * - * @parameter - * name="project" - * type="org.apache.maven.project.MavenProject" - * required="true" - * validator="" - * expression="#project" - * description="" + * @parameter name="project" + * type="org.apache.maven.project.MavenProject" + * required="true" + * validator="" + * expression="#project" + * description="" + * + * @parameter name="installer" + * type="org.apache.maven.artifact.installer.ArtifactInstaller" + * required="true" + * validator="" + * expression="#component.org.apache.maven.artifact.installer.ArtifactInstaller" + * description="" + * + * @parameter name="localRepository" + * type="org.apache.maven.artifact.repository.ArtifactRepository" + * required="true" + * validator="" + * expression="#localRepository" + * description="" * - * @parameter - * name="installer" - * type="org.apache.maven.artifact.installer.ArtifactInstaller" - * required="true" - * validator="" - * expression="#component.org.apache.maven.artifact.installer.ArtifactInstaller" - * description="" */ public class PomInstallMojo extends AbstractPlugin @@ -56,6 +64,15 @@ public void execute( PluginExecutionRequest request, PluginExecutionResponse res ArtifactInstaller artifactInstaller = (ArtifactInstaller) request.getParameter( "installer" ); - artifactInstaller.install( project.getFile(), "pom", project ); + ArtifactRepository localRepository = (ArtifactRepository) request.getParameter( "localRepository" ); + + Artifact artifact = new DefaultArtifact( project.getGroupId(), + project.getArtifactId(), + project.getVersion(), + "pom" ); + + File pom = new File( project.getFile().getParentFile(), "pom.xml" ); + + artifactInstaller.install( pom, artifact, localRepository ); } } diff --git a/maven-plugins/maven-resources-plugin/pom.xml b/maven-plugins/maven-resources-plugin/pom.xml index d19f5240f3..0e68af632d 100644 --- a/maven-plugins/maven-resources-plugin/pom.xml +++ b/maven-plugins/maven-resources-plugin/pom.xml @@ -24,6 +24,11 @@ maven-model 2.0-SNAPSHOT + + plexus + plexus + 0.16-SNAPSHOT + diff --git a/maven-plugins/pom.xml b/maven-plugins/pom.xml index d90ed00530..e4fa2438d6 100644 --- a/maven-plugins/pom.xml +++ b/maven-plugins/pom.xml @@ -44,43 +44,13 @@ - + - - maven - maven-model - 2.0-SNAPSHOT - maven maven-plugin 2.0-SNAPSHOT - - maven - wagon-api - 0.9-SNAPSHOT - - - - plexus - plexus - 0.14-SNAPSHOT - - - classworlds - classworlds - 1.1-SNAPSHOT - - - xstream - xstream - 1.0-SNAPSHOT - - - xpp3 - xpp3 - 1.1.3.3 - +