mirror of https://github.com/apache/maven.git
*** empty log message ***
git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@162928 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
601320d28f
commit
d83868e9cd
|
@ -7,11 +7,11 @@
|
|||
<artifactId>maven-plugin-parent</artifactId>
|
||||
<version>2.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<groupId>maven-clean-plugin</groupId>
|
||||
<groupId>maven</groupId>
|
||||
<artifactId>maven-clean-plugin</artifactId>
|
||||
<type>plugin</type>
|
||||
<name>Maven Clean Plugin</name>
|
||||
<currentVersion>1.0-SNAPSHOT</currentVersion>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
<inceptionYear>2001</inceptionYear>
|
||||
<package>org.apache.maven.plugin.clean</package>
|
||||
</project>
|
||||
|
|
|
@ -15,6 +15,11 @@
|
|||
<inceptionYear>2001</inceptionYear>
|
||||
<package>org.apache.maven</package>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>plexus</groupId>
|
||||
<artifactId>plexus</artifactId>
|
||||
<version>0.16-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>plexus</groupId>
|
||||
<artifactId>plexus-compiler-api</artifactId>
|
||||
|
|
|
@ -20,5 +20,20 @@
|
|||
<artifactId>maven-core</artifactId>
|
||||
<version>2.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>maven</groupId>
|
||||
<artifactId>maven-model</artifactId>
|
||||
<version>2.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>maven</groupId>
|
||||
<artifactId>maven-artifact</artifactId>
|
||||
<version>2.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>maven</groupId>
|
||||
<artifactId>wagon-api</artifactId>
|
||||
<version>1.0-alpha-1-SNAPSHOT</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
|
|
|
@ -16,62 +16,61 @@ package org.apache.maven.plugin.install;
|
|||
* 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 <a href="mailto:michal@codehaus.org">Michal Maczka</a>
|
||||
* @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 );
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -14,6 +14,11 @@
|
|||
<version>1.0-SNAPSHOT</version>
|
||||
<package>org.apache.maven.plugin.jar</package>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>plexus</groupId>
|
||||
<artifactId>plexus</artifactId>
|
||||
<version>0.16-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>maven</groupId>
|
||||
<artifactId>maven-artifact</artifactId>
|
||||
|
@ -24,5 +29,15 @@
|
|||
<artifactId>maven-core</artifactId>
|
||||
<version>2.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>maven</groupId>
|
||||
<artifactId>maven-model</artifactId>
|
||||
<version>2.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>maven</groupId>
|
||||
<artifactId>wagon-api</artifactId>
|
||||
<version>1.0-alpha-1-SNAPSHOT</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
|
|
|
@ -17,24 +17,21 @@ package org.apache.maven.plugin.jar;
|
|||
* 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 @@ 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, 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 @@ public abstract class AbstractJarMojo
|
|||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
/**
|
||||
* Add all files in the specified directory to the archive.
|
||||
|
@ -95,31 +98,33 @@ public abstract class AbstractJarMojo
|
|||
* @param includes a map <String, File> 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 <String, File> 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 <String, File> of items to be include in the outpur
|
||||
* @param includes a map <String, File> 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 @@ public abstract class AbstractJarMojo
|
|||
}
|
||||
|
||||
DirectoryScanner scanner = new DirectoryScanner();
|
||||
scanner.setBasedir(baseDir);
|
||||
scanner.setBasedir( baseDir );
|
||||
if ( includesPattern != null )
|
||||
{
|
||||
scanner.setIncludes( StringUtils.split( includesPattern, "," ) );
|
||||
|
@ -140,10 +145,11 @@ public abstract class AbstractJarMojo
|
|||
}
|
||||
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 @@ public abstract class AbstractJarMojo
|
|||
* @param includes a Map<String, File>of 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 @@ public abstract class AbstractJarMojo
|
|||
*
|
||||
* @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 @@ public abstract class AbstractJarMojo
|
|||
* @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 @@ public abstract class AbstractJarMojo
|
|||
* @param includes a Map<String, File> 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 @@ public abstract class AbstractJarMojo
|
|||
* @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();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,6 +22,10 @@ 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.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 @@ import java.io.File;
|
|||
/**
|
||||
* @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 );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,53 +16,43 @@ package org.apache.maven.plugin.jar;
|
|||
* 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 );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
<artifactId>maven-plugin-parent</artifactId>
|
||||
<version>2.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<groupId>maven-plugin-plugin</groupId>
|
||||
<groupId>maven</groupId>
|
||||
<artifactId>maven-plugin-plugin</artifactId>
|
||||
<type>plugin</type>
|
||||
<name>Maven</name>
|
||||
|
@ -17,7 +17,7 @@
|
|||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>maven</groupId>
|
||||
<artifactId>maven-core</artifactId>
|
||||
<artifactId>maven-plugin-tools</artifactId>
|
||||
<version>2.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
|
|
@ -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 <a href="mailto:trygvis@inamo.no">Trygve Laugstøl</a>
|
||||
* @author <a href="mailto:michal@codehaus.org">Michal Maczka</a>
|
||||
* @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 );
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -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 <a href="mailto:trygvis@inamo.no">Trygve Laugstøl</a>
|
||||
* @author <a href="mailto:michal@codehaus.org">Michal Maczka</a>
|
||||
* @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 );
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -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 <a href="mailto:michal@codehaus.org">Michal Maczka</a>
|
||||
* @version $Id$
|
||||
*/
|
||||
public class PluginMojo extends AbstractPlugin
|
||||
{
|
||||
|
||||
public void execute( PluginExecutionRequest request, PluginExecutionResponse response ) throws Exception
|
||||
{
|
||||
|
||||
}
|
||||
}
|
|
@ -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 <a href="mailto:trygvis@inamo.no">Trygve Laugstøl</a>
|
||||
* @author <a href="mailto:michal@codehaus.org">Michal Maczka</a>
|
||||
* @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;
|
||||
}
|
||||
}
|
|
@ -12,14 +12,26 @@
|
|||
<name>Maven POM Plugin</name>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
<package>org.apache.maven.plugin.pom</package>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>maven</groupId>
|
||||
<artifactId>maven-core</artifactId>
|
||||
<version>2.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>maven</groupId>
|
||||
<artifactId>maven-artifact</artifactId>
|
||||
<version>2.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>maven</groupId>
|
||||
<artifactId>maven-model</artifactId>
|
||||
<version>2.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>maven</groupId>
|
||||
<artifactId>wagon-api</artifactId>
|
||||
<version>1.0-alpha-1-SNAPSHOT</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
|
||||
</project>
|
||||
|
|
|
@ -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 @@ package org.apache.maven.plugin.jar;
|
|||
* 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 class PomDeployMojo
|
|||
|
||||
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 );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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 @@ package org.apache.maven.plugin.jar;
|
|||
* 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 class PomInstallMojo
|
|||
|
||||
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 );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,6 +24,11 @@
|
|||
<artifactId>maven-model</artifactId>
|
||||
<version>2.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>plexus</groupId>
|
||||
<artifactId>plexus</artifactId>
|
||||
<version>0.16-SNAPSHOT</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<build>
|
||||
<unitTest>
|
||||
|
|
|
@ -46,41 +46,11 @@
|
|||
</developers>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>maven</groupId>
|
||||
<artifactId>maven-model</artifactId>
|
||||
<version>2.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>maven</groupId>
|
||||
<artifactId>maven-plugin</artifactId>
|
||||
<version>2.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>maven</groupId>
|
||||
<artifactId>wagon-api</artifactId>
|
||||
<version>0.9-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<!-- This will soon be a transitive dep -->
|
||||
<dependency>
|
||||
<groupId>plexus</groupId>
|
||||
<artifactId>plexus</artifactId>
|
||||
<version>0.14-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>classworlds</groupId>
|
||||
<artifactId>classworlds</artifactId>
|
||||
<version>1.1-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>xstream</groupId>
|
||||
<artifactId>xstream</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>xpp3</groupId>
|
||||
<artifactId>xpp3</artifactId>
|
||||
<version>1.1.3.3</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
|
|
Loading…
Reference in New Issue