Skip to content

Commit

Permalink
SDKJAVA-271 SBT stuck at Resolving NormalizedArtifact for long time (#29
Browse files Browse the repository at this point in the history
)

Signed-off-by: Oleksandr Vyshniak <[email protected]>
  • Loading branch information
molekyla authored Nov 11, 2024
1 parent 67e977e commit fad5060
Show file tree
Hide file tree
Showing 6 changed files with 94 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ class IvyPomLocator(resolver: DependencyResolutionProxy, ivyHome: File, logger:
val dummyDir = new File("target/boms")
logger.info(s"Resolving ${moduleId}")
resolver.retrieve(
resolver.wrapDependencyInModule(moduleId.asModule()),
resolver.wrapDependencyInModule(moduleId.asModule().intransitive()),
dummyDir,
logger
) match {
Expand Down
51 changes: 51 additions & 0 deletions plugin/src/sbt-test/psv/test_downloaded_deps/build.sbt
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import com.here.bom.Bom
import scala.sys.process.Process

lazy val scalaCompilerOptions = Seq(
"-deprecation",
"-encoding",
"UTF-8",
"-feature",
"-language:existentials",
"-language:higherKinds",
"-language:implicitConversions",
"-unchecked",
"-Xfatal-warnings",
"-Xlint",
"-Ywarn-dead-code",
"-Ywarn-numeric-widen",
"-Ywarn-value-discard",
)

lazy val akkaBom = Bom("com.lightbend.akka" %% "akka-dependencies" % "23.05.4")
def akkaDependencies(bom: Bom) = {
Seq(
"com.lightbend.akka.grpc" %% "akka-grpc-runtime" % bom
)
}

lazy val `test-downloaded-deps` = project
.in(file("."))
.settings(akkaBom)
.settings(
name := "test-downloaded-deps",
scalaVersion := "2.13.2",
resolvers := Resolver.DefaultMavenRepository +: resolvers.value,
libraryDependencies ++= akkaDependencies(akkaBom.key.value),
dependencyOverrides ++= akkaBom.key.value.bomDependencies,
TaskKey[Unit]("akkaDepsDescriptorExist") := {
val akkaDepsPath =f"${System.getProperty("java.io.tmpdir")}/test-sbt-bom-cache/cache/com.lightbend.akka/akka-dependencies_2.13/ivy-23.05.4.xml"
if (!new File(akkaDepsPath).exists()) {
sys.error(f"Akka deps file is not exists: $akkaDepsPath")
}
},
TaskKey[Unit]("akkaGrpcRuntimeDescriptorNotExist") := {
val akkaDepsPath =f"${System.getProperty("java.io.tmpdir")}/test-sbt-bom-cache/cache/com.lightbend.akka.grpc/akka-grpc-runtime_2.13"
if (new File(akkaDepsPath).exists()) {
sys.error(f"GRPC core exits: $akkaDepsPath")
}
}
)

ThisBuild / scalacOptions ++= scalaCompilerOptions
Global / onChangedBuildSource := ReloadOnSourceChanges
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
sbt.version=1.6.1
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
addSbtPlugin("com.here.platform.artifact" % "sbt-resolver" % "2.0.24")

sys.props.get("plugin.version") match {
case Some(x) => addSbtPlugin("com.here.platform" % "sbt-bom" % x)
case _ => sys.error("""|The system property 'plugin.version' is not defined.
|Specify this property using the scriptedLaunchOpts -D.""".stripMargin)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
* Copyright (C) 2019-2024 HERE Europe B.V.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* SPDX-License-Identifier: Apache-2.0
* License-Filename: LICENSE
*/
package com.here.bom

object TestApp extends App {
// test that transient dependency of com.lightbend.akka.grpc:akka-grpc-runtime is available
println("io.grpc.internal.GrpcUtil.TIMEOUT value is " + io.grpc.internal.GrpcUtil.TIMEOUT)
}
10 changes: 10 additions & 0 deletions plugin/src/sbt-test/psv/test_downloaded_deps/test
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
> set scriptedBufferLog := false
> eval System.setProperty("sbt.ivy.home", System.getProperty("java.io.tmpdir")+"/test-sbt-bom-cache")
> eval System.setProperty("ivy.home", System.getProperty("java.io.tmpdir")+"/test-sbt-bom-cache")
> set ivyPaths := IvyPaths.apply(file(System.getProperty("java.io.tmpdir")+"/test-sbt-bom-cache"), file(System.getProperty("java.io.tmpdir")+"/test-sbt-bom-cache"))
> reload
> package
# check that declared dependency descriptor downloaded and stored in the ivy cache dir
> akkaDepsDescriptorExist
# check that transient dependency (io.grpc:grpc-core) descriptor is not downloaded during resolution
> akkaGrpcRuntimeDescriptorNotExist

0 comments on commit fad5060

Please sign in to comment.