apply some inspections

git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@219826 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Brett Leslie Porter 2005-07-20 01:24:35 +00:00
parent ee31f9650f
commit 685bfbcb12
3 changed files with 59 additions and 58 deletions

View File

@ -42,12 +42,12 @@ import java.util.Properties;
/**
* Prepare for a release in SCM
*
* @author <a href="mailto:evenisse@apache.org">Emmanuel Venisse</a>
* @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
* @version $Id: DoxiaMojo.java 169372 2005-05-09 22:47:34Z evenisse $
* @goal prepare
* @requiresDependencyResolution test
*
* @author <a href="mailto:evenisse@apache.org">Emmanuel Venisse</a>
* @author <a href="mailto:jason@maven.org>Jason van Zyl</a>
* @version $Id: DoxiaMojo.java 169372 2005-05-09 22:47:34Z evenisse $
* @todo check how this works with version ranges
*/
public class PrepareReleaseMojo
extends AbstractReleaseMojo
@ -58,7 +58,7 @@ public class PrepareReleaseMojo
* @readonly
*/
private String basedir;
/**
* @parameter expression="${settings.interactiveMode}"
* @readonly
@ -127,8 +127,7 @@ public class PrepareReleaseMojo
for ( Iterator i = changedFiles.iterator(); i.hasNext(); )
{
ScmFile f = (ScmFile) i.next();
if ( f.getPath().equals( "pom.xml.backup" ) ||
f.getPath().equals( RELEASE_PROPS ) )
if ( f.getPath().equals( "pom.xml.backup" ) || f.getPath().equals( RELEASE_PROPS ) )
{
i.remove();
}
@ -147,7 +146,8 @@ public class PrepareReleaseMojo
message.append( "\n" );
}
throw new MojoExecutionException( "Cannot prepare the release because you have local modifications : \n" + message.toString() );
throw new MojoExecutionException(
"Cannot prepare the release because you have local modifications : \n" + message.toString() );
}
}
@ -230,8 +230,8 @@ public class PrepareReleaseMojo
message.append( "\n" );
}
throw new MojoExecutionException( "Can't release project due to non released dependencies :\n"
+ message.toString() );
throw new MojoExecutionException(
"Can't release project due to non released dependencies :\n" + message.toString() );
}
}
@ -278,8 +278,8 @@ public class PrepareReleaseMojo
model.getScm().setConnection( rewriteScmConnection( model.getScm().getConnection(), getTagLabel() ) );
model.getScm().setDeveloperConnection( rewriteScmConnection( model.getScm().getDeveloperConnection(),
getTagLabel() ) );
model.getScm().setDeveloperConnection(
rewriteScmConnection( model.getScm().getDeveloperConnection(), getTagLabel() ) );
}
try
@ -323,10 +323,10 @@ public class PrepareReleaseMojo
for ( Iterator j = model.getDependencies().iterator(); j.hasNext(); )
{
Dependency dependency = (Dependency) j.next();
if ( artifact.getGroupId().equals( dependency.getGroupId() )
&& artifact.getArtifactId().equals( dependency.getArtifactId() )
&& artifact.getBaseVersion().equals( dependency.getVersion() )
&& artifact.getType().equals( dependency.getType() ) )
if ( artifact.getGroupId().equals( dependency.getGroupId() ) &&
artifact.getArtifactId().equals( dependency.getArtifactId() ) &&
artifact.getBaseVersion().equals( dependency.getVersion() ) &&
artifact.getType().equals( dependency.getType() ) )
{
dependency.setVersion( artifact.getVersion() );
}
@ -343,8 +343,8 @@ public class PrepareReleaseMojo
for ( Iterator j = model.getBuild().getPlugins().iterator(); j.hasNext(); )
{
Plugin plugin = (Plugin) j.next();
if ( artifact.getGroupId().equals( plugin.getGroupId() )
&& artifact.getArtifactId().equals( plugin.getArtifactId() ) )
if ( artifact.getGroupId().equals( plugin.getGroupId() ) &&
artifact.getArtifactId().equals( plugin.getArtifactId() ) )
{
plugin.setGroupId( artifact.getGroupId() );
plugin.setVersion( artifact.getVersion() );
@ -361,7 +361,7 @@ public class PrepareReleaseMojo
transformer.setProject( project.getFile() );
transformer.setUpdatedModel ( model );
transformer.setUpdatedModel( model );
transformer.transformNodes();
@ -389,7 +389,8 @@ public class PrepareReleaseMojo
{
nextVersionString = Integer.toString( Integer.parseInt( nextVersionString ) + 1 );
projectVersion = projectVersion.substring( 0, projectVersion.lastIndexOf( "-" ) + 1 ) + nextVersionString + SNAPSHOT;
projectVersion = projectVersion.substring( 0, projectVersion.lastIndexOf( "-" ) + 1 ) + nextVersionString +
SNAPSHOT;
}
catch ( NumberFormatException e )
{
@ -426,7 +427,7 @@ public class PrepareReleaseMojo
transformer.setProject( project.getFile() );
transformer.setUpdatedModel ( model );
transformer.setUpdatedModel( model );
transformer.transformNodes();
@ -570,11 +571,11 @@ public class PrepareReleaseMojo
{
if ( scmConnection.startsWith( "svn" ) )
{
if ( scmConnection.endsWith( "trunk/") )
if ( scmConnection.endsWith( "trunk/" ) )
{
scmConnection = scmConnection.substring( 0, scmConnection.length() - "trunk/".length() );
}
if ( scmConnection.endsWith( "branches/") )
if ( scmConnection.endsWith( "branches/" ) )
{
scmConnection = scmConnection.substring( 0, scmConnection.length() - "branches/".length() );
}

View File

@ -65,7 +65,7 @@ public class MavenMetadataSource
artifact.getVersion(), artifact.getScope() );
// TODO: this a very thin wrapper around a project builder - is it needed?
List dependencies = null;
List dependencies;
// Use the ProjectBuilder, to enable post-processing and inheritance calculation before retrieving the
// associated artifacts.
@ -101,11 +101,10 @@ public class MavenMetadataSource
{
Dependency d = (Dependency) i.next();
VersionRange versionRange = VersionRange.createFromVersionSpec( d.getVersion() );
Artifact artifact = artifactFactory.createDependencyArtifact( d.getGroupId(), d.getArtifactId(),
VersionRange.createFromVersionSpec(
d.getVersion() ), d.getType(),
d.getScope(),
inheritedScope );
versionRange, d.getType(), d.getScope(),
inheritedScope );
if ( artifact != null && ( dependencyFilter == null || dependencyFilter.include( artifact ) ) )
{

View File

@ -19,8 +19,8 @@ package org.apache.maven.report.projectinfo;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.model.Dependency;
import org.apache.maven.project.MavenProject;
import org.apache.maven.reporting.AbstractMavenReportRenderer;
import org.apache.maven.reporting.AbstractMavenReport;
import org.apache.maven.reporting.AbstractMavenReportRenderer;
import org.apache.maven.reporting.MavenReportException;
import org.codehaus.doxia.sink.Sink;
import org.codehaus.doxia.site.renderer.SiteRenderer;
@ -35,12 +35,11 @@ import java.util.Set;
/**
* Generates the dependencies report.
*
* @goal dependencies
*
* @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
* @author <a href="mailto:vincent.siveton@gmail.com">Vincent Siveton</a>
* @version $Id$
* @goal dependencies
* @plexus.component
*/
public class DependenciesReport
@ -107,7 +106,7 @@ public class DependenciesReport
}
/**
* @see org.apache.maven.reporting.AbstractMavenReport#getSiteRenderer()
* @see AbstractMavenReport#getSiteRenderer()
*/
protected SiteRenderer getSiteRenderer()
{
@ -126,7 +125,7 @@ public class DependenciesReport
r.render();
}
catch( IOException e )
catch ( IOException e )
{
throw new MavenReportException( "Can't write the report " + getOutputName(), e );
}
@ -167,7 +166,7 @@ public class DependenciesReport
// Dependencies report
List dependencies = project.getDependencies();
if ( dependencies.isEmpty() )
{
// TODO: should the report just be excluded?
@ -194,16 +193,16 @@ public class DependenciesReport
endTable();
}
endSection();
// Transitive dependencies
if ( !dependencies.isEmpty() )
{
Set artifacts = getTransitiveDependencies( project );
startSection( getBundle( locale ).getString( "report.transitivedependencies.title" ) );
if ( artifacts.isEmpty() )
{
// TODO: should the report just be excluded?
@ -212,22 +211,24 @@ public class DependenciesReport
else
{
startTable();
tableCaption( getBundle( locale ).getString( "report.transitivedependencies.intro" ) );
String groupId = getBundle( locale ).getString( "report.transitivedependencies.column.groupId" );
String artifactId = getBundle( locale ).getString( "report.transitivedependencies.column.artifactId" );
String artifactId = getBundle( locale ).getString(
"report.transitivedependencies.column.artifactId" );
String version = getBundle( locale ).getString( "report.transitivedependencies.column.version" );
tableHeader( new String[]{groupId, artifactId, version} );
for ( Iterator i = artifacts.iterator(); i.hasNext(); )
{
Artifact artifact = (Artifact) i.next();
tableRow( new String[]{artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion()} );
tableRow(
new String[]{artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion()} );
}
endTable();
}
@ -238,52 +239,52 @@ public class DependenciesReport
/**
* Return a set of artifact which are not already present in the dependencies list.
*
*
* @param project a Maven project
* @return a set of transitive dependencies
* @todo check if this works with version ranges
*/
private Set getTransitiveDependencies( MavenProject project )
{
private Set getTransitiveDependencies( MavenProject project )
{
Set result = new HashSet();
if ( ( project.getDependencies() == null ) ||
( project.getArtifacts() == null ) )
if ( project.getDependencies() == null || project.getArtifacts() == null )
{
return result;
}
List dependencies = project.getDependencies();
Set artifacts = project.getArtifacts();
for ( Iterator j = artifacts.iterator(); j.hasNext(); )
{
Artifact artifact = (Artifact)j.next();
Artifact artifact = (Artifact) j.next();
boolean toadd = true;
for ( Iterator i = dependencies.iterator(); i.hasNext(); )
{
Dependency dependency = (Dependency) i.next();
if ( ( artifact.getArtifactId().equals( dependency.getArtifactId() ) ) &&
( artifact.getGroupId().equals( dependency.getGroupId() ) ) &&
( artifact.getVersion().equals( dependency.getVersion() ) ) )
if ( artifact.getArtifactId().equals( dependency.getArtifactId() ) &&
artifact.getGroupId().equals( dependency.getGroupId() ) &&
artifact.getVersion().equals( dependency.getVersion() ) )
{
toadd = false;
break;
}
}
if ( toadd )
{
result.add( artifact );
}
}
return result;
}
}
private static ResourceBundle getBundle( Locale locale )
{
return ResourceBundle.getBundle("project-info-report", locale, DependenciesReport.class.getClassLoader() );
return ResourceBundle.getBundle( "project-info-report", locale, DependenciesReport.class.getClassLoader() );
}
}