The following document contains the results of PMD's CPD 4.2.5.
| File | Line |
|---|---|
| org/apache/maven/archetype/creator/FilesetArchetypeCreator.java | 853 |
| org/apache/maven/archetype/creator/FilesetArchetypeCreator.java | 1074 |
private void createModulePom( Model pom, String rootArtifactId, File archetypeFilesDirectory,
Properties pomReversedProperties, File initialPomFile, boolean preserveCData,
boolean keepParent )
throws IOException
{
File outputFile = FileUtils.resolveFile( archetypeFilesDirectory, Constants.ARCHETYPE_POM );
if ( preserveCData )
{
getLogger().debug( "Preserving CDATA parts of pom" );
File inputFile = FileUtils.resolveFile( archetypeFilesDirectory, Constants.ARCHETYPE_POM + ".tmp" );
FileUtils.copyFile( initialPomFile, inputFile );
Reader in = null;
Writer out = null;
try
{
in = ReaderFactory.newXmlReader( inputFile );
String initialcontent = IOUtil.toString( in );
String content = getReversedContent( initialcontent, pomReversedProperties );
outputFile.getParentFile().mkdirs();
out = WriterFactory.newXmlWriter( outputFile );
IOUtil.copy( content, out );
}
finally
{
IOUtil.close( in );
IOUtil.close( out );
}
inputFile.delete();
}
else
{
if ( pom.getParent() != null ) | |
| File | Line |
|---|---|
| org/apache/maven/archetype/common/MavenJDOMWriter.java | 1792 |
| org/apache/maven/archetype/common/MavenJDOMWriter.java | 2060 |
updateBuildBase( value.getBuild(), "build", innerCount, root );
findAndReplaceSimpleLists( innerCount, root, value.getModules(), "modules", "module" );
iterateRepository( innerCount, root, value.getRepositories(), "repositories", "repository" );
iterateRepository( innerCount, root, value.getPluginRepositories(), "pluginRepositories", "pluginRepository" );
iterateDependency( innerCount, root, value.getDependencies(), "dependencies", "dependency" );
findAndReplaceXpp3DOM( innerCount, root, "reports", (Xpp3Dom) value.getReports() );
updateReporting( value.getReporting(), "reporting", innerCount, root );
updateDependencyManagement( value.getDependencyManagement(), "dependencyManagement", innerCount, root );
updateDistributionManagement( value.getDistributionManagement(), "distributionManagement", innerCount, root );
findAndReplaceProperties( innerCount, root, "properties", value.getProperties() );
} // -- void updateProfile(Profile, String, Counter, Element)
/**
* Method updateRelocation.
*
* @param value
* @param element
* @param counter
* @param xmlTag
*/
protected void updateRelocation( Relocation value, String xmlTag, Counter counter, Element element ) | |
| File | Line |
|---|---|
| org/apache/maven/archetype/common/MavenJDOMWriter.java | 1792 |
| org/apache/maven/archetype/common/MavenJDOMWriter.java | 1818 |
Counter innerCount = new Counter( counter.getDepth() + 1 );
findAndReplaceSimpleLists( innerCount, root, value.getModules(), "modules", "module" );
iterateRepository( innerCount, root, value.getRepositories(), "repositories", "repository" );
iterateRepository( innerCount, root, value.getPluginRepositories(), "pluginRepositories",
"pluginRepository" );
iterateDependency( innerCount, root, value.getDependencies(), "dependencies", "dependency" );
findAndReplaceXpp3DOM( innerCount, root, "reports", (Xpp3Dom) value.getReports() );
updateReporting( value.getReporting(), "reporting", innerCount, root );
updateDependencyManagement( value.getDependencyManagement(), "dependencyManagement", innerCount, root );
updateDistributionManagement( value.getDistributionManagement(), "distributionManagement", innerCount,
root );
findAndReplaceProperties( innerCount, root, "properties", value.getProperties() );
} | |
| File | Line |
|---|---|
| org/apache/maven/archetype/creator/FilesetArchetypeCreator.java | 629 |
| org/apache/maven/archetype/creator/FilesetArchetypeCreator.java | 748 |
for ( Iterator<Plugin> plugins = profile.getBuild().getPluginManagement().getPlugins().iterator();
plugins.hasNext(); )
{
Plugin plugin = plugins.next();
if ( plugin.getArtifactId() != null && plugin.getArtifactId().indexOf( rootArtifactId ) >= 0 )
{
if ( plugin.getGroupId() != null )
{
plugin.setGroupId( StringUtils.replace( plugin.getGroupId(), groupId,
"${" + Constants.GROUP_ID + "}" ) );
}
plugin.setArtifactId( StringUtils.replace( plugin.getArtifactId(), rootArtifactId,
"${rootArtifactId}" ) );
if ( plugin.getVersion() != null )
{
plugin.setVersion( "${" + Constants.VERSION + "}" );
}
}
}
} | |
| File | Line |
|---|---|
| org/apache/maven/archetype/common/util/FileCharsetDetector.java | 58 |
| org/apache/maven/archetype/common/util/FileCharsetDetector.java | 114 |
BufferedInputStream imp = new BufferedInputStream( detectedStream );
byte[] buf = new byte[1024];
int len;
boolean done = false;
boolean isAscii = true;
while ( ( len = imp.read( buf, 0, buf.length ) ) != -1 )
{
// Check if the stream is only ascii.
if ( isAscii )
{
isAscii = det.isAscii( buf, len );
}
// DoIt if non-ascii and not done yet.
if ( !isAscii && !done )
{
done = det.DoIt( buf, len, false );
found = done;
}
}
det.DataEnd();
if ( !isFound() )
{
String[] prob = det.getProbableCharsets();
if ( prob.length > 0 )
{
charset = prob[0];
}
}
if ( isAscii )
{
charset = "ASCII";
}
}
public String getCharset() | |
| File | Line |
|---|---|
| org/apache/maven/archetype/creator/FilesetArchetypeCreator.java | 601 |
| org/apache/maven/archetype/creator/FilesetArchetypeCreator.java | 629 |
for ( Iterator<Plugin> plugins = pom.getBuild().getPluginManagement().getPlugins().iterator(); plugins.hasNext(); )
{
Plugin plugin = plugins.next();
if ( plugin.getArtifactId() != null && plugin.getArtifactId().indexOf( rootArtifactId ) >= 0 )
{
if ( plugin.getGroupId() != null )
{
plugin.setGroupId( StringUtils.replace( plugin.getGroupId(), groupId,
"${" + Constants.GROUP_ID + "}" ) );
}
plugin.setArtifactId( StringUtils.replace( plugin.getArtifactId(), rootArtifactId,
"${rootArtifactId}" ) );
if ( plugin.getVersion() != null )
{
plugin.setVersion( "${" + Constants.VERSION + "}" );
}
}
}
}
// rewrite Profiles
if ( pom.getProfiles() != null ) | |
| File | Line |
|---|---|
| org/apache/maven/archetype/creator/FilesetArchetypeCreator.java | 601 |
| org/apache/maven/archetype/creator/FilesetArchetypeCreator.java | 720 |
for ( Iterator<Plugin> plugins = profile.getBuild().getPlugins().iterator(); plugins.hasNext(); )
{
Plugin plugin = plugins.next();
if ( plugin.getArtifactId() != null && plugin.getArtifactId().indexOf( rootArtifactId ) >= 0 )
{
if ( plugin.getGroupId() != null )
{
plugin.setGroupId( StringUtils.replace( plugin.getGroupId(), groupId,
"${" + Constants.GROUP_ID + "}" ) );
}
plugin.setArtifactId( StringUtils.replace( plugin.getArtifactId(), rootArtifactId,
"${rootArtifactId}" ) );
if ( plugin.getVersion() != null )
{
plugin.setVersion( "${" + Constants.VERSION + "}" );
}
}
}
}
// rewrite PluginManagement
if ( profile.getBuild() != null && profile.getBuild().getPluginManagement() != null | |
| File | Line |
|---|---|
| org/apache/maven/archetype/creator/FilesetArchetypeCreator.java | 574 |
| org/apache/maven/archetype/creator/FilesetArchetypeCreator.java | 692 |
profile.getDependencyManagement().getDependencies().iterator(); dependencies.hasNext(); )
{
Dependency dependency = dependencies.next();
if ( dependency.getArtifactId() != null
&& dependency.getArtifactId().indexOf( rootArtifactId ) >= 0 )
{
if ( dependency.getGroupId() != null )
{
dependency.setGroupId( StringUtils.replace( dependency.getGroupId(), groupId,
"${" + Constants.GROUP_ID + "}" ) );
}
dependency.setArtifactId( StringUtils.replace( dependency.getArtifactId(), rootArtifactId,
"${rootArtifactId}" ) );
if ( dependency.getVersion() != null )
{
dependency.setVersion( "${" + Constants.VERSION + "}" );
}
}
}
}
// rewrite Plugins
if ( profile.getBuild() != null && profile.getBuild().getPlugins() != null | |
| File | Line |
|---|---|
| org/apache/maven/archetype/creator/FilesetArchetypeCreator.java | 547 |
| org/apache/maven/archetype/creator/FilesetArchetypeCreator.java | 574 |
for ( Iterator<Dependency> dependencies = pom.getDependencyManagement().getDependencies().iterator();
dependencies.hasNext(); )
{
Dependency dependency = dependencies.next();
if ( dependency.getArtifactId() != null && dependency.getArtifactId().indexOf( rootArtifactId ) >= 0 )
{
if ( dependency.getGroupId() != null )
{
dependency.setGroupId( StringUtils.replace( dependency.getGroupId(), groupId,
"${" + Constants.GROUP_ID + "}" ) );
}
dependency.setArtifactId( StringUtils.replace( dependency.getArtifactId(), rootArtifactId,
"${rootArtifactId}" ) );
if ( dependency.getVersion() != null )
{
dependency.setVersion( "${" + Constants.VERSION + "}" );
}
}
}
}
// rewrite Plugins
if ( pom.getBuild() != null && pom.getBuild().getPlugins() != null && !pom.getBuild().getPlugins().isEmpty() ) | |
| File | Line |
|---|---|
| org/apache/maven/archetype/creator/FilesetArchetypeCreator.java | 720 |
| org/apache/maven/archetype/creator/FilesetArchetypeCreator.java | 748 |
for ( Iterator<Plugin> plugins = profile.getBuild().getPluginManagement().getPlugins().iterator();
plugins.hasNext(); )
{
Plugin plugin = plugins.next();
if ( plugin.getArtifactId() != null && plugin.getArtifactId().indexOf( rootArtifactId ) >= 0 )
{
if ( plugin.getGroupId() != null )
{
plugin.setGroupId( StringUtils.replace( plugin.getGroupId(), groupId,
"${" + Constants.GROUP_ID + "}" ) );
}
plugin.setArtifactId( StringUtils.replace( plugin.getArtifactId(), rootArtifactId,
"${rootArtifactId}" ) );
if ( plugin.getVersion() != null )
{
plugin.setVersion( "${" + Constants.VERSION + "}" );
}
}
}
} | |
| File | Line |
|---|---|
| org/apache/maven/archetype/creator/FilesetArchetypeCreator.java | 547 |
| org/apache/maven/archetype/creator/FilesetArchetypeCreator.java | 692 |
for ( Iterator<Dependency> dependencies = profile.getDependencies().iterator(); dependencies.hasNext(); )
{
Dependency dependency = dependencies.next();
if ( dependency.getArtifactId() != null
&& dependency.getArtifactId().indexOf( rootArtifactId ) >= 0 )
{
if ( dependency.getGroupId() != null )
{
dependency.setGroupId( StringUtils.replace( dependency.getGroupId(), groupId,
"${" + Constants.GROUP_ID + "}" ) );
}
dependency.setArtifactId( StringUtils.replace( dependency.getArtifactId(), rootArtifactId,
"${rootArtifactId}" ) );
if ( dependency.getVersion() != null )
{
dependency.setVersion( "${" + Constants.VERSION + "}" );
}
}
}
}
// rewrite DependencyManagement
if ( profile.getDependencyManagement() != null | |
| File | Line |
|---|---|
| org/apache/maven/archetype/common/MavenJDOMWriter.java | 1386 |
| org/apache/maven/archetype/common/MavenJDOMWriter.java | 1412 |
Counter innerCount = new Counter( counter.getDepth() + 1 );
findAndReplaceSimpleElement( innerCount, root, "defaultGoal", value.getDefaultGoal(), null );
iterateResource( innerCount, root, value.getResources(), "resources", "resource" );
iterateResource( innerCount, root, value.getTestResources(), "testResources", "testResource" );
findAndReplaceSimpleElement( innerCount, root, "directory", value.getDirectory(), null );
findAndReplaceSimpleElement( innerCount, root, "finalName", value.getFinalName(), null );
findAndReplaceSimpleLists( innerCount, root, value.getFilters(), "filters", "filter" );
updatePluginManagement( value.getPluginManagement(), "pluginManagement", innerCount, root );
iteratePlugin( innerCount, root, value.getPlugins(), "plugins", "plugin" );
}
} // -- void updateBuildBase(BuildBase, String, Counter, Element)
/**
* Method updateCiManagement.
*
* @param value
* @param element
* @param counter
* @param xmlTag
*/
protected void updateCiManagement( CiManagement value, String xmlTag, Counter counter, Element element ) | |
| File | Line |
|---|---|
| org/apache/maven/archetype/common/MavenJDOMWriter.java | 1477 |
| org/apache/maven/archetype/common/MavenJDOMWriter.java | 1571 |
findAndReplaceSimpleElement( innerCount, root, "id", value.getId(), null );
findAndReplaceSimpleElement( innerCount, root, "name", value.getName(), null );
findAndReplaceSimpleElement( innerCount, root, "email", value.getEmail(), null );
findAndReplaceSimpleElement( innerCount, root, "url", value.getUrl(), null );
findAndReplaceSimpleElement( innerCount, root, "organization", value.getOrganization(), null );
findAndReplaceSimpleElement( innerCount, root, "organizationUrl", value.getOrganizationUrl(), null );
findAndReplaceSimpleLists( innerCount, root, value.getRoles(), "roles", "role" );
findAndReplaceSimpleElement( innerCount, root, "timezone", value.getTimezone(), null );
findAndReplaceProperties( innerCount, root, "properties", value.getProperties() );
} // -- void updateDeveloper(Developer, String, Counter, Element)
/**
* Method updateDistributionManagement.
*
* @param value
* @param element
* @param counter
* @param xmlTag
*/
protected void updateDistributionManagement( DistributionManagement value, String xmlTag, Counter counter, | |
| File | Line |
|---|---|
| org/apache/maven/archetype/common/MavenJDOMWriter.java | 383 |
| org/apache/maven/archetype/common/MavenJDOMWriter.java | 719 |
protected void iterateResource( Counter counter, Element parent, java.util.Collection list,
java.lang.String parentTag, java.lang.String childTag )
{
boolean shouldExist = ( list != null ) && ( list.size() > 0 );
Element element = updateElement( counter, parent, parentTag, shouldExist );
if ( shouldExist )
{
Iterator it = list.iterator();
Iterator elIt = element.getChildren( childTag, element.getNamespace() ).iterator();
if ( !elIt.hasNext() )
{
elIt = null;
}
Counter innerCount = new Counter( counter.getDepth() + 1 );
while ( it.hasNext() )
{ | |
| File | Line |
|---|---|
| org/apache/maven/archetype/common/util/XMLOutputter.java | 1579 |
| org/apache/maven/archetype/common/util/XMLOutputter.java | 1665 |
break;
default:
if ( strategy.shouldEscape( ch ) )
{
entity = "&#x" + Integer.toHexString( ch ) + ";";
}
else
{
entity = null;
}
break;
}
if ( buffer == null )
{
if ( entity != null )
{
// An entity occurred, so we'll have to use StringBuffer
// (allocate room for it plus a few more entities).
buffer = new StringBuffer( str.length() + 20 );
// Copy previous skipped characters and fall through
// to pickup current character
buffer.append( str.substring( 0, i ) );
buffer.append( entity );
}
}
else
{
if ( entity == null )
{
buffer.append( ch );
}
else
{
buffer.append( entity );
}
}
}
// If there were any entities, return the escaped characters
// that we put in the StringBuffer. Otherwise, just return
// the unmodified input string.
return ( buffer == null ) ? str : buffer.toString();
}
/** Returns a copy of this XMLOutputter. */
public Object clone() | |
| File | Line |
|---|---|
| org/apache/maven/archetype/creator/FilesetArchetypeCreator.java | 793 |
| org/apache/maven/archetype/creator/FilesetArchetypeCreator.java | 1282 |
Properties reverseProperties, String defaultEncoding )
throws IOException
{
String packageAsDirectory = StringUtils.replace( packageName, ".", File.separator );
getLogger().debug( "Package as Directory: Package:" + packageName + "->" + packageAsDirectory );
for ( String inputFileName : fileSetResources )
{
String outputFileName =
packaged ? StringUtils.replace( inputFileName, packageAsDirectory + File.separator, "" )
: inputFileName;
getLogger().debug( "InputFileName:" + inputFileName );
getLogger().debug( "OutputFileName:" + outputFileName );
File outputFile = new File( archetypeFilesDirectory, outputFileName );
File inputFile = new File( basedir, inputFileName ); | |