8000 Update dependencies and improve build tool testing infrastructure, add JDK 21 by keynmol · Pull Request #692 · sourcegraph/scip-java · GitHub
[go: up one dir, main page]

Skip to content

Update dependencies and improve build tool testing infrastructure, add JDK 21 #692

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 12 commits into from
Apr 18, 2024
Prev Previous commit
Next Next commit
Support Gradle 2
  • Loading branch information
keynmol committed Apr 18, 2024
commit 25e9d4b22bf4857cb5c87378aee899dcf5eb844c
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ import org.gradle.api.tasks.SourceSetContainer
import org.gradle.api.tasks.TaskAction
import org.gradle.api.tasks.compile.JavaCompile
import org.gradle.api.tasks.scala.ScalaCompile
import org.gradle.api.artifacts.Configuration
import org.gradle.api.artifacts.dsl.DependencyHandler

class SemanticdbGradlePlugin extends Plugin[Project] {
import Logging._
Expand Down Expand Up @@ -78,23 +80,24 @@ class SemanticdbGradlePlugin extends Plugin[Project] {

val compilerPluginAdded =
try {
project.getDependencies().add("compileOnly", javacPluginDep)
project.getDependencies().add("compileOnly", javacPluginDep)

if (hasAnnotationPath) {
project
.getDependencies()
.add("annotationProcessor", javacPluginDep)
}
if (hasAnnotationPath) {
project
.getDependencies()
.add("annotationProcessor", javacPluginDep)
}

project.getDependencies().add("testCompileOnly", javacPluginDep)
project.getDependencies().add("testCompileOnly", javacPluginDep)

true
true
} catch {
case exc: Exception =>
// If the `compileOnly` configuration has already been evaluated
// by the build, we need to fallback on agent injected into javac
warn(
s"Failed to add compiler plugin to javac, will go through the agent route: ${exc.getMessage()}"
s"Failed to add compiler plugin to javac, will go through the agent route (${exc
.getClass()}): ${exc.getMessage()}"
)
false
}
Expand All @@ -119,6 +122,7 @@ class SemanticdbGradlePlugin extends Plugin[Project] {
}
def getMetadata(): Metadata
}

type HasCompilerProperty = {
def getJavaCompiler(): Property[JavaCompiler]
}
Expand Down Expand Up @@ -454,7 +458,7 @@ class WriteDependencies extends DefaultTask {
warn(s"""
|Failed to extract Maven publication from the project `$projectName`.
$crossRepoBanner
|Here's the raw error message:
|Here's the raw error message (${exception.getClass()}):
| "${exception.getMessage()}"
|Continuing without cross-repository support.
""".stripMargin.trim())
Expand Down Expand Up @@ -506,10 +510,16 @@ class WriteDependencies extends DefaultTask {
}
}

def canBeResolved(conf: Configuration) =
if (gradle.is2)
!conf.isEmpty()
else
conf.isCanBeResolved()

project
.getConfigurations()
.forEach { conf =>
if (conf.isCanBeResolved()) {
if (canBeResolved(conf)) {
try {
val resolved = conf.getResolvedConfiguration()
resolved
Expand Down
2 changes: 1 addition & 1 deletion tests/buildTools/src/test/scala/tests/Tool.scala
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ object Tool {
case object Gradle6 extends Gradle("6.8.3", atMostJava(11))
case object Gradle5 extends Gradle("5.6.4", atMostJava(11))
case object Gradle3 extends Gradle("3.3", atMostJava(8))
case object Gradle2 extends Gradle("2.2.1", atMostJava(8))
case object Gradle2 extends Gradle("2.14.1", atMostJava(8))

sealed abstract class SBT(version: String, support: JVMSupport)
extends Tool("sbt", version, support)
Expand Down
0