8000 Address review comments · sourcegraph/scip-java@e313c2e · GitHub
[go: up one dir, main page]

Skip to content

Commit e313c2e

Browse files
committed
Address review comments
1 parent d560d3d commit e313c2e

File tree

2 files changed

+40
-32
lines changed

2 files changed

+40
-32
lines changed

scip-java/src/main/scala/com/sourcegraph/scip_java/buildtools/ClasspathEntry.scala

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,9 @@ import scala.jdk.CollectionConverters._
1212
import com.sourcegraph.scip_semanticdb.MavenPackage
1313

1414
/**
15-
* Represents a single jar file on the classpath of a project, used to emit SCIP
16-
* "packageInformation" nodes.
15+
* Represents a single classpath entry on the classpath of a project, used to
16+
* emit SCIP "packageInformation" nodes. A classpath entry can either be a jar
17+
* file or a directory path.
1718
*/
1819
case class ClasspathEntry(
1920
entry: Path,

semanticdb-gradle-plugin/src/main/scala/SemanticdbGradlePlugin.scala

Lines changed: 37 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import java.nio.file.Paths
55
import java.{util => ju}
66

77
import scala.jdk.CollectionConverters._
8-
import scala.util.Try
8+
import scala.util.control.NonFatal
99

1010
import com.sourcegraph.scip_java.BuildInfo
1111
import org.gradle.api.DefaultTask
@@ -405,35 +405,42 @@ class WriteDependencies extends DefaultTask {
405405
// List the project itself as a dependency so that we can assign project name/version to symbols that are defined in this project.
406406
// The code below is roughly equivalent to the following with Groovy:
407407
// deps += "$publication.groupId $publication.artifactId $publication.version $sourceSets.main.output.classesDirectory"
408-
Try(
409-
project
410-
.getExtensions()
411-
.getByType(classOf[SourceSetContainer])
412-
.getByName("main")
413-
.getOutput()
414-
.getClassesDirs()
415-
.getFiles()
416-
.asScala
417-
.toList
418-
.map(_.getAbsolutePath())
419-
.sorted
420-
.headOption
421-
).collect { case Some(classesDirectory) =>
422-
project
423-
.getExtensions()
424-
.findByType(classOf[PublishingExtension])
425-
.getPublications()
426-
.withType(classOf[MavenPublication])
427-
.asScala
428-
.foreach { publication =>
429-
deps +=
430-
List(
431-
publication.getGroupId(),
432-
publication.getArtifactId(),
433-
publication.getVersion(),
434-
classesDirectory
435-
).mkString("\t")
436-
}
408+
try {
409+
for {
410+
classesDirectory <- project
411+
.getExtensions()
412+
.getByType(classOf[SourceSetContainer])
413+
.getByName("main")
414+
.getOutput()
415+
.getClassesDirs()
416+
.getFiles()
417+
.asScala
418+
.toList
419+
.map(_.getAbsolutePath())
420+
.sorted
421+
.take(1)
422+
publication <-
423+
project
424+
.getExtensions()
425+
.findByType(classOf[PublishingExtension])
426+
.getPublications()
427+
.withType(classOf[MavenPublication])
428+
.asScala
429+
} {
430+
deps +=
431+
List(
432+
publication.getGroupId(),
433+
publication.getArtifactId(),
434+
publication.getVersion(),
435+
classesDirectory
436+
).mkString("\t")
437+
}
438+
} catch {
439+
case NonFatal(ex) =>
440+
println(
441+
s"Failed to extract publication from project ${project.getName()}"
442+
)
443+
ex.printStackTrace()
437444
}
438445

439446
project

0 commit comments

Comments
 (0)
0