Skip to content

Commit

Permalink
Issue #530: Remove JXR library from launch.groovy
Browse files Browse the repository at this point in the history
  • Loading branch information
nrmancuso committed Dec 29, 2020
1 parent a2d3058 commit 2748899
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 81 deletions.
64 changes: 0 additions & 64 deletions checkstyle-tester/launch.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -248,77 +248,13 @@ def runMavenExecution(srcDir, excludes, checkstyleConfig, ignoreExceptions, chec
}

def postProcessCheckstyleReport(targetDir, repoName, repoPath) {
def siteDir = getOsSpecificPath("$targetDir", "site")
println 'linking report to index.html'
new File(getOsSpecificPath("$siteDir", "index.html")).renameTo getOsSpecificPath("$siteDir", "_index.html")
Files.createLink(Paths.get(getOsSpecificPath("$siteDir", "index.html")),
Paths.get(getOsSpecificPath("$siteDir", "checkstyle.html")))

removeNonReferencedXrefFiles(siteDir)
removeEmptyDirectories(new File(getOsSpecificPath("$siteDir", "xref")))

new AntBuilder().replace(
file: getOsSpecificPath("$targetDir", "checkstyle-result.xml"),
token: new File(getOsSpecificPath("src", "main", "java", "$repoName")).absolutePath,
value: getOsSpecificPath("$repoPath")
)
}

def removeNonReferencedXrefFiles(siteDir) {
println 'Removing non referenced xref files in report ...'

def linesFromIndexHtml = Files.readAllLines(Paths.get("$siteDir/index.html"))
def filesReferencedInReport = getFilesReferencedInReport(linesFromIndexHtml)

def xrefPath = Paths.get(getOsSpecificPath("$siteDir", "xref"))
if (Files.isDirectory(xrefPath)) {
xrefPath.toFile().eachFileRecurse {
fileObj ->
def path = fileObj.path
path = path.substring(path.indexOf("xref"))
if (isWindows()) {
path = path.replace("\\", "/")
}
def fileName = fileObj.name
if (fileObj.isFile()
&& !filesReferencedInReport.contains(path)
&& 'stylesheet.css' != fileName
&& 'allclasses-frame.html' != fileName
&& 'index.html' != fileName
&& 'overview-frame.html' != fileName
&& 'overview-summary.html' != fileName) {
fileObj.delete()
}
}
}
}

def getFilesReferencedInReport(linesFromIndexHtml) {
def xrefStartIdx = 2
def pattern = Pattern.compile('\\./xref/[^<>]+\\.html')
def referencedFiles = new HashSet<String>()
linesFromIndexHtml.each {
line ->
def matcher = pattern.matcher(line)
if (matcher.find()) {
referencedFiles.addAll(matcher.collect { it.substring(xrefStartIdx) })
}
}
return referencedFiles
}

def removeEmptyDirectories(file) {
def contents = file.listFiles()
if (contents != null) {
for (File f : contents) {
removeEmptyDirectories(f)
}
}
if (file.isDirectory() && file.listFiles().length == 0) {
file.delete()
}
}

def executeCmd(cmd, dir = new File("").getAbsoluteFile()) {
println "Running command: ${cmd}"
def osSpecificCmd = getOsSpecificCmd(cmd)
Expand Down
17 changes: 0 additions & 17 deletions checkstyle-tester/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
<checkstyle-plugin.version>3.1.1</checkstyle-plugin.version>
<checkstyle.version>8.39-SNAPSHOT</checkstyle.version>
<sevntu-checkstyle.version>1.38.0</sevntu-checkstyle.version>
<jxr-plugin.version>2.5</jxr-plugin.version>
<checkstyle.config.location>https://raw.githubusercontent.com/checkstyle/checkstyle/master/src/main/resources/google_checks.xml</checkstyle.config.location>
<checkstyle.failsOnError>true</checkstyle.failsOnError>
</properties>
Expand All @@ -36,11 +35,6 @@
<artifactId>sevntu-checks</artifactId>
<version>${sevntu-checkstyle.version}</version>
</dependency>
<dependency>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jxr-plugin</artifactId>
<version>${jxr-plugin.version}</version>
</dependency>
</dependencies>
</plugin>

Expand Down Expand Up @@ -70,17 +64,6 @@
<failsOnError>${checkstyle.failsOnError}</failsOnError>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jxr-plugin</artifactId>
<version>${jxr-plugin.version}</version>
<!-- plugin do not have ability to define followinng by system property -->
<configuration>
<excludes>
<exclude>**/.ci-temp/**/*</exclude>
</excludes>
</configuration>
</plugin>

</plugins>
</reporting>
Expand Down

0 comments on commit 2748899

Please sign in to comment.