Skip to content

Commit

Permalink
fixed errors reported by Checkstyle
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.apache.org/repos/asf/maven/archetype/trunk@1631079 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
hboutemy committed Oct 11, 2014
1 parent 99a45d8 commit b26cbe5
Show file tree
Hide file tree
Showing 18 changed files with 148 additions and 146 deletions.
2 changes: 2 additions & 0 deletions archetype-common/pom.xml
Expand Up @@ -37,6 +37,8 @@ under the License.

<properties>
<cargoVersion>1.0-alpha-6</cargoVersion>
<checkstyle.violation.ignore>RedundantThrows,NewlineAtEndOfFile,ParameterNumber,MethodLength,FileLength,javadoc,EmptyBlock,InterfaceIsType</checkstyle.violation.ignore>
<checkstyle.excludes>**/MavenJDOMWriter.java,**/XMLOutputter.java,**/Format.java,**/NamespaceStack.java</checkstyle.excludes>
</properties>

<dependencies>
Expand Down
Expand Up @@ -338,7 +338,8 @@ public List<ArtifactRepository> getRemoteArtifactRepositories()
return remoteArtifactRepositories;
}

public ArchetypeGenerationRequest setRemoteArtifactRepositories( List<ArtifactRepository> remoteArtifactRepositories )
@SuppressWarnings( "checkstyle:linelength" )
public ArchetypeGenerationRequest setRemoteArtifactRepositories( List<ArtifactRepository> remoteArtifactRepositories )
{
this.remoteArtifactRepositories = remoteArtifactRepositories;

Expand Down
Expand Up @@ -32,20 +32,20 @@ public interface ArchetypeManager
String ROLE = ArchetypeManager.class.getName();

/**
* A command to create an archetype from an existing Maven project given the supplied
* creation request.
* A command to create an archetype from an existing Maven project given the supplied creation request.
*
* @param request
* @return The result of creating the archetype from the existing project. It contains any errors that might have occurred.
* @return The result of creating the archetype from the existing project. It contains any errors that might have
* occurred.
*/
ArchetypeCreationResult createArchetypeFromProject( ArchetypeCreationRequest request );

/**
* A command to generate a Maven project from an archetype given the supplied
* generation request.
* A command to generate a Maven project from an archetype given the supplied generation request.
*
* @param request
* @return The result of creating the project from the existing archetype. It contains any errors that might have occurred.
* @return The result of creating the project from the existing archetype. It contains any errors that might have
* occurred.
*/
ArchetypeGenerationResult generateProjectFromArchetype( ArchetypeGenerationRequest request );

Expand Down Expand Up @@ -74,7 +74,8 @@ public interface ArchetypeManager
ArchetypeCatalog getLocalCatalog( String path );

/**
* Gives the catalog of archetypes located at <code>http://repo.maven.apache.org/maven2/archetype-catalog.xml</code>.
* Gives the catalog of archetypes located at
* <code>http://repo.maven.apache.org/maven2/archetype-catalog.xml</code>.
*
* @return the catalog.
*/
Expand Down
Expand Up @@ -317,7 +317,8 @@ public void writePom( final Model model, final File pomFile, final File initialP
outputStreamWriter =
new OutputStreamWriter( new FileOutputStream( pomFile ), fileEncoding );

Format form = Format.getRawFormat().setEncoding( fileEncoding ).setLineSeparator(System.getProperty("line.separator"));
final String ls = System.getProperty( "line.separator" );
Format form = Format.getRawFormat().setEncoding( fileEncoding ).setLineSeparator( ls );
writer.write( model, doc, outputStreamWriter, form );
}
catch ( JDOMException exc )
Expand Down
Expand Up @@ -48,6 +48,7 @@ public FileCharsetDetector( File detectedFile )

det.Init( new nsICharsetDetectionObserver()
{
@SuppressWarnings( "checkstyle:methodname" )
public void Notify( String charset )
{
FileCharsetDetector.this.charset = charset;
Expand Down Expand Up @@ -113,6 +114,7 @@ public FileCharsetDetector( InputStream detectedStream )

det.Init( new nsICharsetDetectionObserver()
{
@SuppressWarnings( "checkstyle:methodname" )
public void Notify( String charset )
{
FileCharsetDetector.this.charset = charset;
Expand Down
Expand Up @@ -435,7 +435,6 @@ public List<String> scan( List<String> files )

for ( String fileName : files )
{
// System.err.println("Checking "+(isIncluded ( fileName )?"I":"-")+(isExcluded ( fileName )?"E":"-")+fileName);
if ( isIncluded( fileName ) && !isExcluded( fileName ) )
{
result.add( fileName );
Expand Down
Expand Up @@ -549,7 +549,7 @@ private void rewriteReferences( Model pom, String rootArtifactId, String groupId
{
for ( Iterator<Dependency> dependencies = pom.getDependencies().iterator(); dependencies.hasNext(); )
{
rewriteDependencyReferences(dependencies.next(), rootArtifactId, groupId);
rewriteDependencyReferences( dependencies.next(), rootArtifactId, groupId );
}
}

Expand All @@ -560,7 +560,7 @@ private void rewriteReferences( Model pom, String rootArtifactId, String groupId
for ( Iterator<Dependency> dependencies = pom.getDependencyManagement().getDependencies().iterator();
dependencies.hasNext(); )
{
rewriteDependencyReferences(dependencies.next(), rootArtifactId, groupId);
rewriteDependencyReferences( dependencies.next(), rootArtifactId, groupId );
}
}

Expand All @@ -569,7 +569,7 @@ private void rewriteReferences( Model pom, String rootArtifactId, String groupId
{
for ( Iterator<Plugin> plugins = pom.getBuild().getPlugins().iterator(); plugins.hasNext(); )
{
rewritePluginReferences(plugins.next(), rootArtifactId, groupId);
rewritePluginReferences( plugins.next(), rootArtifactId, groupId );
}
}

Expand All @@ -581,7 +581,7 @@ private void rewriteReferences( Model pom, String rootArtifactId, String groupId
for ( Iterator<Plugin> plugins = pom.getBuild().getPluginManagement().getPlugins().iterator();
plugins.hasNext(); )
{
rewritePluginReferences(plugins.next(), rootArtifactId, groupId);
rewritePluginReferences( plugins.next(), rootArtifactId, groupId );
}
}

Expand All @@ -598,7 +598,7 @@ private void rewriteReferences( Model pom, String rootArtifactId, String groupId
for ( Iterator<Dependency> dependencies = profile.getDependencies().iterator();
dependencies.hasNext(); )
{
rewriteDependencyReferences(dependencies.next(), rootArtifactId, groupId);
rewriteDependencyReferences( dependencies.next(), rootArtifactId, groupId );
}
}

Expand All @@ -610,7 +610,7 @@ private void rewriteReferences( Model pom, String rootArtifactId, String groupId
for ( Iterator<Dependency> dependencies =
profile.getDependencyManagement().getDependencies().iterator(); dependencies.hasNext(); )
{
rewriteDependencyReferences(dependencies.next(), rootArtifactId, groupId);
rewriteDependencyReferences( dependencies.next(), rootArtifactId, groupId );
}
}

Expand All @@ -620,7 +620,7 @@ private void rewriteReferences( Model pom, String rootArtifactId, String groupId
{
for ( Iterator<Plugin> plugins = profile.getBuild().getPlugins().iterator(); plugins.hasNext(); )
{
rewritePluginReferences(plugins.next(), rootArtifactId, groupId);
rewritePluginReferences( plugins.next(), rootArtifactId, groupId );
}
}

Expand All @@ -632,24 +632,25 @@ private void rewriteReferences( Model pom, String rootArtifactId, String groupId
for ( Iterator<Plugin> plugins = profile.getBuild().getPluginManagement().getPlugins().iterator();
plugins.hasNext(); )
{
rewritePluginReferences(plugins.next(), rootArtifactId, groupId);
rewritePluginReferences( plugins.next(), rootArtifactId, groupId );
}
}
}
}
}

private void rewriteDependencyReferences(Dependency dependency, String rootArtifactId, String groupId) {
private void rewriteDependencyReferences( Dependency dependency, String rootArtifactId, String groupId )
{
if ( dependency.getArtifactId() != null && dependency.getArtifactId().indexOf( rootArtifactId ) >= 0 )
{
if ( dependency.getGroupId() != null )
{
dependency.setGroupId(
StringUtils.replace(dependency.getGroupId(), groupId, "${" + Constants.GROUP_ID + "}") );
dependency.setGroupId( StringUtils.replace( dependency.getGroupId(), groupId, "${" + Constants.GROUP_ID
+ "}" ) );
}

dependency.setArtifactId(
StringUtils.replace( dependency.getArtifactId(), rootArtifactId, "${rootArtifactId}" ) );
dependency.setArtifactId( StringUtils.replace( dependency.getArtifactId(), rootArtifactId,
"${rootArtifactId}" ) );

if ( dependency.getVersion() != null )
{
Expand All @@ -658,17 +659,17 @@ private void rewriteDependencyReferences(Dependency dependency, String rootArtif
}
}

private void rewritePluginReferences(Plugin plugin, String rootArtifactId, String groupId) {
private void rewritePluginReferences( Plugin plugin, String rootArtifactId, String groupId )
{
if ( plugin.getArtifactId() != null && plugin.getArtifactId().indexOf( rootArtifactId ) >= 0 )
{
if ( plugin.getGroupId() != null )
{
plugin.setGroupId(
StringUtils.replace(plugin.getGroupId(), groupId, "${" + Constants.GROUP_ID + "}") );
String g = StringUtils.replace( plugin.getGroupId(), groupId, "${" + Constants.GROUP_ID + "}" );
plugin.setGroupId( g );
}

plugin.setArtifactId(
StringUtils.replace( plugin.getArtifactId(), rootArtifactId, "${rootArtifactId}" ) );
plugin.setArtifactId( StringUtils.replace( plugin.getArtifactId(), rootArtifactId, "${rootArtifactId}" ) );

if ( plugin.getVersion() != null )
{
Expand All @@ -678,13 +679,14 @@ private void rewritePluginReferences(Plugin plugin, String rootArtifactId, Strin

if ( plugin.getArtifactId() != null && "maven-ear-plugin".equals( plugin.getArtifactId() ) )
{
rewriteEARPluginReferences(plugin, rootArtifactId, groupId);
rewriteEARPluginReferences( plugin, rootArtifactId, groupId );
}
}

private void rewriteEARPluginReferences(Plugin plugin, String rootArtifactId, String groupId) {
private void rewriteEARPluginReferences( Plugin plugin, String rootArtifactId, String groupId )
{
Xpp3Dom configuration = (Xpp3Dom) plugin.getConfiguration();
Xpp3Dom[] modules = configuration.getChild("modules").getChildren();
Xpp3Dom[] modules = configuration.getChild( "modules" ).getChildren();
for ( int i = 0; i < modules.length; i++ )
{
Xpp3Dom module = modules[i];
Expand All @@ -694,29 +696,34 @@ private void rewriteEARPluginReferences(Plugin plugin, String rootArtifactId, St
Xpp3Dom moduleModuleId = module.getChild( "moduleId" );
Xpp3Dom moduleContextRoot = module.getChild( "contextRoot" );

if (moduleGroupId != null)
if ( moduleGroupId != null )
{
moduleGroupId.setValue( StringUtils.replace(moduleGroupId.getValue(), groupId, "${" + Constants.GROUP_ID + "}") );
moduleGroupId.setValue( StringUtils.replace( moduleGroupId.getValue(), groupId, "${"
+ Constants.GROUP_ID + "}" ) );
}

if (moduleArtifactId != null)
if ( moduleArtifactId != null )
{
moduleArtifactId.setValue( StringUtils.replace( moduleArtifactId.getValue(), rootArtifactId, "${rootArtifactId}" ) );
moduleArtifactId.setValue( StringUtils.replace( moduleArtifactId.getValue(), rootArtifactId,
"${rootArtifactId}" ) );
}

if (moduleBundleFileName != null)
if ( moduleBundleFileName != null )
{
moduleBundleFileName.setValue( StringUtils.replace( moduleBundleFileName.getValue(), rootArtifactId, "${rootArtifactId}" ) );
moduleBundleFileName.setValue( StringUtils.replace( moduleBundleFileName.getValue(), rootArtifactId,
"${rootArtifactId}" ) );
}

if (moduleModuleId != null)
if ( moduleModuleId != null )
{
moduleModuleId.setValue( StringUtils.replace( moduleModuleId.getValue(), rootArtifactId, "${rootArtifactId}" ) );
moduleModuleId.setValue( StringUtils.replace( moduleModuleId.getValue(), rootArtifactId,
"${rootArtifactId}" ) );
}

if (moduleContextRoot != null)
if ( moduleContextRoot != null )
{
moduleContextRoot.setValue( StringUtils.replace( moduleContextRoot.getValue(), rootArtifactId, "${rootArtifactId}" ) );
moduleContextRoot.setValue( StringUtils.replace( moduleContextRoot.getValue(), rootArtifactId,
"${rootArtifactId}" ) );
}
}
}
Expand Down
Expand Up @@ -87,7 +87,8 @@ else if ( repositories.isEmpty() && localRepository != null )
}
catch ( ArtifactNotFoundException e )
{
throw new DownloadNotFoundException( "Requested " + artifact.getId() + " download's POM does not exist.", e );
throw new DownloadNotFoundException( "Requested " + artifact.getId()
+ " download's POM does not exist.", e );
}

return artifact.getFile();
Expand Down
Expand Up @@ -186,7 +186,8 @@ public void createArchetype( ArchetypeGenerationRequest request, File archetypeF

if ( is == null )
{
throw new ArchetypeDescriptorException( "The " + ARCHETYPE_DESCRIPTOR + " descriptor cannot be found." );
throw new ArchetypeDescriptorException( "The " + ARCHETYPE_DESCRIPTOR
+ " descriptor cannot be found." );
}

descriptor = builder.build( new XmlStreamReader( is ) );
Expand Down

0 comments on commit b26cbe5

Please sign in to comment.