Skip to content

Commit d02d76e

Browse files
Remove better.files dependency (#1871)
Replace its only usage (TestProtoCpg) with java.nio and java.util.zip, and drop the dependency from sbt and bazel (incl. maven_install.json).
1 parent 59c4ffa commit d02d76e

6 files changed

Lines changed: 44 additions & 51 deletions

File tree

‎MODULE.bazel‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ maven.install(
4747
"com.google.protobuf:protobuf-java:4.34.1",
4848
"com.lihaoyi:ujson_3:4.4.3",
4949
"com.lihaoyi:os-lib_3:0.11.4",
50-
"com.github.pathikrit:better-files_3:3.9.2",
5150
],
5251
excluded_artifacts = [
5352
# Exclude any scala libraries which might come in transitively.

‎codepropertygraph/BUILD‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ scala_test(
4444
":tests_java",
4545
"//schema:domainClassesNeverLinked",
4646
"//schema:java_proto",
47-
"@maven//:com_github_pathikrit_better_files_3",
4847
"@maven//:io_joern_flatgraph_core_3",
4948
"@maven//:io_joern_flatgraph_help_3",
5049
],

‎codepropertygraph/build.sbt‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ libraryDependencies ++= Seq(
77
"io.joern" %% "flatgraph-help" % Versions.flatgraph,
88
"io.joern" %% "flatgraph-odb-convert" % Versions.flatgraph,
99
"com.github.scopt" %% "scopt" % "4.0.1",
10-
"com.github.pathikrit" %% "better-files" % "3.9.2",
1110
"org.slf4j" % "slf4j-api" % "2.0.6",
1211
"org.scalatest" %% "scalatest" % Versions.scalatest % Test
1312
)
Lines changed: 44 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,58 @@
11
package io.shiftleft.codepropertygraph.cpgloading
22

3-
import better.files.File
43
import io.shiftleft.proto.cpg.Cpg
54
import io.shiftleft.proto.cpg.Cpg.CpgStruct
65

7-
import java.io.FileOutputStream
86
import java.nio.file.{Files, Path}
7+
import java.util.zip.{ZipEntry, ZipOutputStream}
98

109
object TestProtoCpg {
1110

1211
def createTestProtoCpg: Path = {
13-
val outDir = better.files.File.newTemporaryDirectory("cpgloadertests")
14-
val outStream = new FileOutputStream((outDir / "1.proto").pathAsString)
15-
CpgStruct
16-
.newBuilder()
17-
.addNode(
18-
CpgStruct.Node
19-
.newBuilder()
20-
.setKey(1)
21-
.setType(CpgStruct.Node.NodeType.valueOf("METHOD"))
22-
.addProperty(
23-
CpgStruct.Node.Property
24-
.newBuilder()
25-
.setName(Cpg.NodePropertyName.valueOf("FULL_NAME"))
26-
.setValue(
27-
Cpg.PropertyValue
28-
.newBuilder()
29-
.setStringValue("foo")
30-
.build()
31-
)
32-
.build
33-
)
34-
.build()
35-
)
36-
.build()
37-
.writeTo(outStream)
38-
outStream.close()
12+
val outDir = Files.createTempDirectory("cpgloadertests")
13+
val protoFile = outDir.resolve("1.proto")
14+
val outStream = Files.newOutputStream(protoFile)
15+
try {
16+
CpgStruct
17+
.newBuilder()
18+
.addNode(
19+
CpgStruct.Node
20+
.newBuilder()
21+
.setKey(1)
22+
.setType(CpgStruct.Node.NodeType.valueOf("METHOD"))
23+
.addProperty(
24+
CpgStruct.Node.Property
25+
.newBuilder()
26+
.setName(Cpg.NodePropertyName.valueOf("FULL_NAME"))
27+
.setValue(
28+
Cpg.PropertyValue
29+
.newBuilder()
30+
.setStringValue("foo")
31+
.build()
32+
)
33+
.build
34+
)
35+
.build()
36+
)
37+
.build()
38+
.writeTo(outStream)
39+
} finally {
40+
outStream.close()
41+
}
3942

40-
val zipFile = better.files.File.newTemporaryFile("cpgloadertests", ".bin.zip")
41-
outDir.zipTo(zipFile)
42-
outDir.delete()
43-
zipFile.path
43+
val zipFile = Files.createTempFile("cpgloadertests", ".bin.zip")
44+
val zipStream = new ZipOutputStream(Files.newOutputStream(zipFile))
45+
try {
46+
zipStream.putNextEntry(new ZipEntry("1.proto"))
47+
Files.copy(protoFile, zipStream)
48+
zipStream.closeEntry()
49+
} finally {
50+
zipStream.close()
51+
}
52+
53+
Files.delete(protoFile)
54+
Files.delete(outDir)
55+
zipFile
4456
}
4557

4658
}

‎maven_install.json‎

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
{
22
"__AUTOGENERATED_FILE_DO_NOT_MODIFY_THIS_FILE_MANUALLY": "THERE_IS_NO_DATA_ONLY_ZUUL",
33
"__INPUT_ARTIFACTS_HASH": {
4-
"com.github.pathikrit:better-files_3": 2078137804,
54
"com.google.code.findbugs:jsr305": 495355163,
65
"com.google.code.gson:gson": 597770368,
76
"com.google.errorprone:error_prone_annotations": -1035138750,
@@ -23,8 +22,6 @@
2322
"__RESOLVED_ARTIFACTS_HASH": {
2423
"com.github.luben:zstd-jni": 1886873774,
2524
"com.github.luben:zstd-jni:jar:sources": -1190847340,
26-
"com.github.pathikrit:better-files_3": -730147472,
27-
"com.github.pathikrit:better-files_3:jar:sources": -1753499885,
2825
"com.github.scopt:scopt_3": 148843063,
2926
"com.github.scopt:scopt_3:jar:sources": 776003799,
3027
"com.google.code.findbugs:jsr305": 870839855,
@@ -100,13 +97,6 @@
10097
},
10198
"version": "1.5.7-11"
10299
},
103-
"com.github.pathikrit:better-files_3": {
104-
"shasums": {
105-
"jar": "136c1770a63aa33b2710745bf7f8441cbbe0eeef0cab6b832bd0a46804158989",
106-
"sources": "5a3d4cc0c63605353b1c528abfdc180ae4d74b6c50d6693eee4389dcec923e61"
107-
},
108-
"version": "3.9.2"
109-
},
110100
"com.github.scopt:scopt_3": {
111101
"shasums": {
112102
"jar": "7cfb80743b761b3df8630a818265eb91fd93cd77b32ed5ebd6fba1bb7cff6a3f",
@@ -395,9 +385,6 @@
395385
"com.github.luben.zstd",
396386
"com.github.luben.zstd.util"
397387
],
398-
"com.github.pathikrit:better-files_3": [
399-
"better.files"
400-
],
401388
"com.github.scopt:scopt_3": [
402389
"scopt"
403390
],
@@ -773,8 +760,6 @@
773760
"https://repo1.maven.org/maven2/": [
774761
"com.github.luben:zstd-jni",
775762
"com.github.luben:zstd-jni:jar:sources",
776-
"com.github.pathikrit:better-files_3",
777-
"com.github.pathikrit:better-files_3:jar:sources",
778763
"com.github.scopt:scopt_3",
779764
"com.github.scopt:scopt_3:jar:sources",
780765
"com.google.code.findbugs:jsr305",

‎proto-bindings/build.sbt‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ lazy val installProtoc =
2727
installProtoc := {
2828
import sys.process._
2929
import java.nio.file.Files
30-
// import better.files.FileExtensions
3130
val protocVersion = (ProtobufConfig / version).value
3231
val protocBinary = new File(protocBinaryPath)
3332
val isAlreadyInstalled = protocBinary.exists && s"$protocBinaryPath --version".!!.contains(protocVersion)

0 commit comments

Comments
 (0)