docs: @SuppressWarnings({"checkstyle:cyclomaticcomplexity", "checkstyle:npathcomplexity"})
  	protected synchronized String replaceInString(File sourceFile, int sourceLine, String file,
  			ExtendedArtifact artifact, String line, ReplacementType replacementType) throws MojoExecutionException {
  		// No possibility of replacement
  		if (!line.contains("$")) { //$NON-NLS-1$
  			return line;
  		}
  
  		final String replacementName = (artifact == null) ? null : artifact.getName();
  		final String replacementVersion = (artifact == null) ? null : artifact.getVersion();
  		final String replacementRevision = (artifact == null) ? null : artifact.getScmRevision();
  		final String replacementArtifactId = ensureArtifactId(artifact);
  		final String replacementGroupId = ensureGroupId(artifact);
  		final String replacementWebsite = (artifact == null) ? null : artifact.getWebsite();
  		final String replacementFilename = (artifact == null) ? null : file;
  
  		String replacementOrganization = null;
  
  		if (artifact != null) {
  			final Organization orga = artifact.getOrganization();
  			if (orga != null) {
  				replacementOrganization = orga.getName();
  			}
  		}
  
  		SimpleDateFormat fmt = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); //$NON-NLS-1$
  		final String currentDate = fmt.format(this.invocationDate);
  
  		fmt = new SimpleDateFormat("yyyy"); //$NON-NLS-1$
  		final String year = fmt.format(this.invocationDate);
  
  		String inceptionYear = null;
  		final MavenProject project = getMavenProject(artifact);
  		if (project != null) {
  			inceptionYear = project.getInceptionYear();
  		}
  		if (inceptionYear == null || inceptionYear.isEmpty()) {
  			inceptionYear = year;
  		}
  
  		final String replacementFullVersion;
  		if (artifact == null) {
  			replacementFullVersion = null;
  		} else {
  			String rev = null;
  			if (replacementRevision != null) {
  				rev = "(rev:" + //$NON-NLS-1$
  						replacementRevision
  						+ ")"; //$NON-NLS-1$
  			}
  			replacementFullVersion = join(" ", //$NON-NLS-1$
  					replacementVersion, rev, currentDate);
  		}
  
  		String nline = line;
  		nline = replaceMacro(Macros.MACRO_NAME, nline, replacementName, replacementType, sourceFile, sourceLine);
  		nline = replaceMacro(Macros.MACRO_REVISION, nline, replacementRevision, replacementType, sourceFile, sourceLine);
  		nline = replaceMacro(Macros.MACRO_VERSION, nline, replacementVersion, replacementType, sourceFile, sourceLine);
  		nline = replaceMacro(Macros.MACRO_ARTIFACTID, nline, replacementArtifactId, replacementType, sourceFile, sourceLine);
  		nline = replaceMacro(Macros.MACRO_GROUPID, nline, replacementGroupId, replacementType, sourceFile, sourceLine);
  		nline = replaceMacro(Macros.MACRO_WEBSITE, nline, replacementWebsite, replacementType, sourceFile, sourceLine);
  		nline = replaceMacro(Macros.MACRO_ORGANIZATION, nline, replacementOrganization, replacementType, sourceFile, sourceLine);
  		nline = replaceMacro(Macros.MACRO_DATE, nline, currentDate, replacementType, sourceFile, sourceLine);
  		nline = replaceMacro(Macros.MACRO_YEAR, nline, year, replacementType, sourceFile, sourceLine);
  		nline = replaceMacro(Macros.MACRO_INCEPTIONYEAR, nline, inceptionYear, replacementType, sourceFile, sourceLine);
  		nline = replaceMacro(Macros.MACRO_FULLVERSION, nline, replacementFullVersion, replacementType, sourceFile, sourceLine);
  		nline = replaceMacro(Macros.MACRO_FILENAME, nline, replacementFilename, replacementType, sourceFile, sourceLine);
  
  		final StringBuilder buffer = new StringBuilder();
  		buffer.setLength(0);
  		// Split the string int "$" and "Id" to avoid the plugin to replace the tag in its own source fole
  		buffer.append("$" + "Id: "); //$NON-NLS-1$ //$NON-NLS-2$
  		buffer.append(file);
  		buffer.append(' ');
  		if (replacementRevision != null) {
  			buffer.append("rev:"); //$NON-NLS-1$
  			buffer.append(replacementRevision);
  			buffer.append(' ');
  		}
  		if (replacementVersion != null) {
  			buffer.append('v');
  			buffer.append(replacementVersion);
  			buffer.append(' ');
  		}
  		buffer.append(currentDate);
  		buffer.append("$"); //$NON-NLS-1$
  		nline = replaceMacro(Macros.MACRO_ID, nline, buffer.toString(), ReplacementType.TEXT, sourceFile, sourceLine);
  
  		nline = replaceAuthor(sourceFile, sourceLine, nline, artifact, replacementType);
  		nline = replaceProp(sourceFile, sourceLine, nline, project, replacementType);
  
  		return nline;
  	}