Skip to content

Commit 56d3e2a

Browse files
authored
Remove use of gradle api (#88)
Signed-off-by: Prabhu Subramanian <prabhu@appthreat.com>
1 parent fcd860e commit 56d3e2a

File tree

11 files changed

+11
-381
lines changed

11 files changed

+11
-381
lines changed

.github/workflows/pr.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ jobs:
66
strategy:
77
matrix:
88
os: [ubuntu-latest, windows-latest, macos-latest]
9-
jvm: ['21', '22']
9+
jvm: ['21', '22', '23']
1010
steps:
1111
- uses: actions/checkout@v4
1212
with:

.github/workflows/win_compat.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ jobs:
88
runs-on: windows-latest
99
strategy:
1010
matrix:
11-
python-version: ['3.8','3.9','3.10','3.11','3.12']
11+
python-version: ['3.10','3.11','3.12']
1212
with-science: ["--download", "--download --with-science"]
1313
fail-fast: false
1414

build.sbt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name := "chen"
22
ThisBuild / organization := "io.appthreat"
3-
ThisBuild / version := "2.1.6"
3+
ThisBuild / version := "2.1.7"
44
ThisBuild / scalaVersion := "3.5.0"
55

66
val cpgVersion = "1.0.0"

codemeta.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"downloadUrl": "https://github.com/AppThreat/chen",
88
"issueTracker": "https://github.com/AppThreat/chen/issues",
99
"name": "chen",
10-
"version": "2.1.6",
10+
"version": "2.1.7",
1111
"description": "Code Hierarchy Exploration Net (chen) is an advanced exploration toolkit for your application source code and its dependency hierarchy.",
1212
"applicationCategory": "code-analysis",
1313
"keywords": [

meta.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{% set version = "2.1.6" %}
1+
{% set version = "2.1.7" %}
22

33
package:
44
name: chen

platform/frontends/javasrc2cpg/build.sbt

-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ dependsOn(Projects.dataflowengineoss, Projects.x2cpg % "compile->compile;test->t
55
libraryDependencies ++= Seq(
66
"io.appthreat" %% "cpg2" % Versions.cpg,
77
"com.github.javaparser" % "javaparser-symbol-solver-core" % "3.26.2",
8-
"org.gradle" % "gradle-tooling-api" % Versions.gradleTooling,
98
"org.scalatest" %% "scalatest" % Versions.scalatest % Test,
109
"org.projectlombok" % "lombok" % "1.18.34",
1110
"org.scala-lang.modules" %% "scala-parallel-collections" % "1.0.4",

platform/frontends/jssrc2cpg/src/test/scala/io/appthreat/jssrc2cpg/types/TSTypesTest.scala

+2-2
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ class TSTypesTest extends AbstractPassTest {
4646
args.name shouldBe "args"
4747
args.code shouldBe "...args"
4848
args.isVariadic shouldBe true
49-
args.typeFullName shouldBe Defines.Any
49+
args.typeFullName shouldBe "Array<any>"
5050
}
5151

5252
"have return types for arrow functions" in AstFixture("const foo = () => 42;", tsTypes = true) { cpg =>
@@ -138,7 +138,7 @@ class TSTypesTest extends AbstractPassTest {
138138
inside(cpg.identifier.l) { case List(x) =>
139139
x.name shouldBe "x"
140140
x.code shouldBe "x"
141-
x.typeFullName shouldBe Defines.String // we can actually follow type intrinsics
141+
x.typeFullName shouldBe "ModifiedNickName"
142142
}
143143
}
144144

platform/frontends/x2cpg/build.sbt

-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ libraryDependencies ++= Seq(
66
"io.circe" %% "circe-core" % Versions.circe,
77
"io.circe" %% "circe-generic" % Versions.circe,
88
"io.circe" %% "circe-parser" % Versions.circe,
9-
"org.gradle" % "gradle-tooling-api" % Versions.gradleTooling % Optional,
109
"org.scalatest" %% "scalatest" % Versions.scalatest % Test
1110
)
1211

platform/frontends/x2cpg/src/main/scala/io/appthreat/x2cpg/utils/dependency/DependencyResolver.scala

+3-37
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package io.appthreat.x2cpg.utils.dependency
33
import better.files.File
44
import io.appthreat.x2cpg.utils.ExternalCommand
55
import io.appthreat.x2cpg.utils.dependency.GradleConfigKeys.GradleConfigKey
6-
import org.slf4j.LoggerFactory
76

87
import java.nio.file.Path
98
import scala.util.{Failure, Success}
@@ -17,10 +16,7 @@ case class DependencyResolverParams(
1716
)
1817

1918
object DependencyResolver:
20-
private val logger = LoggerFactory.getLogger(getClass)
21-
private val defaultGradleProjectName = "app"
22-
private val defaultGradleConfigurationName = "compileClasspath"
23-
private val MaxSearchDepth: Int = 4
19+
private val MaxSearchDepth: Int = 4
2420

2521
def getCoordinates(
2622
projectDir: Path,
@@ -31,9 +27,8 @@ object DependencyResolver:
3127
// TODO: implement
3228
None
3329
else if isGradleBuildFile(buildFile) then
34-
getCoordinatesForGradleProject(buildFile.getParent, defaultGradleConfigurationName)
30+
Nil
3531
else
36-
logger.debug(s"Found unsupported build file $buildFile")
3732
Nil
3833
}.flatten
3934

@@ -49,16 +44,10 @@ object DependencyResolver:
4944
) match
5045
case Success(lines) => lines
5146
case Failure(exception) =>
52-
logger.debug(
53-
s"Could not retrieve dependencies for Gradle project at path `$projectDir`\n" +
54-
exception.getMessage
55-
)
5647
Seq()
5748

5849
val coordinates = MavenCoordinates.fromGradleOutput(lines)
59-
logger.debug("Got {} Maven coordinates", coordinates.size)
6050
Some(coordinates)
61-
end getCoordinatesForGradleProject
6251

6352
def getDependencies(
6453
projectDir: Path,
@@ -68,35 +57,13 @@ object DependencyResolver:
6857
if isMavenBuildFile(buildFile) then
6958
MavenDependencies.get(buildFile.getParent)
7059
else if isGradleBuildFile(buildFile) then
71-
getDepsForGradleProject(params, buildFile.getParent)
60+
Nil
7261
else
73-
logger.debug(s"Found unsupported build file $buildFile")
7462
Nil
7563
}.flatten
7664

7765
Option.when(dependencies.nonEmpty)(dependencies)
7866

79-
private def getDepsForGradleProject(
80-
params: DependencyResolverParams,
81-
projectDir: Path
82-
): Option[collection.Seq[String]] =
83-
logger.debug("resolving Gradle dependencies at {}", projectDir)
84-
val gradleProjectName =
85-
params.forGradle.getOrElse(GradleConfigKeys.ProjectName, defaultGradleProjectName)
86-
val gradleConfiguration =
87-
params.forGradle.getOrElse(
88-
GradleConfigKeys.ConfigurationName,
89-
defaultGradleConfigurationName
90-
)
91-
GradleDependencies.get(projectDir, gradleProjectName, gradleConfiguration) match
92-
case Some(deps) => Some(deps)
93-
case None =>
94-
logger.debug(
95-
s"Could not download Gradle dependencies for project at path `$projectDir`"
96-
)
97-
None
98-
end getDepsForGradleProject
99-
10067
private def isGradleBuildFile(file: File): Boolean =
10168
val pathString = file.pathAsString
10269
pathString.endsWith(".gradle") || pathString.endsWith(".gradle.kts")
@@ -106,7 +73,6 @@ object DependencyResolver:
10673

10774
private def findSupportedBuildFiles(currentDir: File, depth: Int = 0): List[Path] =
10875
if depth >= MaxSearchDepth then
109-
logger.debug("findSupportedBuildFiles reached max depth before finding build files")
11076
Nil
11177
else
11278
val (childDirectories, childFiles) = currentDir.children.partition(_.isDirectory)

0 commit comments

Comments
 (0)