Skip to content

Commit

Permalink
chore(spdx-utils): Remove ANTLR parser
Browse files Browse the repository at this point in the history
Remove the dependency on ANTLR and all related files, as the parser
generated by ANTLR was replaced in the previous commit.

Relaates to #8164.

Signed-off-by: Martin Nonnenmacher <[email protected]>
  • Loading branch information
mnonnenmacher committed Feb 4, 2024
1 parent 9fa513a commit bbf3525
Show file tree
Hide file tree
Showing 8 changed files with 12 additions and 336 deletions.
2 changes: 0 additions & 2 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ kotlinPlugin = "1.9.22"
mavenPublishPlugin = "0.27.0"
versionsPlugin = "0.51.0"

antlr = "4.13.1"
asciidoctorj = "2.5.11"
asciidoctorjPdf = "2.3.10"
clikt = "4.2.2"
Expand Down Expand Up @@ -80,7 +79,6 @@ plugin-graalVmNativeImage = { module = "org.graalvm.buildtools:native-gradle-plu
plugin-kotlin = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin", version.ref = "kotlinPlugin" }
plugin-mavenPublish = { module = "com.vanniktech:gradle-maven-publish-plugin", version.ref = "mavenPublishPlugin" }

antlr = { module = "org.antlr:antlr4", version.ref = "antlr" }
asciidoctorj = { module = "org.asciidoctor:asciidoctorj", version.ref = "asciidoctorj" }
asciidoctorj-pdf = { module = "org.asciidoctor:asciidoctorj-pdf", version.ref = "asciidoctorjPdf" }
awsS3 = { module = "software.amazon.awssdk:s3", version.ref = "s3" }
Expand Down
36 changes: 0 additions & 36 deletions utils/spdx/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -28,50 +28,14 @@ import java.net.URI
val spdxLicenseListVersion: String by project

plugins {
// Apply core plugins.
antlr

// Apply precompiled plugins.
id("ort-library-conventions")

// Apply third-party plugins.
alias(libs.plugins.download)
}

tasks.withType<AntlrTask>().configureEach {
arguments = arguments + listOf("-visitor")

doLast {
// Work around https://github.com/antlr/antlr4/issues/4128.
outputDirectory.walk()
.filter { it.isFile && it.extension == "java" }
.forEach { javaFile ->
val lines = javaFile.readLines()

val text = buildString {
lines.mapIndexed { index, line ->
val patchedLine = when {
index == 0 && line.startsWith("// Generated from ") -> line.replace('\\', '/')
else -> line
}

appendLine(patchedLine)
}
}

javaFile.writeText(text)
}
}
}

sourceSets.configureEach {
val generateGrammarSource = tasks.named(getTaskName("generate", "GrammarSource"))
java.srcDir(generateGrammarSource.map { files() })
}

dependencies {
antlr(libs.antlr)

api(libs.jackson.databind)

implementation(projects.utils.commonUtils)
Expand Down

This file was deleted.

40 changes: 0 additions & 40 deletions utils/spdx/src/main/kotlin/SpdxErrorListener.kt

This file was deleted.

89 changes: 0 additions & 89 deletions utils/spdx/src/main/kotlin/SpdxExpressionDefaultVisitor.kt

This file was deleted.

3 changes: 2 additions & 1 deletion utils/spdx/src/test/kotlin/SpdxDeclaredLicenseMappingTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import io.kotest.matchers.string.containADigit
import io.kotest.matchers.string.shouldContain

import org.ossreviewtoolkit.utils.common.titlecase
import org.ossreviewtoolkit.utils.spdx.parser.SpdxExpressionLexer

class SpdxDeclaredLicenseMappingTest : WordSpec({
"The list" should {
Expand Down Expand Up @@ -76,7 +77,7 @@ class SpdxDeclaredLicenseMappingTest : WordSpec({
licenseIdMapping.keys.forAll { declaredLicense ->
@Suppress("SwallowedException")
try {
val tokens = getTokensByTypeForExpression(declaredLicense)
val tokens = SpdxExpressionLexer(declaredLicense).tokens().toList()

tokens.size shouldBeGreaterThanOrEqual 2

Expand Down
78 changes: 0 additions & 78 deletions utils/spdx/src/test/kotlin/SpdxExpressionLexerTest.kt

This file was deleted.

Loading

0 comments on commit bbf3525

Please sign in to comment.