Reformat code using maven style (I'm doing it because there's no patch to apply in Jira).
git-svn-id: https://svn.apache.org/repos/asf/maven/maven-1/plugins/trunk@432063 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
58bfbb114f
commit
ee6ceb3851
@ -44,23 +44,23 @@ import org.codehaus.plexus.util.IOUtil;
|
|||||||
*/
|
*/
|
||||||
public class PomRewriter
|
public class PomRewriter
|
||||||
{
|
{
|
||||||
public static File getRewrittenPom( Project project )
|
public static File getRewrittenPom( final Project project )
|
||||||
throws MavenException
|
throws MavenException
|
||||||
{
|
{
|
||||||
Model model = getRewrittenModel( project.getFile(), project.getContext() );
|
final Model model = PomRewriter.getRewrittenModel( project.getFile(), project.getContext() );
|
||||||
|
|
||||||
FileWriter w = null;
|
FileWriter w = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
MavenXpp3Writer writer = new MavenXpp3Writer();
|
final MavenXpp3Writer writer = new MavenXpp3Writer();
|
||||||
File f = File.createTempFile( "maven-artifact-plugin.", null );
|
final File f = File.createTempFile( "maven-artifact-plugin.", null );
|
||||||
f.deleteOnExit();
|
f.deleteOnExit();
|
||||||
w = new FileWriter( f );
|
w = new FileWriter( f );
|
||||||
writer.write( w, model );
|
writer.write( w, model );
|
||||||
|
|
||||||
return f;
|
return f;
|
||||||
}
|
}
|
||||||
catch ( IOException e )
|
catch ( final IOException e )
|
||||||
{
|
{
|
||||||
throw new MavenException( "Error getting the project as a string", e );
|
throw new MavenException( "Error getting the project as a string", e );
|
||||||
}
|
}
|
||||||
@ -70,7 +70,7 @@ public class PomRewriter
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static Model getRewrittenModel( File file, JellyContext context )
|
static Model getRewrittenModel( final File file, final JellyContext context )
|
||||||
throws MavenException
|
throws MavenException
|
||||||
{
|
{
|
||||||
Model model;
|
Model model;
|
||||||
@ -78,20 +78,21 @@ public class PomRewriter
|
|||||||
{
|
{
|
||||||
// Very gross, but we don't want initialize() called
|
// Very gross, but we don't want initialize() called
|
||||||
// A future version should use use project.getModel() and serialize that
|
// A future version should use use project.getModel() and serialize that
|
||||||
Method m = MavenUtils.class.getDeclaredMethod( "getNonJellyProject", new Class[]{File.class,
|
Method m = MavenUtils.class.getDeclaredMethod( "getNonJellyProject", new Class[] {
|
||||||
MavenJellyContext.class,
|
File.class,
|
||||||
boolean.class} );
|
MavenJellyContext.class,
|
||||||
|
boolean.class } );
|
||||||
m.setAccessible( true );
|
m.setAccessible( true );
|
||||||
Project p = (Project) m.invoke( null, new Object[]{file, context, Boolean.TRUE} );
|
Project p = (Project) m.invoke( null, new Object[] { file, context, Boolean.TRUE } );
|
||||||
m.setAccessible( false );
|
m.setAccessible( false );
|
||||||
m = MavenUtils.class.getDeclaredMethod( "getJellyProject", new Class[]{Project.class} );
|
m = MavenUtils.class.getDeclaredMethod( "getJellyProject", new Class[] { Project.class } );
|
||||||
m.setAccessible( true );
|
m.setAccessible( true );
|
||||||
p = (Project) m.invoke( null, new Object[]{p} );
|
p = (Project) m.invoke( null, new Object[] { p } );
|
||||||
m.setAccessible( false );
|
m.setAccessible( false );
|
||||||
// The rewrittenPOM must redefine dependencies versions
|
// The rewrittenPOM must redefine dependencies versions
|
||||||
// if override properties are used
|
// if override properties are used
|
||||||
p.buildArtifactList();
|
p.buildArtifactList();
|
||||||
|
|
||||||
// now sanitize
|
// now sanitize
|
||||||
p.setContext( null );
|
p.setContext( null );
|
||||||
p.setParent( null );
|
p.setParent( null );
|
||||||
@ -99,27 +100,27 @@ public class PomRewriter
|
|||||||
p.setDependencyVerifier( null );
|
p.setDependencyVerifier( null );
|
||||||
p.setExtend( null );
|
p.setExtend( null );
|
||||||
|
|
||||||
Map depProperties = new HashMap();
|
final Map depProperties = new HashMap();
|
||||||
for ( Iterator i = p.getDependencies().iterator(); i.hasNext(); )
|
for ( final Iterator i = p.getDependencies().iterator(); i.hasNext(); )
|
||||||
{
|
{
|
||||||
org.apache.maven.project.Dependency d = (org.apache.maven.project.Dependency) i.next();
|
final org.apache.maven.project.Dependency d = (org.apache.maven.project.Dependency) i.next();
|
||||||
Map properties = d.getProperties();
|
final Map properties = d.getProperties();
|
||||||
if ( properties != null && !properties.isEmpty() )
|
if ( ( properties != null ) && !properties.isEmpty() )
|
||||||
{
|
{
|
||||||
depProperties.put( d.getId(), properties );
|
depProperties.put( d.getId(), properties );
|
||||||
d.setProperties( null );
|
d.setProperties( null );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
String asString = p.getProjectAsString();
|
final String asString = p.getProjectAsString();
|
||||||
|
|
||||||
MavenXpp3Reader reader = new MavenXpp3Reader();
|
final MavenXpp3Reader reader = new MavenXpp3Reader();
|
||||||
model = reader.read( new StringReader( asString ) );
|
model = reader.read( new StringReader( asString ) );
|
||||||
model.setId( null );
|
model.setId( null );
|
||||||
|
|
||||||
for ( Iterator i = model.getDependencies().iterator(); i.hasNext(); )
|
for ( final Iterator i = model.getDependencies().iterator(); i.hasNext(); )
|
||||||
{
|
{
|
||||||
Dependency d = (Dependency) i.next();
|
final Dependency d = (Dependency) i.next();
|
||||||
|
|
||||||
if ( depProperties.containsKey( d.getId() ) )
|
if ( depProperties.containsKey( d.getId() ) )
|
||||||
{
|
{
|
||||||
@ -128,24 +129,24 @@ public class PomRewriter
|
|||||||
|
|
||||||
d.setId( null );
|
d.setId( null );
|
||||||
|
|
||||||
if ( d.getUrl() != null && d.getUrl().length() == 0 )
|
if ( ( d.getUrl() != null ) && ( d.getUrl().length() == 0 ) )
|
||||||
{
|
{
|
||||||
d.setUrl( null );
|
d.setUrl( null );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( d.getType() != null && d.getType().length() == 0 )
|
if ( ( d.getType() != null ) && ( d.getType().length() == 0 ) )
|
||||||
{
|
{
|
||||||
d.setType( null );
|
d.setType( null );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( d.getJar() != null && d.getJar().length() == 0 )
|
if ( ( d.getJar() != null ) && ( d.getJar().length() == 0 ) )
|
||||||
{
|
{
|
||||||
d.setJar( null );
|
d.setJar( null );
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch ( Exception e )
|
catch ( final Exception e )
|
||||||
{
|
{
|
||||||
throw new MavenException( "Error getting the project as a string", e );
|
throw new MavenException( "Error getting the project as a string", e );
|
||||||
}
|
}
|
||||||
|
|||||||
@ -50,7 +50,7 @@ public interface ArtifactDeployer
|
|||||||
*
|
*
|
||||||
* @throws MavenException
|
* @throws MavenException
|
||||||
*/
|
*/
|
||||||
void deploy(String artifact, String type, Project project, ArtifactTypeHandler handler)
|
void deploy( String artifact, String type, Project project, ArtifactTypeHandler handler )
|
||||||
throws MavenException;
|
throws MavenException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -63,7 +63,7 @@ public interface ArtifactDeployer
|
|||||||
*
|
*
|
||||||
* @throws MavenException
|
* @throws MavenException
|
||||||
*/
|
*/
|
||||||
void deploySnapshot(String artifact, String type, Project project, ArtifactTypeHandler handler)
|
void deploySnapshot( String artifact, String type, Project project, ArtifactTypeHandler handler )
|
||||||
throws MavenException;
|
throws MavenException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -75,7 +75,7 @@ public interface ArtifactDeployer
|
|||||||
* @param handler the type handler for the artifact
|
* @param handler the type handler for the artifact
|
||||||
* @throws MavenException
|
* @throws MavenException
|
||||||
*/
|
*/
|
||||||
void install(String artifact, String type, Project project, ArtifactTypeHandler handler)
|
void install( String artifact, String type, Project project, ArtifactTypeHandler handler )
|
||||||
throws MavenException;
|
throws MavenException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -87,7 +87,6 @@ public interface ArtifactDeployer
|
|||||||
* @param handler the type handler for the artifact
|
* @param handler the type handler for the artifact
|
||||||
* @throws MavenException
|
* @throws MavenException
|
||||||
*/
|
*/
|
||||||
void installSnapshot(String artifact, String type, Project project, ArtifactTypeHandler handler)
|
void installSnapshot( String artifact, String type, Project project, ArtifactTypeHandler handler )
|
||||||
throws MavenException;
|
throws MavenException;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -84,85 +84,86 @@ public class DefaultArtifactDeployer
|
|||||||
/**
|
/**
|
||||||
* @see ArtifactDeployer#deploy(String, String, Project, ArtifactTypeHandler)
|
* @see ArtifactDeployer#deploy(String, String, Project, ArtifactTypeHandler)
|
||||||
*/
|
*/
|
||||||
public void deploy( String artifact, String type, Project project, ArtifactTypeHandler handler )
|
public void deploy( final String artifact, final String type, final Project project, final ArtifactTypeHandler handler )
|
||||||
throws MavenException
|
throws MavenException
|
||||||
{
|
{
|
||||||
handleDeploy( type, project, project.getArtifactId(), artifact, handler, project.getCurrentVersion() );
|
this.handleDeploy( type, project, project.getArtifactId(), artifact, handler, project.getCurrentVersion() );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see DefaultArtifactDeployer#deploySnapshot(String, String, Project, ArtifactTypeHandler)
|
* @see DefaultArtifactDeployer#deploySnapshot(String, String, Project, ArtifactTypeHandler)
|
||||||
*/
|
*/
|
||||||
public void deploySnapshot( String artifact, String type, Project project, ArtifactTypeHandler handler )
|
public void deploySnapshot( final String artifact, final String type, final Project project, final ArtifactTypeHandler handler )
|
||||||
throws MavenException
|
throws MavenException
|
||||||
{
|
{
|
||||||
handleDeploy( type, project, project.getArtifactId(), artifact, handler, MavenConstants.SNAPSHOT_SIGNIFIER );
|
this.handleDeploy( type, project, project.getArtifactId(), artifact, handler, MavenConstants.SNAPSHOT_SIGNIFIER );
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void handleDeploy( String type, Project project, String artifactId, String artifact, ArtifactTypeHandler handler,
|
protected void handleDeploy( final String type, final Project project, final String artifactId, final String artifact,
|
||||||
String version )
|
final ArtifactTypeHandler handler, final String version )
|
||||||
throws MavenException
|
throws MavenException
|
||||||
{
|
{
|
||||||
File file;
|
File file;
|
||||||
if ( POM_TYPE.equals( type ) )
|
if ( DefaultArtifactDeployer.POM_TYPE.equals( type ) )
|
||||||
{
|
{
|
||||||
file = PomRewriter.getRewrittenPom( project );
|
file = PomRewriter.getRewrittenPom( project );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
file = getFileForArtifact( artifact );
|
file = this.getFileForArtifact( artifact );
|
||||||
}
|
}
|
||||||
|
|
||||||
// do not deploy POM twice
|
// do not deploy POM twice
|
||||||
if ( !POM_TYPE.equals( type ) )
|
if ( !DefaultArtifactDeployer.POM_TYPE.equals( type ) )
|
||||||
{
|
{
|
||||||
doDeploy( PomRewriter.getRewrittenPom( project ), project, artifactId, POM_ARTIFACT_TYPE_HANDLER, version, POM_TYPE );
|
this.doDeploy( PomRewriter.getRewrittenPom( project ), project, artifactId, DefaultArtifactDeployer.POM_ARTIFACT_TYPE_HANDLER, version,
|
||||||
|
DefaultArtifactDeployer.POM_TYPE );
|
||||||
}
|
}
|
||||||
|
|
||||||
doDeploy( file, project, artifactId, handler, version, type );
|
this.doDeploy( file, project, artifactId, handler, version, type );
|
||||||
|
|
||||||
snapshotSignature = null;
|
this.snapshotSignature = null;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see ArtifactDeployer#install(String, String, Project, ArtifactTypeHandler)
|
* @see ArtifactDeployer#install(String, String, Project, ArtifactTypeHandler)
|
||||||
*/
|
*/
|
||||||
public void install( String artifact, String type, Project project, ArtifactTypeHandler handler )
|
public void install( final String artifact, final String type, final Project project, final ArtifactTypeHandler handler )
|
||||||
throws MavenException
|
throws MavenException
|
||||||
{
|
{
|
||||||
handleInstall( type, project, artifact, handler, project.getCurrentVersion() );
|
this.handleInstall( type, project, artifact, handler, project.getCurrentVersion() );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see ArtifactDeployer#installSnapshot(String, String, Project, ArtifactTypeHandler)
|
* @see ArtifactDeployer#installSnapshot(String, String, Project, ArtifactTypeHandler)
|
||||||
*/
|
*/
|
||||||
public void installSnapshot( String artifact, String type, Project project, ArtifactTypeHandler handler )
|
public void installSnapshot( final String artifact, final String type, final Project project, final ArtifactTypeHandler handler )
|
||||||
throws MavenException
|
throws MavenException
|
||||||
{
|
{
|
||||||
handleInstall( type, project, artifact, handler, MavenConstants.SNAPSHOT_SIGNIFIER );
|
this.handleInstall( type, project, artifact, handler, MavenConstants.SNAPSHOT_SIGNIFIER );
|
||||||
}
|
}
|
||||||
|
|
||||||
private void handleInstall( String type, Project project, String artifact, ArtifactTypeHandler handler,
|
private void handleInstall( final String type, final Project project, final String artifact, final ArtifactTypeHandler handler,
|
||||||
String version )
|
final String version )
|
||||||
throws MavenException
|
throws MavenException
|
||||||
{
|
{
|
||||||
File file;
|
File file;
|
||||||
if ( POM_TYPE.equals( type ) )
|
if ( DefaultArtifactDeployer.POM_TYPE.equals( type ) )
|
||||||
{
|
{
|
||||||
file = PomRewriter.getRewrittenPom( project );
|
file = PomRewriter.getRewrittenPom( project );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
file = getFileForArtifact( artifact );
|
file = this.getFileForArtifact( artifact );
|
||||||
}
|
}
|
||||||
|
|
||||||
doInstall( file, type, project, version, handler );
|
this.doInstall( file, type, project, version, handler );
|
||||||
|
|
||||||
// do not install twice
|
// do not install twice
|
||||||
if ( !POM_TYPE.equals( type ) )
|
if ( !DefaultArtifactDeployer.POM_TYPE.equals( type ) )
|
||||||
{
|
{
|
||||||
doInstall( PomRewriter.getRewrittenPom( project ), POM_TYPE, project, version, POM_ARTIFACT_TYPE_HANDLER );
|
this.doInstall( PomRewriter.getRewrittenPom( project ), DefaultArtifactDeployer.POM_TYPE, project, version, DefaultArtifactDeployer.POM_ARTIFACT_TYPE_HANDLER );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -175,95 +176,95 @@ public class DefaultArtifactDeployer
|
|||||||
* @param version String denominating the version of the artifact
|
* @param version String denominating the version of the artifact
|
||||||
* @throws MavenException
|
* @throws MavenException
|
||||||
*/
|
*/
|
||||||
private void doInstall( File file, String type, Project project, String version, ArtifactTypeHandler handler )
|
private void doInstall( final File file, final String type, final Project project, final String version, final ArtifactTypeHandler handler )
|
||||||
throws MavenException
|
throws MavenException
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Repository repository = new Repository( "local", "file:" + project.getContext().getMavenRepoLocal() );
|
final Repository repository = new Repository( "local", "file:" + project.getContext().getMavenRepoLocal() );
|
||||||
String repositoryPath = handler.constructRepositoryFullPath( type, project, version );
|
final String repositoryPath = handler.constructRepositoryFullPath( type, project, version );
|
||||||
deployFile( repository, file, repositoryPath, project );
|
this.deployFile( repository, file, repositoryPath, project );
|
||||||
}
|
}
|
||||||
catch ( Exception e )
|
catch ( final Exception e )
|
||||||
{
|
{
|
||||||
String msg = "Cannot install file: '" + file + "'. Reason: " + e.getMessage();
|
final String msg = "Cannot install file: '" + file + "'. Reason: " + e.getMessage();
|
||||||
throw new MavenException( msg, e );
|
throw new MavenException( msg, e );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected String findSshIdentity()
|
protected String findSshIdentity()
|
||||||
{
|
{
|
||||||
String key = findSshIdentity( System.getProperty( "user.home" ) );
|
String key = this.findSshIdentity( System.getProperty( "user.home" ) );
|
||||||
if ( key != null )
|
if ( key != null )
|
||||||
{
|
{
|
||||||
return key;
|
return key;
|
||||||
}
|
}
|
||||||
if ( System.getProperty( "user.home" ).equals( System.getProperty( "user.home.env" ) ) == false )
|
if ( System.getProperty( "user.home" ).equals( System.getProperty( "user.home.env" ) ) == false )
|
||||||
{
|
{
|
||||||
key = findSshIdentity( System.getProperty( "user.home.env" ) );
|
key = this.findSshIdentity( System.getProperty( "user.home.env" ) );
|
||||||
if ( key != null )
|
if ( key != null )
|
||||||
{
|
{
|
||||||
return key;
|
return key;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
LOG.warn( "Unable to locate identity id_rsa, id_dsa or identity - set maven.repo.default.privatekey" );
|
DefaultArtifactDeployer.LOG.warn( "Unable to locate identity id_rsa, id_dsa or identity - set maven.repo.default.privatekey" );
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private String findSshIdentity( String home )
|
private String findSshIdentity( final String home )
|
||||||
{
|
{
|
||||||
if ( home == null )
|
if ( home == null )
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
File sshHome = new File( home, ".ssh" );
|
final File sshHome = new File( home, ".ssh" );
|
||||||
LOG.debug( "Looking for SSH keys in " + sshHome );
|
DefaultArtifactDeployer.LOG.debug( "Looking for SSH keys in " + sshHome );
|
||||||
File key = new File( sshHome, "id_dsa" );
|
File key = new File( sshHome, "id_dsa" );
|
||||||
if ( key.exists() )
|
if ( key.exists() )
|
||||||
{
|
{
|
||||||
LOG.debug( "found " + key );
|
DefaultArtifactDeployer.LOG.debug( "found " + key );
|
||||||
return key.getAbsolutePath();
|
return key.getAbsolutePath();
|
||||||
}
|
}
|
||||||
key = new File( sshHome, "id_rsa" );
|
key = new File( sshHome, "id_rsa" );
|
||||||
if ( key.exists() )
|
if ( key.exists() )
|
||||||
{
|
{
|
||||||
LOG.debug( "found " + key );
|
DefaultArtifactDeployer.LOG.debug( "found " + key );
|
||||||
return key.getAbsolutePath();
|
return key.getAbsolutePath();
|
||||||
}
|
}
|
||||||
key = new File( sshHome, "identity" );
|
key = new File( sshHome, "identity" );
|
||||||
if ( key.exists() )
|
if ( key.exists() )
|
||||||
{
|
{
|
||||||
LOG.debug( "found " + key );
|
DefaultArtifactDeployer.LOG.debug( "found " + key );
|
||||||
return key.getAbsolutePath();
|
return key.getAbsolutePath();
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void doDeploy( File file, Project project, String artifactId, ArtifactTypeHandler handler, String version, String type )
|
private void doDeploy( final File file, final Project project, final String artifactId, final ArtifactTypeHandler handler, final String version,
|
||||||
|
final String type )
|
||||||
throws MavenException
|
throws MavenException
|
||||||
{
|
{
|
||||||
List srcFiles = new ArrayList( 3 );
|
final List srcFiles = new ArrayList( 3 );
|
||||||
List destFiles = new ArrayList( 3 );
|
final List destFiles = new ArrayList( 3 );
|
||||||
|
|
||||||
srcFiles.add( file );
|
srcFiles.add( file );
|
||||||
destFiles.add( handler.constructRepositoryFullPath( type, project, version ) );
|
destFiles.add( handler.constructRepositoryFullPath( type, project, version ) );
|
||||||
|
|
||||||
if ( version.indexOf( MavenConstants.SNAPSHOT_SIGNIFIER ) >= 0 )
|
if ( version.indexOf( MavenConstants.SNAPSHOT_SIGNIFIER ) >= 0 )
|
||||||
{
|
{
|
||||||
String signature = getSnapshotSignature();
|
final String signature = this.getSnapshotSignature();
|
||||||
String v = StringUtils.replace( version, MavenConstants.SNAPSHOT_SIGNIFIER, signature );
|
final String v = StringUtils.replace( version, MavenConstants.SNAPSHOT_SIGNIFIER, signature );
|
||||||
|
|
||||||
File snapshotVersionFile = createSnapshotVersionFile( file, v, artifactId, type );
|
final File snapshotVersionFile = this.createSnapshotVersionFile( file, v, artifactId, type );
|
||||||
|
|
||||||
String snapshotVersionsFilename = handler.constructRepositoryDirectoryPath( type, project ) +
|
final String snapshotVersionsFilename = handler.constructRepositoryDirectoryPath( type, project ) + artifactId
|
||||||
artifactId + "-snapshot-version";
|
+ "-snapshot-version";
|
||||||
|
|
||||||
srcFiles.add( snapshotVersionFile );
|
srcFiles.add( snapshotVersionFile );
|
||||||
destFiles.add( snapshotVersionsFilename );
|
destFiles.add( snapshotVersionsFilename );
|
||||||
|
|
||||||
String deployTimestamp =
|
final String deployTimestamp = (String) project.getContext().getVariable( "maven.artifact.deploy.timestamps" );
|
||||||
(String) project.getContext().getVariable( "maven.artifact.deploy.timestamps" );
|
if ( deployTimestamp.equals( "true" ) )
|
||||||
if ( deployTimestamp.equals("true") )
|
|
||||||
{
|
{
|
||||||
srcFiles.add( file );
|
srcFiles.add( file );
|
||||||
destFiles.add( handler.constructRepositoryFullPath( type, project, v ) );
|
destFiles.add( handler.constructRepositoryFullPath( type, project, v ) );
|
||||||
@ -274,26 +275,26 @@ public class DefaultArtifactDeployer
|
|||||||
|
|
||||||
String repoStr = (String) project.getContext().getVariable( "maven.repo.list" );
|
String repoStr = (String) project.getContext().getVariable( "maven.repo.list" );
|
||||||
|
|
||||||
if ( repoStr == null || repoStr.trim().length() == 0 )
|
if ( ( repoStr == null ) || ( repoStr.trim().length() == 0 ) )
|
||||||
{
|
{
|
||||||
String central = project.getDistributionSite();
|
String central = project.getDistributionSite();
|
||||||
String centralDirectory = project.getDistributionDirectory();
|
String centralDirectory = project.getDistributionDirectory();
|
||||||
if ( central == null || central.trim().length() == 0 )
|
if ( ( central == null ) || ( central.trim().length() == 0 ) )
|
||||||
{
|
{
|
||||||
central = (String) project.getContext().getVariable( "maven.repo.central" );
|
central = (String) project.getContext().getVariable( "maven.repo.central" );
|
||||||
centralDirectory = (String) project.getContext().getVariable( "maven.repo.central.directory" );
|
centralDirectory = (String) project.getContext().getVariable( "maven.repo.central.directory" );
|
||||||
}
|
}
|
||||||
if ( central != null && central.trim().length() > 0 )
|
if ( ( central != null ) && ( central.trim().length() > 0 ) )
|
||||||
{
|
{
|
||||||
repoStr = "default";
|
repoStr = "default";
|
||||||
project.getContext().setVariable( "maven.repo.default", "scp://" + central );
|
project.getContext().setVariable( "maven.repo.default", "scp://" + central );
|
||||||
if ( project.getContext().getVariable( "maven.repo.default.privatekey" ) == null )
|
if ( project.getContext().getVariable( "maven.repo.default.privatekey" ) == null )
|
||||||
{
|
{
|
||||||
project.getContext().setVariable( "maven.repo.default.privatekey", findSshIdentity() );
|
project.getContext().setVariable( "maven.repo.default.privatekey", this.findSshIdentity() );
|
||||||
}
|
}
|
||||||
if ( project.getContext().getVariable( "maven.repo.default.passphrase" ) == null )
|
if ( project.getContext().getVariable( "maven.repo.default.passphrase" ) == null )
|
||||||
{
|
{
|
||||||
LOG.warn( "WARNING: assuming empty passphrase. Specify maven.repo.default.passphrase if needed" );
|
DefaultArtifactDeployer.LOG.warn( "WARNING: assuming empty passphrase. Specify maven.repo.default.passphrase if needed" );
|
||||||
project.getContext().setVariable( "maven.repo.default.passphrase", "" );
|
project.getContext().setVariable( "maven.repo.default.passphrase", "" );
|
||||||
}
|
}
|
||||||
project.getContext().setVariable( "maven.repo.default.directory", centralDirectory );
|
project.getContext().setVariable( "maven.repo.default.directory", centralDirectory );
|
||||||
@ -304,26 +305,26 @@ public class DefaultArtifactDeployer
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
String[] repos = StringUtils.split( repoStr, "," );
|
final String[] repos = StringUtils.split( repoStr, "," );
|
||||||
|
|
||||||
LOG.info( "Will deploy to " + repos.length + " repository(ies): " + repoStr );
|
DefaultArtifactDeployer.LOG.info( "Will deploy to " + repos.length + " repository(ies): " + repoStr );
|
||||||
boolean success = false;
|
boolean success = false;
|
||||||
for ( int i = 0; i < repos.length; i++ )
|
for ( int i = 0; i < repos.length; i++ )
|
||||||
{
|
{
|
||||||
|
|
||||||
String repo = repos[i].trim();
|
final String repo = repos[i].trim();
|
||||||
LOG.info( "Deploying to repository: " + repo );
|
DefaultArtifactDeployer.LOG.info( "Deploying to repository: " + repo );
|
||||||
Repository repository = RepositoryBuilder.getRepository( project, repo );
|
final Repository repository = RepositoryBuilder.getRepository( project, repo );
|
||||||
AuthenticationInfo authenticationInfo = RepositoryBuilder.getAuthenticationInfo( project, repo );
|
final AuthenticationInfo authenticationInfo = RepositoryBuilder.getAuthenticationInfo( project, repo );
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
deployFiles( repository, srcFiles, destFiles, authenticationInfo, project );
|
this.deployFiles( repository, srcFiles, destFiles, authenticationInfo, project );
|
||||||
success = true;
|
success = true;
|
||||||
}
|
}
|
||||||
catch ( Exception e )
|
catch ( final Exception e )
|
||||||
{
|
{
|
||||||
String msg = "Failed to deploy to: " + repository.getId() + " Reason: " + e;
|
final String msg = "Failed to deploy to: " + repository.getId() + " Reason: " + e;
|
||||||
LOG.warn( msg, e );
|
DefaultArtifactDeployer.LOG.warn( msg, e );
|
||||||
// deploy to next repository
|
// deploy to next repository
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -335,30 +336,30 @@ public class DefaultArtifactDeployer
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void deployFile( Repository repository, File src, String dest, Project project )
|
protected void deployFile( final Repository repository, final File src, final String dest, final Project project )
|
||||||
throws ResourceDoesNotExistException, MalformedURLException, NoSuchAlgorithmException, TransferFailedException,
|
throws ResourceDoesNotExistException, MalformedURLException, NoSuchAlgorithmException, TransferFailedException,
|
||||||
ConnectionException, AuthenticationException, AuthorizationException, MavenException
|
ConnectionException, AuthenticationException, AuthorizationException, MavenException
|
||||||
{
|
{
|
||||||
deployFiles( repository, Collections.singletonList( src ), Collections.singletonList( dest ), null, project );
|
this.deployFiles( repository, Collections.singletonList( src ), Collections.singletonList( dest ), null, project );
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void deployFiles( Repository repository, List srcFiles, List destFiles,
|
protected void deployFiles( final Repository repository, final List srcFiles, final List destFiles,
|
||||||
AuthenticationInfo authenticationInfo, Project project )
|
final AuthenticationInfo authenticationInfo, final Project project )
|
||||||
throws ConnectionException, AuthenticationException, ResourceDoesNotExistException, TransferFailedException,
|
throws ConnectionException, AuthenticationException, ResourceDoesNotExistException, TransferFailedException,
|
||||||
AuthorizationException, MalformedURLException, NoSuchAlgorithmException, MavenException
|
AuthorizationException, MalformedURLException, NoSuchAlgorithmException, MavenException
|
||||||
{
|
{
|
||||||
|
|
||||||
if ( srcFiles.size() != destFiles.size() )
|
if ( srcFiles.size() != destFiles.size() )
|
||||||
{
|
{
|
||||||
String msg = "Lengths of the lists should be the same";
|
final String msg = "Lengths of the lists should be the same";
|
||||||
throw new IllegalArgumentException( msg );
|
throw new IllegalArgumentException( msg );
|
||||||
}
|
}
|
||||||
|
|
||||||
Wagon wagon = getWagon( repository.getProtocol(), project, repository.getId() );
|
final Wagon wagon = this.getWagon( repository.getProtocol(), project, repository.getId() );
|
||||||
|
|
||||||
TransferListener uploadMonitor = new UploadMeter();
|
final TransferListener uploadMonitor = new UploadMeter();
|
||||||
|
|
||||||
Map checksums = new HashMap( 2 );
|
final Map checksums = new HashMap( 2 );
|
||||||
|
|
||||||
ChecksumObserver observer = new ChecksumObserver( "MD5" );
|
ChecksumObserver observer = new ChecksumObserver( "MD5" );
|
||||||
checksums.put( "md5", observer );
|
checksums.put( "md5", observer );
|
||||||
@ -370,41 +371,41 @@ public class DefaultArtifactDeployer
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
wagon.connect( repository, authenticationInfo );
|
wagon.connect( repository, authenticationInfo );
|
||||||
Iterator srcIterator = srcFiles.iterator();
|
final Iterator srcIterator = srcFiles.iterator();
|
||||||
Iterator destIterator = destFiles.iterator();
|
final Iterator destIterator = destFiles.iterator();
|
||||||
while ( srcIterator.hasNext() )
|
while ( srcIterator.hasNext() )
|
||||||
{
|
{
|
||||||
wagon.addTransferListener( uploadMonitor );
|
wagon.addTransferListener( uploadMonitor );
|
||||||
|
|
||||||
File srcFile = (File) srcIterator.next();
|
final File srcFile = (File) srcIterator.next();
|
||||||
String destFile = (String) destIterator.next();
|
final String destFile = (String) destIterator.next();
|
||||||
wagon.put( srcFile, destFile );
|
wagon.put( srcFile, destFile );
|
||||||
|
|
||||||
wagon.removeTransferListener( uploadMonitor );
|
wagon.removeTransferListener( uploadMonitor );
|
||||||
|
|
||||||
Map sums = new HashMap( 2 );
|
final Map sums = new HashMap( 2 );
|
||||||
for ( Iterator i = checksums.keySet().iterator(); i.hasNext(); )
|
for ( final Iterator i = checksums.keySet().iterator(); i.hasNext(); )
|
||||||
{
|
{
|
||||||
// store first - a later put will modify them
|
// store first - a later put will modify them
|
||||||
String extension = (String) i.next();
|
final String extension = (String) i.next();
|
||||||
observer = (ChecksumObserver) checksums.get( extension );
|
observer = (ChecksumObserver) checksums.get( extension );
|
||||||
sums.put( extension, observer.getActualChecksum() );
|
sums.put( extension, observer.getActualChecksum() );
|
||||||
}
|
}
|
||||||
|
|
||||||
for ( Iterator i = checksums.keySet().iterator(); i.hasNext(); )
|
for ( final Iterator i = checksums.keySet().iterator(); i.hasNext(); )
|
||||||
{
|
{
|
||||||
String extension = (String) i.next();
|
final String extension = (String) i.next();
|
||||||
|
|
||||||
// TODO: shouldn't need a file intermediatary - improve wagon to take a stream
|
// TODO: shouldn't need a file intermediatary - improve wagon to take a stream
|
||||||
File temp = File.createTempFile( "maven-artifact", null );
|
final File temp = File.createTempFile( "maven-artifact", null );
|
||||||
temp.deleteOnExit();
|
temp.deleteOnExit();
|
||||||
FileUtils.fileWrite( temp.getAbsolutePath(), (String) sums.get( extension ) );
|
FileUtils.fileWrite( temp.getAbsolutePath(), (String) sums.get( extension ) );
|
||||||
|
|
||||||
wagon.put( temp, destFile + "." + extension );
|
wagon.put( temp, destFile + "." + extension );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch ( IOException e )
|
catch ( final IOException e )
|
||||||
{
|
{
|
||||||
throw new MavenException( "Error creating temporary file to transfer checksums", e );
|
throw new MavenException( "Error creating temporary file to transfer checksums", e );
|
||||||
}
|
}
|
||||||
@ -414,72 +415,83 @@ public class DefaultArtifactDeployer
|
|||||||
{
|
{
|
||||||
wagon.disconnect();
|
wagon.disconnect();
|
||||||
}
|
}
|
||||||
catch ( Exception e )
|
catch ( final Exception e )
|
||||||
{
|
{
|
||||||
LOG.error( "Error cleaning up from the deployer", e );
|
DefaultArtifactDeployer.LOG.error( "Error cleaning up from the deployer", e );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private Wagon getWagon( String protocol, Project project, String id )
|
private Wagon getWagon( final String protocol, final Project project, final String id )
|
||||||
throws MalformedURLException
|
throws MalformedURLException
|
||||||
{
|
{
|
||||||
Wagon wagon;
|
Wagon wagon;
|
||||||
|
|
||||||
if (protocol.equals("http")) {
|
if ( protocol.equals( "http" ) )
|
||||||
wagon = new HttpWagon();
|
{
|
||||||
} else if (protocol.equals("ftp")) {
|
wagon = new HttpWagon();
|
||||||
wagon = new FtpWagon();
|
}
|
||||||
RepositoryBuilder.configureFtpWagon(project, id, (FtpWagon) wagon);
|
else if ( protocol.equals( "ftp" ) )
|
||||||
} else if (protocol.equals("sftp")) {
|
{
|
||||||
wagon = new SftpWagon();
|
wagon = new FtpWagon();
|
||||||
RepositoryBuilder.configureSftpWagon(project, id, (SftpWagon) wagon);
|
RepositoryBuilder.configureFtpWagon( project, id, (FtpWagon) wagon );
|
||||||
} else if (protocol.equals("file")) {
|
}
|
||||||
wagon = new FileWagon();
|
else if ( protocol.equals( "sftp" ) )
|
||||||
} else if (protocol.equals("scp")) {
|
{
|
||||||
wagon = new ScpWagon();
|
wagon = new SftpWagon();
|
||||||
RepositoryBuilder.configureScpWagon(project, id, (ScpWagon) wagon);
|
RepositoryBuilder.configureSftpWagon( project, id, (SftpWagon) wagon );
|
||||||
} else if (protocol.equals("scpexe")) {
|
}
|
||||||
wagon = new ScpExternalWagon();
|
else if ( protocol.equals( "file" ) )
|
||||||
RepositoryBuilder.configureSshExternalWagon(project, id,
|
{
|
||||||
(ScpExternalWagon) wagon);
|
wagon = new FileWagon();
|
||||||
return wagon;
|
}
|
||||||
} else {
|
else if ( protocol.equals( "scp" ) )
|
||||||
throw new MalformedURLException("Unknown Wagon protocol: "
|
{
|
||||||
+ protocol);
|
wagon = new ScpWagon();
|
||||||
}
|
RepositoryBuilder.configureScpWagon( project, id, (ScpWagon) wagon );
|
||||||
|
}
|
||||||
return wagon;
|
else if ( protocol.equals( "scpexe" ) )
|
||||||
}
|
{
|
||||||
|
wagon = new ScpExternalWagon();
|
||||||
|
RepositoryBuilder.configureSshExternalWagon( project, id, (ScpExternalWagon) wagon );
|
||||||
|
return wagon;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw new MalformedURLException( "Unknown Wagon protocol: " + protocol );
|
||||||
|
}
|
||||||
|
|
||||||
|
return wagon;
|
||||||
|
}
|
||||||
|
|
||||||
protected String getSnapshotSignature()
|
protected String getSnapshotSignature()
|
||||||
{
|
{
|
||||||
if ( snapshotSignature == null )
|
if ( this.snapshotSignature == null )
|
||||||
{
|
{
|
||||||
DateFormat fmt = new SimpleDateFormat( SNAPSHOT_FORMAT );
|
final DateFormat fmt = new SimpleDateFormat( DefaultArtifactDeployer.SNAPSHOT_FORMAT );
|
||||||
fmt.setTimeZone( TimeZone.getTimeZone( "GMT" ) );
|
fmt.setTimeZone( TimeZone.getTimeZone( "GMT" ) );
|
||||||
snapshotSignature = fmt.format( new Date() );
|
this.snapshotSignature = fmt.format( new Date() );
|
||||||
}
|
}
|
||||||
return snapshotSignature;
|
return this.snapshotSignature;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected File getFileForArtifact( String artifact )
|
protected File getFileForArtifact( final String artifact )
|
||||||
throws MavenException
|
throws MavenException
|
||||||
{
|
{
|
||||||
File file = new File( artifact );
|
final File file = new File( artifact );
|
||||||
if ( !file.exists() )
|
if ( !file.exists() )
|
||||||
{
|
{
|
||||||
String msg = "Artifact file: '" + artifact + "' must exist";
|
final String msg = "Artifact file: '" + artifact + "' must exist";
|
||||||
throw new MavenException( msg );
|
throw new MavenException( msg );
|
||||||
}
|
}
|
||||||
if ( !file.canRead() )
|
if ( !file.canRead() )
|
||||||
{
|
{
|
||||||
String msg = "Artifact file: '" + artifact + "' must be readable";
|
final String msg = "Artifact file: '" + artifact + "' must be readable";
|
||||||
throw new MavenException( msg );
|
throw new MavenException( msg );
|
||||||
}
|
}
|
||||||
if ( file.isDirectory() )
|
if ( file.isDirectory() )
|
||||||
{
|
{
|
||||||
String msg = "Artifact file: '" + artifact + "' must not be a directory";
|
final String msg = "Artifact file: '" + artifact + "' must not be a directory";
|
||||||
throw new MavenException( msg );
|
throw new MavenException( msg );
|
||||||
}
|
}
|
||||||
return file.getAbsoluteFile();
|
return file.getAbsoluteFile();
|
||||||
@ -488,18 +500,18 @@ public class DefaultArtifactDeployer
|
|||||||
/**
|
/**
|
||||||
* Create a file which contains timestamp of the latetst snapshot
|
* Create a file which contains timestamp of the latetst snapshot
|
||||||
*/
|
*/
|
||||||
protected File createSnapshotVersionFile( File artifact, String snapshotVersion, String artifactId, String type )
|
protected File createSnapshotVersionFile( final File artifact, final String snapshotVersion, final String artifactId, final String type )
|
||||||
throws MavenException
|
throws MavenException
|
||||||
{
|
{
|
||||||
File file = null;
|
File file = null;
|
||||||
String filename = artifactId + "-" + type + "-snapshot-version";
|
final String filename = artifactId + "-" + type + "-snapshot-version";
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
file = new File( artifact.getParent(), filename );
|
file = new File( artifact.getParent(), filename );
|
||||||
FileUtils.fileWrite( file.getAbsolutePath(), snapshotVersion );
|
FileUtils.fileWrite( file.getAbsolutePath(), snapshotVersion );
|
||||||
file.deleteOnExit();
|
file.deleteOnExit();
|
||||||
}
|
}
|
||||||
catch ( Exception e )
|
catch ( final Exception e )
|
||||||
{
|
{
|
||||||
throw new MavenException( "Cannot create snapshot-version file:" + file );
|
throw new MavenException( "Cannot create snapshot-version file:" + file );
|
||||||
}
|
}
|
||||||
|
|||||||
@ -34,64 +34,68 @@ public class DeployBean
|
|||||||
private NamedArtifactDeployer artifactDeployer;
|
private NamedArtifactDeployer artifactDeployer;
|
||||||
|
|
||||||
private Project project;
|
private Project project;
|
||||||
|
|
||||||
private String artifact;
|
private String artifact;
|
||||||
|
|
||||||
private String type;
|
private String type;
|
||||||
|
|
||||||
private String artifactIdOverride;
|
private String artifactIdOverride;
|
||||||
|
|
||||||
private ArtifactTypeHandler typeHandler;
|
private ArtifactTypeHandler typeHandler;
|
||||||
|
|
||||||
public DeployBean()
|
public DeployBean()
|
||||||
{
|
{
|
||||||
artifactDeployer = new NamedArtifactDeployer();
|
this.artifactDeployer = new NamedArtifactDeployer();
|
||||||
}
|
}
|
||||||
|
|
||||||
public ArtifactTypeHandler getTypeHandler()
|
public ArtifactTypeHandler getTypeHandler()
|
||||||
{
|
{
|
||||||
return typeHandler;
|
return this.typeHandler;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param typeHandler
|
* @param typeHandler
|
||||||
*/
|
*/
|
||||||
public void setTypeHandler(ArtifactTypeHandler typeHandler)
|
public void setTypeHandler( final ArtifactTypeHandler typeHandler )
|
||||||
{
|
{
|
||||||
this.typeHandler = typeHandler;
|
this.typeHandler = typeHandler;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getArtifact()
|
public String getArtifact()
|
||||||
{
|
{
|
||||||
return artifact;
|
return this.artifact;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param artifact
|
* @param artifact
|
||||||
*/
|
*/
|
||||||
public void setArtifact(String artifact)
|
public void setArtifact( final String artifact )
|
||||||
{
|
{
|
||||||
this.artifact = artifact;
|
this.artifact = artifact;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Project getProject()
|
public Project getProject()
|
||||||
{
|
{
|
||||||
return project;
|
return this.project;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param project
|
* @param project
|
||||||
*/
|
*/
|
||||||
public void setProject(Project project)
|
public void setProject( final Project project )
|
||||||
{
|
{
|
||||||
this.project = project;
|
this.project = project;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getType()
|
public String getType()
|
||||||
{
|
{
|
||||||
return type;
|
return this.type;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param type
|
* @param type
|
||||||
*/
|
*/
|
||||||
public void setType(String type)
|
public void setType( final String type )
|
||||||
{
|
{
|
||||||
this.type = type;
|
this.type = type;
|
||||||
}
|
}
|
||||||
@ -101,13 +105,13 @@ public class DeployBean
|
|||||||
*/
|
*/
|
||||||
public String getArtifactIdOverride()
|
public String getArtifactIdOverride()
|
||||||
{
|
{
|
||||||
return artifactIdOverride;
|
return this.artifactIdOverride;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param newIdOverride The new id.
|
* @param newIdOverride The new id.
|
||||||
*/
|
*/
|
||||||
public void setArtifactIdOverride(String newIdOverride)
|
public void setArtifactIdOverride( final String newIdOverride )
|
||||||
{
|
{
|
||||||
this.artifactIdOverride = newIdOverride;
|
this.artifactIdOverride = newIdOverride;
|
||||||
}
|
}
|
||||||
@ -115,27 +119,28 @@ public class DeployBean
|
|||||||
/**
|
/**
|
||||||
* @throws MavenException MavenException
|
* @throws MavenException MavenException
|
||||||
*/
|
*/
|
||||||
protected void checkAttributes() throws MavenException
|
protected void checkAttributes()
|
||||||
|
throws MavenException
|
||||||
{
|
{
|
||||||
if (project == null)
|
if ( this.project == null )
|
||||||
{
|
{
|
||||||
throw new MavenException("attribute 'project' is required");
|
throw new MavenException( "attribute 'project' is required" );
|
||||||
}
|
}
|
||||||
|
|
||||||
if (artifact == null)
|
if ( this.artifact == null )
|
||||||
{
|
{
|
||||||
throw new MavenException("attribute 'artifact' is required");
|
throw new MavenException( "attribute 'artifact' is required" );
|
||||||
}
|
}
|
||||||
if (type == null)
|
if ( this.type == null )
|
||||||
{
|
{
|
||||||
throw new MavenException("attribute 'type' is required");
|
throw new MavenException( "attribute 'type' is required" );
|
||||||
}
|
}
|
||||||
if (typeHandler == null)
|
if ( this.typeHandler == null )
|
||||||
{
|
{
|
||||||
typeHandler = new NamedArtifactTypeHandler();
|
this.typeHandler = new NamedArtifactTypeHandler();
|
||||||
if ( artifactIdOverride != null )
|
if ( this.artifactIdOverride != null )
|
||||||
{
|
{
|
||||||
((NamedArtifactTypeHandler) typeHandler).setArtifactId( artifactIdOverride );
|
( (NamedArtifactTypeHandler) this.typeHandler ).setArtifactId( this.artifactIdOverride );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -143,64 +148,68 @@ public class DeployBean
|
|||||||
/**
|
/**
|
||||||
* @throws MavenException MavenException
|
* @throws MavenException MavenException
|
||||||
*/
|
*/
|
||||||
public void deploy() throws MavenException
|
public void deploy()
|
||||||
|
throws MavenException
|
||||||
{
|
{
|
||||||
checkAttributes();
|
this.checkAttributes();
|
||||||
if ( artifactIdOverride != null )
|
if ( this.artifactIdOverride != null )
|
||||||
{
|
{
|
||||||
artifactDeployer.deploy(artifact, type, project, (NamedArtifactTypeHandler) typeHandler);
|
this.artifactDeployer.deploy( this.artifact, this.type, this.project, (NamedArtifactTypeHandler) this.typeHandler );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
artifactDeployer.deploy(artifact, type, project, typeHandler);
|
this.artifactDeployer.deploy( this.artifact, this.type, this.project, this.typeHandler );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @throws MavenException MavenException
|
* @throws MavenException MavenException
|
||||||
*/
|
*/
|
||||||
public void deploySnapshot() throws MavenException
|
public void deploySnapshot()
|
||||||
|
throws MavenException
|
||||||
{
|
{
|
||||||
checkAttributes();
|
this.checkAttributes();
|
||||||
if ( artifactIdOverride != null )
|
if ( this.artifactIdOverride != null )
|
||||||
{
|
{
|
||||||
artifactDeployer.deploySnapshot(artifact, type, project, (NamedArtifactTypeHandler) typeHandler);
|
this.artifactDeployer.deploySnapshot( this.artifact, this.type, this.project, (NamedArtifactTypeHandler) this.typeHandler );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
artifactDeployer.deploySnapshot(artifact, type, project, typeHandler);
|
this.artifactDeployer.deploySnapshot( this.artifact, this.type, this.project, this.typeHandler );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @throws MavenException MavenException
|
* @throws MavenException MavenException
|
||||||
*/
|
*/
|
||||||
public void install() throws MavenException
|
public void install()
|
||||||
|
throws MavenException
|
||||||
{
|
{
|
||||||
checkAttributes();
|
this.checkAttributes();
|
||||||
if ( artifactIdOverride != null )
|
if ( this.artifactIdOverride != null )
|
||||||
{
|
{
|
||||||
artifactDeployer.install(artifact, type, project, (NamedArtifactTypeHandler) typeHandler);
|
this.artifactDeployer.install( this.artifact, this.type, this.project, this.typeHandler );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
artifactDeployer.install(artifact, type, project, typeHandler);
|
this.artifactDeployer.install( this.artifact, this.type, this.project, this.typeHandler );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @throws MavenException MavenException
|
* @throws MavenException MavenException
|
||||||
*/
|
*/
|
||||||
public void installSnapshot() throws MavenException
|
public void installSnapshot()
|
||||||
|
throws MavenException
|
||||||
{
|
{
|
||||||
checkAttributes();
|
this.checkAttributes();
|
||||||
if ( artifactIdOverride != null )
|
if ( this.artifactIdOverride != null )
|
||||||
{
|
{
|
||||||
artifactDeployer.installSnapshot(artifact, type, project, (NamedArtifactTypeHandler) typeHandler);
|
this.artifactDeployer.installSnapshot( this.artifact, this.type, this.project, this.typeHandler );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
artifactDeployer.installSnapshot(artifact, type, project, typeHandler);
|
this.artifactDeployer.installSnapshot( this.artifact, this.type, this.project, this.typeHandler );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -26,24 +26,25 @@ import org.apache.maven.project.Project;
|
|||||||
*
|
*
|
||||||
* @author <a href="mailto:ltheussl@apache.org">Lukas Theussl</a>
|
* @author <a href="mailto:ltheussl@apache.org">Lukas Theussl</a>
|
||||||
*/
|
*/
|
||||||
public class NamedArtifactDeployer extends DefaultArtifactDeployer
|
public class NamedArtifactDeployer
|
||||||
|
extends DefaultArtifactDeployer
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see ArtifactDeployer#deploy(String, String, Project, NamedArtifactTypeHandler)
|
* @see ArtifactDeployer#deploy(String, String, Project, NamedArtifactTypeHandler)
|
||||||
*/
|
*/
|
||||||
public void deploy( String artifact, String type, Project project, NamedArtifactTypeHandler handler )
|
public void deploy( final String artifact, final String type, final Project project, final NamedArtifactTypeHandler handler )
|
||||||
throws MavenException
|
throws MavenException
|
||||||
{
|
{
|
||||||
handleDeploy( type, project, handler.getArtifactId(), artifact, handler, project.getCurrentVersion() );
|
this.handleDeploy( type, project, handler.getArtifactId(), artifact, handler, project.getCurrentVersion() );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see DefaultArtifactDeployer#deploySnapshot(String, String, Project, NamedArtifactTypeHandler)
|
* @see DefaultArtifactDeployer#deploySnapshot(String, String, Project, NamedArtifactTypeHandler)
|
||||||
*/
|
*/
|
||||||
public void deploySnapshot( String artifact, String type, Project project, NamedArtifactTypeHandler handler )
|
public void deploySnapshot( final String artifact, final String type, final Project project, final NamedArtifactTypeHandler handler )
|
||||||
throws MavenException
|
throws MavenException
|
||||||
{
|
{
|
||||||
handleDeploy( type, project, handler.getArtifactId(), artifact, handler, MavenConstants.SNAPSHOT_SIGNIFIER );
|
this.handleDeploy( type, project, handler.getArtifactId(), artifact, handler, MavenConstants.SNAPSHOT_SIGNIFIER );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -25,49 +25,47 @@ import org.apache.maven.repository.DefaultArtifactTypeHandler;
|
|||||||
*
|
*
|
||||||
* @author <a href="mailto:neilc@strate.co.za">Neil Crow</a>
|
* @author <a href="mailto:neilc@strate.co.za">Neil Crow</a>
|
||||||
*/
|
*/
|
||||||
public class NamedArtifactTypeHandler extends DefaultArtifactTypeHandler
|
public class NamedArtifactTypeHandler
|
||||||
|
extends DefaultArtifactTypeHandler
|
||||||
{
|
{
|
||||||
/** The artifactId. */
|
/** The artifactId. */
|
||||||
private String artifactId = null;
|
private String artifactId = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return String
|
* @return String
|
||||||
*/
|
*/
|
||||||
public String getArtifactId()
|
public String getArtifactId()
|
||||||
{
|
{
|
||||||
return artifactId;
|
return this.artifactId;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param newId - The artifactId which overides the pom default.
|
* @param newId - The artifactId which overides the pom default.
|
||||||
*/
|
*/
|
||||||
public void setArtifactId( String newId )
|
public void setArtifactId( final String newId )
|
||||||
{
|
{
|
||||||
this.artifactId = newId;
|
this.artifactId = newId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Map an artifact to a repository path.
|
* Map an artifact to a repository path.
|
||||||
*
|
*
|
||||||
* @param project the project for the artifact
|
* @param project the project for the artifact
|
||||||
* @param type The type of the artifact
|
* @param type The type of the artifact
|
||||||
* @param version The version of the artifact (may be a snapshot)
|
* @param version The version of the artifact (may be a snapshot)
|
||||||
* @return the path
|
* @return the path
|
||||||
*/
|
*/
|
||||||
public String constructRepositoryFullPath( String type,
|
public String constructRepositoryFullPath( final String type, final Project project, final String version )
|
||||||
Project project, String version )
|
|
||||||
{
|
{
|
||||||
if ( artifactId == null )
|
if ( this.artifactId == null )
|
||||||
{
|
{
|
||||||
artifactId = project.getArtifactId();
|
this.artifactId = project.getArtifactId();
|
||||||
}
|
}
|
||||||
StringBuffer path =
|
final StringBuffer path = new StringBuffer( this.constructRepositoryDirectoryPath( type, project ) );
|
||||||
new StringBuffer( constructRepositoryDirectoryPath( type, project ) );
|
path.append( this.artifactId );
|
||||||
path.append( artifactId );
|
|
||||||
path.append( "-" );
|
path.append( "-" );
|
||||||
path.append( version );
|
path.append( version );
|
||||||
path.append( extensionForType( type) );
|
path.append( this.extensionForType( type ) );
|
||||||
return path.toString();
|
return path.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -75,9 +73,9 @@ public class NamedArtifactTypeHandler extends DefaultArtifactTypeHandler
|
|||||||
* @param type type
|
* @param type type
|
||||||
* @return extension
|
* @return extension
|
||||||
*/
|
*/
|
||||||
private String extensionForType(String type)
|
private String extensionForType( final String type )
|
||||||
{
|
{
|
||||||
if (type.equals("uberjar") || type.equals("ejb") || type.equals("plugin"))
|
if ( type.equals( "uberjar" ) || type.equals( "ejb" ) || type.equals( "plugin" ) )
|
||||||
{
|
{
|
||||||
return ".jar";
|
return ".jar";
|
||||||
}
|
}
|
||||||
|
|||||||
@ -42,19 +42,19 @@ public class RepositoryBuilder
|
|||||||
{
|
{
|
||||||
private static final Log LOG = LogFactory.getLog( RepositoryBuilder.class );
|
private static final Log LOG = LogFactory.getLog( RepositoryBuilder.class );
|
||||||
|
|
||||||
public static Repository getRepository( Project project, String id )
|
public static Repository getRepository( final Project project, final String id )
|
||||||
throws MavenException
|
throws MavenException
|
||||||
{
|
{
|
||||||
String url = (String) project.getContext().getVariable( "maven.repo." + id );
|
final String url = (String) project.getContext().getVariable( "maven.repo." + id );
|
||||||
if ( url == null )
|
if ( url == null )
|
||||||
{
|
{
|
||||||
throw new MavenException( "URL not specified in property: maven.repo." + id );
|
throw new MavenException( "URL not specified in property: maven.repo." + id );
|
||||||
}
|
}
|
||||||
|
|
||||||
Repository repository = new Repository( id, url );
|
final Repository repository = new Repository( id, url );
|
||||||
|
|
||||||
String dir = (String) project.getContext().getVariable( "maven.repo." + id + ".directory" );
|
String dir = (String) project.getContext().getVariable( "maven.repo." + id + ".directory" );
|
||||||
if ( repository.getBasedir() != null && dir != null )
|
if ( ( repository.getBasedir() != null ) && ( dir != null ) )
|
||||||
{
|
{
|
||||||
dir = dir.replace( '\\', '/' );
|
dir = dir.replace( '\\', '/' );
|
||||||
if ( !repository.getBasedir().endsWith( "/" ) && !dir.startsWith( "/" ) )
|
if ( !repository.getBasedir().endsWith( "/" ) && !dir.startsWith( "/" ) )
|
||||||
@ -70,20 +70,20 @@ public class RepositoryBuilder
|
|||||||
throw new MavenException( "Directory not specified in property: maven.repo." + id + ".directory" );
|
throw new MavenException( "Directory not specified in property: maven.repo." + id + ".directory" );
|
||||||
}
|
}
|
||||||
|
|
||||||
String port = (String) project.getContext().getVariable( "maven.repo." + id + ".port" );
|
final String port = (String) project.getContext().getVariable( "maven.repo." + id + ".port" );
|
||||||
if ( port != null )
|
if ( port != null )
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
repository.setPort( Integer.valueOf( port ).intValue() );
|
repository.setPort( Integer.valueOf( port ).intValue() );
|
||||||
}
|
}
|
||||||
catch ( NumberFormatException e )
|
catch ( final NumberFormatException e )
|
||||||
{
|
{
|
||||||
LOG.warn( "Invalid format for port: " + port );
|
RepositoryBuilder.LOG.warn( "Invalid format for port: " + port );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
String remoteGroup = (String) project.getContext().getVariable( "maven.repo." + id + ".group" );
|
final String remoteGroup = (String) project.getContext().getVariable( "maven.repo." + id + ".group" );
|
||||||
String remoteMode = (String) project.getContext().getVariable( "maven.repo." + id + ".mode" );
|
String remoteMode = (String) project.getContext().getVariable( "maven.repo." + id + ".mode" );
|
||||||
String remoteDirectoryMode = (String) project.getContext().getVariable( "maven.repo." + id + ".directory.mode" );
|
String remoteDirectoryMode = (String) project.getContext().getVariable( "maven.repo." + id + ".directory.mode" );
|
||||||
|
|
||||||
@ -97,7 +97,7 @@ public class RepositoryBuilder
|
|||||||
remoteDirectoryMode = remoteMode;
|
remoteDirectoryMode = remoteMode;
|
||||||
}
|
}
|
||||||
|
|
||||||
RepositoryPermissions permissions = new RepositoryPermissions();
|
final RepositoryPermissions permissions = new RepositoryPermissions();
|
||||||
permissions.setDirectoryMode( remoteDirectoryMode );
|
permissions.setDirectoryMode( remoteDirectoryMode );
|
||||||
permissions.setFileMode( remoteMode );
|
permissions.setFileMode( remoteMode );
|
||||||
permissions.setGroup( remoteGroup );
|
permissions.setGroup( remoteGroup );
|
||||||
@ -106,54 +106,54 @@ public class RepositoryBuilder
|
|||||||
return repository;
|
return repository;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void configureFtpWagon( Project project, String id, FtpWagon wagon )
|
public static void configureFtpWagon( final Project project, final String id, final FtpWagon wagon )
|
||||||
{
|
{
|
||||||
/* TODO: implement in FTP wagon
|
/* TODO: implement in FTP wagon
|
||||||
String passiveModeOn = (String) project.getContext().getVariable( "maven.repo." + id + ".passiveModeOn" );
|
String passiveModeOn = (String) project.getContext().getVariable( "maven.repo." + id + ".passiveModeOn" );
|
||||||
|
|
||||||
String compress = (String) project.getContext().getVariable( "maven.repo." + id + ".compress" );
|
String compress = (String) project.getContext().getVariable( "maven.repo." + id + ".compress" );
|
||||||
|
|
||||||
if ( passiveModeOn != null )
|
if ( passiveModeOn != null )
|
||||||
{
|
{
|
||||||
if ( "false".equalsIgnoreCase( passiveModeOn ) )
|
if ( "false".equalsIgnoreCase( passiveModeOn ) )
|
||||||
{
|
{
|
||||||
wagon.setPassiveModeOn( false );
|
wagon.setPassiveModeOn( false );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ( compress != null )
|
if ( compress != null )
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
wagon.setCompress( new Boolean( compress ).booleanValue() );
|
wagon.setCompress( new Boolean( compress ).booleanValue() );
|
||||||
}
|
}
|
||||||
catch ( Exception e )
|
catch ( Exception e )
|
||||||
{
|
{
|
||||||
throw new MavenException( "maven.repo." + id + ".compress should be a boolean" );
|
throw new MavenException( "maven.repo." + id + ".compress should be a boolean" );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void configureSshWagon( Project project, String id, AbstractSshWagon wagon )
|
public static void configureSshWagon( final Project project, final String id, final AbstractSshWagon wagon )
|
||||||
{
|
{
|
||||||
// DON'T check host key
|
// DON'T check host key
|
||||||
// To do it we need to had more configuration settings (know_hosts file, ...)
|
// To do it we need to had more configuration settings (know_hosts file, ...)
|
||||||
NullKnownHostProvider nkhp = new NullKnownHostProvider();
|
final NullKnownHostProvider nkhp = new NullKnownHostProvider();
|
||||||
nkhp.setHostKeyChecking("no");
|
nkhp.setHostKeyChecking( "no" );
|
||||||
wagon.setKnownHostsProvider(nkhp);
|
wagon.setKnownHostsProvider( nkhp );
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void configureSftpWagon( Project project, String id, SftpWagon wagon )
|
public static void configureSftpWagon( final Project project, final String id, final SftpWagon wagon )
|
||||||
{
|
{
|
||||||
configureSshWagon(project,id,wagon);
|
RepositoryBuilder.configureSshWagon( project, id, wagon );
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void configureScpWagon( Project project, String id, ScpWagon wagon )
|
public static void configureScpWagon( final Project project, final String id, final ScpWagon wagon )
|
||||||
{
|
{
|
||||||
configureSshWagon(project,id,wagon);
|
RepositoryBuilder.configureSshWagon( project, id, wagon );
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void configureSshExternalWagon( Project project, String id, ScpExternalWagon wagon )
|
public static void configureSshExternalWagon( final Project project, final String id, final ScpExternalWagon wagon )
|
||||||
{
|
{
|
||||||
String scpExe = (String) project.getContext().getVariable( "maven.repo." + id + ".scp.executable" );
|
String scpExe = (String) project.getContext().getVariable( "maven.repo." + id + ".scp.executable" );
|
||||||
if ( scpExe == null )
|
if ( scpExe == null )
|
||||||
@ -200,14 +200,14 @@ public class RepositoryBuilder
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void getProxyInfo( Project project )
|
public static void getProxyInfo( final Project project )
|
||||||
{
|
{
|
||||||
ProxyInfo proxyInfo = new ProxyInfo();
|
final ProxyInfo proxyInfo = new ProxyInfo();
|
||||||
|
|
||||||
String proxyHost = project.getContext().getProxyHost();
|
final String proxyHost = project.getContext().getProxyHost();
|
||||||
String proxyUser = project.getContext().getProxyUserName();
|
final String proxyUser = project.getContext().getProxyUserName();
|
||||||
String proxyPassword = project.getContext().getProxyPassword();
|
final String proxyPassword = project.getContext().getProxyPassword();
|
||||||
String proxyPort = project.getContext().getProxyPort();
|
final String proxyPort = project.getContext().getProxyPort();
|
||||||
|
|
||||||
if ( proxyPort != null )
|
if ( proxyPort != null )
|
||||||
{
|
{
|
||||||
@ -215,9 +215,9 @@ public class RepositoryBuilder
|
|||||||
{
|
{
|
||||||
proxyInfo.setPort( Integer.valueOf( proxyPort ).intValue() );
|
proxyInfo.setPort( Integer.valueOf( proxyPort ).intValue() );
|
||||||
}
|
}
|
||||||
catch ( NumberFormatException e )
|
catch ( final NumberFormatException e )
|
||||||
{
|
{
|
||||||
LOG.warn( "Invalid format for port: " + proxyPort );
|
RepositoryBuilder.LOG.warn( "Invalid format for port: " + proxyPort );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -230,19 +230,19 @@ public class RepositoryBuilder
|
|||||||
proxyInfo.setPassword( proxyPassword );
|
proxyInfo.setPassword( proxyPassword );
|
||||||
}
|
}
|
||||||
|
|
||||||
public static AuthenticationInfo getAuthenticationInfo( Project project, String id )
|
public static AuthenticationInfo getAuthenticationInfo( final Project project, final String id )
|
||||||
{
|
{
|
||||||
String username = (String) project.getContext().getVariable( "maven.repo." + id + ".username" );
|
String username = (String) project.getContext().getVariable( "maven.repo." + id + ".username" );
|
||||||
String password = (String) project.getContext().getVariable( "maven.repo." + id + ".password" );
|
final String password = (String) project.getContext().getVariable( "maven.repo." + id + ".password" );
|
||||||
String passphrase = (String) project.getContext().getVariable( "maven.repo." + id + ".passphrase" );
|
final String passphrase = (String) project.getContext().getVariable( "maven.repo." + id + ".passphrase" );
|
||||||
String privateKey = (String) project.getContext().getVariable( "maven.repo." + id + ".privatekey" );
|
final String privateKey = (String) project.getContext().getVariable( "maven.repo." + id + ".privatekey" );
|
||||||
|
|
||||||
if ( username == null )
|
if ( username == null )
|
||||||
{
|
{
|
||||||
username = (String) project.getContext().getVariable( "maven.username" );
|
username = (String) project.getContext().getVariable( "maven.username" );
|
||||||
}
|
}
|
||||||
|
|
||||||
AuthenticationInfo authenticationInfo = new AuthenticationInfo();
|
final AuthenticationInfo authenticationInfo = new AuthenticationInfo();
|
||||||
authenticationInfo.setUserName( username );
|
authenticationInfo.setUserName( username );
|
||||||
authenticationInfo.setPassword( password );
|
authenticationInfo.setPassword( password );
|
||||||
authenticationInfo.setPrivateKey( privateKey );
|
authenticationInfo.setPrivateKey( privateKey );
|
||||||
|
|||||||
@ -28,15 +28,20 @@ import org.apache.maven.wagon.events.TransferListener;
|
|||||||
* @author <a href="mailto:brett@apache.org">Brett Porter</a>
|
* @author <a href="mailto:brett@apache.org">Brett Porter</a>
|
||||||
* @version $Id$
|
* @version $Id$
|
||||||
*/
|
*/
|
||||||
public class UploadMeter implements TransferListener
|
public class UploadMeter
|
||||||
|
implements TransferListener
|
||||||
{
|
{
|
||||||
/** log for debug output */
|
/** log for debug output */
|
||||||
private static final Log log = LogFactory.getLog(UploadMeter.class);
|
private static final Log log = LogFactory.getLog( UploadMeter.class );
|
||||||
|
|
||||||
private int shownSoFar;
|
private int shownSoFar;
|
||||||
|
|
||||||
private final int numHashes;
|
private final int numHashes;
|
||||||
|
|
||||||
private final char hashChar;
|
private final char hashChar;
|
||||||
|
|
||||||
private long complete;
|
private long complete;
|
||||||
|
|
||||||
private long total;
|
private long total;
|
||||||
|
|
||||||
private static final int KB = 1024;
|
private static final int KB = 1024;
|
||||||
@ -46,52 +51,51 @@ public class UploadMeter implements TransferListener
|
|||||||
this( 20, '.' );
|
this( 20, '.' );
|
||||||
}
|
}
|
||||||
|
|
||||||
public UploadMeter(int numHashes, char hashChar)
|
public UploadMeter( final int numHashes, final char hashChar )
|
||||||
{
|
{
|
||||||
this.numHashes = numHashes;
|
this.numHashes = numHashes;
|
||||||
this.hashChar = hashChar;
|
this.hashChar = hashChar;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void transferInitiated( TransferEvent transferEvent )
|
public void transferInitiated( final TransferEvent transferEvent )
|
||||||
{
|
{
|
||||||
System.out.println( "Uploading to " + transferEvent.getResource().getName() + ": " );
|
System.out.println( "Uploading to " + transferEvent.getResource().getName() + ": " );
|
||||||
}
|
}
|
||||||
|
|
||||||
public void transferStarted( TransferEvent transferEvent )
|
public void transferStarted( final TransferEvent transferEvent )
|
||||||
{
|
{
|
||||||
shownSoFar = 0;
|
this.shownSoFar = 0;
|
||||||
complete = 0;
|
this.complete = 0;
|
||||||
total = transferEvent.getLocalFile().length();
|
this.total = transferEvent.getLocalFile().length();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void transferProgress( TransferEvent transferEvent, byte[] buffer, int length )
|
public void transferProgress( final TransferEvent transferEvent, final byte[] buffer, final int length )
|
||||||
{
|
{
|
||||||
complete += length;
|
this.complete += length;
|
||||||
|
|
||||||
if (total > 0)
|
if ( this.total > 0 )
|
||||||
{
|
{
|
||||||
int numToShow = (int) ( ( complete * numHashes ) / total );
|
final int numToShow = (int) ( ( this.complete * this.numHashes ) / this.total );
|
||||||
for ( int i = shownSoFar + 1; i <= numToShow; i++ )
|
for ( int i = this.shownSoFar + 1; i <= numToShow; i++ )
|
||||||
{
|
{
|
||||||
System.out.print( hashChar );
|
System.out.print( this.hashChar );
|
||||||
}
|
}
|
||||||
shownSoFar = numToShow;
|
this.shownSoFar = numToShow;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void transferCompleted( TransferEvent transferEvent )
|
public void transferCompleted( final TransferEvent transferEvent )
|
||||||
{
|
{
|
||||||
System.out.println(" (" + total / KB + "K)");
|
System.out.println( " (" + this.total / UploadMeter.KB + "K)" );
|
||||||
}
|
}
|
||||||
|
|
||||||
public void transferError( TransferEvent transferEvent )
|
public void transferError( final TransferEvent transferEvent )
|
||||||
{
|
{
|
||||||
log.error( transferEvent.getException().getMessage() );
|
UploadMeter.log.error( transferEvent.getException().getMessage() );
|
||||||
}
|
}
|
||||||
|
|
||||||
public void debug( String message )
|
public void debug( final String message )
|
||||||
{
|
{
|
||||||
log.debug( message );
|
UploadMeter.log.debug( message );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -16,16 +16,14 @@ package org.apache.maven.artifact;
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import junit.framework.TestCase;
|
|
||||||
import org.apache.maven.project.Project;
|
|
||||||
import org.apache.maven.model.Model;
|
|
||||||
import org.apache.maven.model.Dependency;
|
|
||||||
import org.apache.maven.MavenException;
|
|
||||||
import org.apache.maven.MavenUtils;
|
|
||||||
import org.apache.maven.MavenConstants;
|
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileReader;
|
|
||||||
|
import junit.framework.Assert;
|
||||||
|
import junit.framework.TestCase;
|
||||||
|
|
||||||
|
import org.apache.maven.MavenConstants;
|
||||||
|
import org.apache.maven.model.Dependency;
|
||||||
|
import org.apache.maven.model.Model;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test the POM rewriter.
|
* Test the POM rewriter.
|
||||||
@ -48,18 +46,19 @@ public class PomRewriterTest
|
|||||||
public void testPropertiesRewriting()
|
public void testPropertiesRewriting()
|
||||||
throws Exception
|
throws Exception
|
||||||
{
|
{
|
||||||
String resourceName = "pom-with-properties.xml";
|
final String resourceName = "pom-with-properties.xml";
|
||||||
|
|
||||||
Model model = PomRewriter.getRewrittenModel( new File( System.getProperty( "basedir"), "src/test/resources/" + resourceName ), null );
|
final Model model = PomRewriter.getRewrittenModel( new File( System.getProperty( "basedir" ), "src/test/resources/"
|
||||||
|
+ resourceName ), null );
|
||||||
|
|
||||||
Dependency dep = (Dependency) model.getDependencies().get( 0 );
|
Dependency dep = (Dependency) model.getDependencies().get( 0 );
|
||||||
assertEquals( "check property war.bundle", "true", dep.getProperty( "war.bundle" ) );
|
Assert.assertEquals( "check property war.bundle", "true", dep.getProperty( "war.bundle" ) );
|
||||||
assertEquals( "check num properties", 1, dep.getProperties().size() );
|
Assert.assertEquals( "check num properties", 1, dep.getProperties().size() );
|
||||||
|
|
||||||
dep = (Dependency) model.getDependencies().get( 1 );
|
dep = (Dependency) model.getDependencies().get( 1 );
|
||||||
assertEquals( "check property gump.project", "jakarta-taglibs-standard", dep.getProperty( "gump.project" ) );
|
Assert.assertEquals( "check property gump.project", "jakarta-taglibs-standard", dep.getProperty( "gump.project" ) );
|
||||||
assertEquals( "check property gump.id", "jstl", dep.getProperty( "gump.id" ) );
|
Assert.assertEquals( "check property gump.id", "jstl", dep.getProperty( "gump.id" ) );
|
||||||
assertEquals( "check num properties", 2, dep.getProperties().size() );
|
Assert.assertEquals( "check num properties", 2, dep.getProperties().size() );
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user