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 * 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 * @goal prepare
* @requiresDependencyResolution test * @requiresDependencyResolution test
* * @todo check how this works with version ranges
* @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 $
*/ */
public class PrepareReleaseMojo public class PrepareReleaseMojo
extends AbstractReleaseMojo extends AbstractReleaseMojo
@ -127,8 +127,7 @@ public class PrepareReleaseMojo
for ( Iterator i = changedFiles.iterator(); i.hasNext(); ) for ( Iterator i = changedFiles.iterator(); i.hasNext(); )
{ {
ScmFile f = (ScmFile) i.next(); ScmFile f = (ScmFile) i.next();
if ( f.getPath().equals( "pom.xml.backup" ) || if ( f.getPath().equals( "pom.xml.backup" ) || f.getPath().equals( RELEASE_PROPS ) )
f.getPath().equals( RELEASE_PROPS ) )
{ {
i.remove(); i.remove();
} }
@ -147,7 +146,8 @@ public class PrepareReleaseMojo
message.append( "\n" ); 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" ); message.append( "\n" );
} }
throw new MojoExecutionException( "Can't release project due to non released dependencies :\n" throw new MojoExecutionException(
+ message.toString() ); "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().setConnection( rewriteScmConnection( model.getScm().getConnection(), getTagLabel() ) );
model.getScm().setDeveloperConnection( rewriteScmConnection( model.getScm().getDeveloperConnection(), model.getScm().setDeveloperConnection(
getTagLabel() ) ); rewriteScmConnection( model.getScm().getDeveloperConnection(), getTagLabel() ) );
} }
try try
@ -323,10 +323,10 @@ public class PrepareReleaseMojo
for ( Iterator j = model.getDependencies().iterator(); j.hasNext(); ) for ( Iterator j = model.getDependencies().iterator(); j.hasNext(); )
{ {
Dependency dependency = (Dependency) j.next(); Dependency dependency = (Dependency) j.next();
if ( artifact.getGroupId().equals( dependency.getGroupId() ) if ( artifact.getGroupId().equals( dependency.getGroupId() ) &&
&& artifact.getArtifactId().equals( dependency.getArtifactId() ) artifact.getArtifactId().equals( dependency.getArtifactId() ) &&
&& artifact.getBaseVersion().equals( dependency.getVersion() ) artifact.getBaseVersion().equals( dependency.getVersion() ) &&
&& artifact.getType().equals( dependency.getType() ) ) artifact.getType().equals( dependency.getType() ) )
{ {
dependency.setVersion( artifact.getVersion() ); dependency.setVersion( artifact.getVersion() );
} }
@ -343,8 +343,8 @@ public class PrepareReleaseMojo
for ( Iterator j = model.getBuild().getPlugins().iterator(); j.hasNext(); ) for ( Iterator j = model.getBuild().getPlugins().iterator(); j.hasNext(); )
{ {
Plugin plugin = (Plugin) j.next(); Plugin plugin = (Plugin) j.next();
if ( artifact.getGroupId().equals( plugin.getGroupId() ) if ( artifact.getGroupId().equals( plugin.getGroupId() ) &&
&& artifact.getArtifactId().equals( plugin.getArtifactId() ) ) artifact.getArtifactId().equals( plugin.getArtifactId() ) )
{ {
plugin.setGroupId( artifact.getGroupId() ); plugin.setGroupId( artifact.getGroupId() );
plugin.setVersion( artifact.getVersion() ); plugin.setVersion( artifact.getVersion() );
@ -361,7 +361,7 @@ public class PrepareReleaseMojo
transformer.setProject( project.getFile() ); transformer.setProject( project.getFile() );
transformer.setUpdatedModel ( model ); transformer.setUpdatedModel( model );
transformer.transformNodes(); transformer.transformNodes();
@ -389,7 +389,8 @@ public class PrepareReleaseMojo
{ {
nextVersionString = Integer.toString( Integer.parseInt( nextVersionString ) + 1 ); 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 ) catch ( NumberFormatException e )
{ {
@ -426,7 +427,7 @@ public class PrepareReleaseMojo
transformer.setProject( project.getFile() ); transformer.setProject( project.getFile() );
transformer.setUpdatedModel ( model ); transformer.setUpdatedModel( model );
transformer.transformNodes(); transformer.transformNodes();
@ -570,11 +571,11 @@ public class PrepareReleaseMojo
{ {
if ( scmConnection.startsWith( "svn" ) ) if ( scmConnection.startsWith( "svn" ) )
{ {
if ( scmConnection.endsWith( "trunk/") ) if ( scmConnection.endsWith( "trunk/" ) )
{ {
scmConnection = scmConnection.substring( 0, scmConnection.length() - "trunk/".length() ); scmConnection = scmConnection.substring( 0, scmConnection.length() - "trunk/".length() );
} }
if ( scmConnection.endsWith( "branches/") ) if ( scmConnection.endsWith( "branches/" ) )
{ {
scmConnection = scmConnection.substring( 0, scmConnection.length() - "branches/".length() ); scmConnection = scmConnection.substring( 0, scmConnection.length() - "branches/".length() );
} }

View File

@ -65,7 +65,7 @@ public class MavenMetadataSource
artifact.getVersion(), artifact.getScope() ); artifact.getVersion(), artifact.getScope() );
// TODO: this a very thin wrapper around a project builder - is it needed? // 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 // Use the ProjectBuilder, to enable post-processing and inheritance calculation before retrieving the
// associated artifacts. // associated artifacts.
@ -101,11 +101,10 @@ public class MavenMetadataSource
{ {
Dependency d = (Dependency) i.next(); Dependency d = (Dependency) i.next();
VersionRange versionRange = VersionRange.createFromVersionSpec( d.getVersion() );
Artifact artifact = artifactFactory.createDependencyArtifact( d.getGroupId(), d.getArtifactId(), Artifact artifact = artifactFactory.createDependencyArtifact( d.getGroupId(), d.getArtifactId(),
VersionRange.createFromVersionSpec( versionRange, d.getType(), d.getScope(),
d.getVersion() ), d.getType(), inheritedScope );
d.getScope(),
inheritedScope );
if ( artifact != null && ( dependencyFilter == null || dependencyFilter.include( artifact ) ) ) 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.artifact.Artifact;
import org.apache.maven.model.Dependency; import org.apache.maven.model.Dependency;
import org.apache.maven.project.MavenProject; import org.apache.maven.project.MavenProject;
import org.apache.maven.reporting.AbstractMavenReportRenderer;
import org.apache.maven.reporting.AbstractMavenReport; import org.apache.maven.reporting.AbstractMavenReport;
import org.apache.maven.reporting.AbstractMavenReportRenderer;
import org.apache.maven.reporting.MavenReportException; import org.apache.maven.reporting.MavenReportException;
import org.codehaus.doxia.sink.Sink; import org.codehaus.doxia.sink.Sink;
import org.codehaus.doxia.site.renderer.SiteRenderer; import org.codehaus.doxia.site.renderer.SiteRenderer;
@ -36,11 +36,10 @@ import java.util.Set;
/** /**
* Generates the dependencies report. * Generates the dependencies report.
* *
* @goal dependencies
*
* @author <a href="mailto:jason@maven.org">Jason van Zyl</a> * @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
* @author <a href="mailto:vincent.siveton@gmail.com">Vincent Siveton</a> * @author <a href="mailto:vincent.siveton@gmail.com">Vincent Siveton</a>
* @version $Id$ * @version $Id$
* @goal dependencies
* @plexus.component * @plexus.component
*/ */
public class DependenciesReport public class DependenciesReport
@ -107,7 +106,7 @@ public class DependenciesReport
} }
/** /**
* @see org.apache.maven.reporting.AbstractMavenReport#getSiteRenderer() * @see AbstractMavenReport#getSiteRenderer()
*/ */
protected SiteRenderer getSiteRenderer() protected SiteRenderer getSiteRenderer()
{ {
@ -126,7 +125,7 @@ public class DependenciesReport
r.render(); r.render();
} }
catch( IOException e ) catch ( IOException e )
{ {
throw new MavenReportException( "Can't write the report " + getOutputName(), e ); throw new MavenReportException( "Can't write the report " + getOutputName(), e );
} }
@ -216,7 +215,8 @@ public class DependenciesReport
tableCaption( getBundle( locale ).getString( "report.transitivedependencies.intro" ) ); tableCaption( getBundle( locale ).getString( "report.transitivedependencies.intro" ) );
String groupId = getBundle( locale ).getString( "report.transitivedependencies.column.groupId" ); 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" ); String version = getBundle( locale ).getString( "report.transitivedependencies.column.version" );
tableHeader( new String[]{groupId, artifactId, version} ); tableHeader( new String[]{groupId, artifactId, version} );
@ -225,7 +225,8 @@ public class DependenciesReport
{ {
Artifact artifact = (Artifact) i.next(); Artifact artifact = (Artifact) i.next();
tableRow( new String[]{artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion()} ); tableRow(
new String[]{artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion()} );
} }
endTable(); endTable();
@ -241,13 +242,13 @@ public class DependenciesReport
* *
* @param project a Maven project * @param project a Maven project
* @return a set of transitive dependencies * @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(); Set result = new HashSet();
if ( ( project.getDependencies() == null ) || if ( project.getDependencies() == null || project.getArtifacts() == null )
( project.getArtifacts() == null ) )
{ {
return result; return result;
} }
@ -257,15 +258,15 @@ public class DependenciesReport
for ( Iterator j = artifacts.iterator(); j.hasNext(); ) for ( Iterator j = artifacts.iterator(); j.hasNext(); )
{ {
Artifact artifact = (Artifact)j.next(); Artifact artifact = (Artifact) j.next();
boolean toadd = true; boolean toadd = true;
for ( Iterator i = dependencies.iterator(); i.hasNext(); ) for ( Iterator i = dependencies.iterator(); i.hasNext(); )
{ {
Dependency dependency = (Dependency) i.next(); Dependency dependency = (Dependency) i.next();
if ( ( artifact.getArtifactId().equals( dependency.getArtifactId() ) ) && if ( artifact.getArtifactId().equals( dependency.getArtifactId() ) &&
( artifact.getGroupId().equals( dependency.getGroupId() ) ) && artifact.getGroupId().equals( dependency.getGroupId() ) &&
( artifact.getVersion().equals( dependency.getVersion() ) ) ) artifact.getVersion().equals( dependency.getVersion() ) )
{ {
toadd = false; toadd = false;
break; break;
@ -284,6 +285,6 @@ public class DependenciesReport
private static ResourceBundle getBundle( Locale locale ) 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() );
} }
} }