@@ -3,7 +3,9 @@ import static java.nio.file.StandardCopyOption.REPLACE_EXISTING
33
44import java.nio.file.Files
55import java.nio.file.Paths
6+ import java.nio.file.Path
67import java.util.regex.Pattern
8+ import groovy.cli.picocli.CliBuilder
79
810static void main (String [] args ) {
911 def cliOptions = getCliOptions(args)
@@ -571,7 +573,7 @@ def generateAndPrintConfigHtmlFile(diffDir, configFile, textTransform, summaryIn
571573 def configfilenameWithoutExtension = getFilenameWithoutExtension(configFile. name)
572574 def configFileHtml = new File (" $diffDir /${ configfilenameWithoutExtension} .html" )
573575 textTransform. transform(configFile. name, configFileHtml. toPath(). toString(), Locale . ENGLISH ,
574- " UTF-8" , " UTF-8" )
576+ " UTF-8" , " UTF-8" , " UTF-8 " )
575577
576578 summaryIndexHtml << (' <h6>' )
577579 summaryIndexHtml << (" <a href='${ configFileHtml.name} '>${ configFile.name} file</a>" )
@@ -703,27 +705,51 @@ def runMavenExecution(srcDir, excludes, checkstyleConfig,
703705}
704706
705707def postProcessCheckstyleReport (targetDir , repoName , repoPath ) {
706- new AntBuilder (). replace(
707- file : getOsSpecificPath(" $targetDir " , " checkstyle-result.xml" ),
708- token : new File (getOsSpecificPath(" src" , " main" , " java" , " $repoName " )). absolutePath,
709- value : getOsSpecificPath(" $repoPath " )
710- )
708+ def checkstyleResultFile = new File (getOsSpecificPath(" $targetDir " , " checkstyle-result.xml" ))
709+ if (checkstyleResultFile. exists()) {
710+ def content = checkstyleResultFile. text
711+ def oldPath = new File (getOsSpecificPath(" src" , " main" , " java" , " $repoName " )). absolutePath
712+ def newContent = content. replace(oldPath, getOsSpecificPath(" $repoPath " ))
713+ checkstyleResultFile. text = newContent
714+ }
711715}
712716
713717def copyDir (source , destination ) {
714- new AntBuilder (). copy(todir : destination) {
715- fileset(dir : source)
718+ def sourceDir = new File (source)
719+ def destDir = new File (destination)
720+
721+ if (! destDir. exists()) {
722+ destDir. mkdirs()
723+ }
724+
725+ sourceDir. eachFileRecurse { file ->
726+ def relativePath = sourceDir. toPath(). relativize(file. toPath())
727+ def destFile = new File (destDir, relativePath. toString())
728+
729+ if (file. isDirectory()) {
730+ destFile. mkdirs()
731+ } else {
732+ Files . copy(file. toPath(), destFile. toPath(), REPLACE_EXISTING )
733+ }
716734 }
717735}
718736
719737def moveDir (source , destination ) {
720- new AntBuilder (). move(todir : destination) {
721- fileset(dir : source)
738+ def sourceDir = new File (source)
739+ def destDir = new File (destination)
740+
741+ if (sourceDir. exists()) {
742+ // First copy, then delete
743+ copyDir(source, destination)
744+ deleteDir(source)
722745 }
723746}
724747
725748def deleteDir (dir ) {
726- new AntBuilder (). delete(dir : dir, failonerror : false )
749+ def dirFile = new File (dir)
750+ if (dirFile. exists() && dirFile. isDirectory()) {
751+ dirFile. deleteDir()
752+ }
727753}
728754
729755def executeCmd (cmd , dir = new File (" " ). absoluteFile) {
0 commit comments