File tree Expand file tree Collapse file tree 3 files changed +24
-5
lines changed
bundle/kamon-runtime-attacher/src/main/scala/kamon/runtime Expand file tree Collapse file tree 3 files changed +24
-5
lines changed Original file line number Diff line number Diff line change @@ -1007,7 +1007,6 @@ lazy val bundle = (project in file("bundle"))
1007
1007
`kamon-runtime-attacher`
1008
1008
)
1009
1009
1010
- import com .lightbend .sbt .javaagent .Modules
1011
1010
import BundleKeys ._
1012
1011
1013
1012
lazy val commonBundleSettings = Seq (
@@ -1045,8 +1044,8 @@ lazy val `kamon-runtime-attacher` = (project in file("bundle/kamon-runtime-attac
1045
1044
moduleName := " kamon-runtime-attacher" ,
1046
1045
buildInfoPackage := " kamon.runtime.attacher" ,
1047
1046
buildInfoKeys := Seq [BuildInfoKey ](kanelaAgentJarName),
1048
- kanelaAgentJar := update.value.matching( Modules .exactFilter(kanelaAgent)).head ,
1049
- kanelaAgentJarName := kanelaAgentJar .value.getName,
1047
+ kanelaAgentJar := BaseProject .findKanelaAgentJar.value ,
1048
+ kanelaAgentJarName := BaseProject .findKanelaAgentJar .value.getName,
1050
1049
Compile / resourceGenerators += Def .task(Seq (kanelaAgentJar.value)).taskValue,
1051
1050
assembly / assemblyShadeRules := Seq (
1052
1051
ShadeRule .zap(" **module-info" ).inAll,
Original file line number Diff line number Diff line change @@ -29,7 +29,9 @@ object Attacher {
29
29
30
30
} else {
31
31
32
- val embeddedAgentFile = Attacher .getClass.getClassLoader.getResourceAsStream(BuildInfo .kanelaAgentJarName)
32
+ val embeddedAgentFile =
33
+ Option (Attacher .getClass.getClassLoader.getResourceAsStream(BuildInfo .kanelaAgentJarName))
34
+ .getOrElse(throw new RuntimeException (s " Couldn't find kanela jar resource ' ${BuildInfo .kanelaAgentJarName}' " ))
33
35
val temporaryAgentFile = Files .createTempFile(BuildInfo .kanelaAgentJarName, " .jar" )
34
36
Files .copy(embeddedAgentFile, temporaryAgentFile, StandardCopyOption .REPLACE_EXISTING )
35
37
Original file line number Diff line number Diff line change @@ -220,10 +220,28 @@ object BaseProject extends AutoPlugin {
220
220
}
221
221
222
222
def findKanelaAgentJar = Def .task {
223
+ val hasSemver = """ .*[0-9]+\.[0-9]+\.[0-9]+.*"""
223
224
update.value.matching {
224
225
moduleFilter(organization = " io.kamon" , name = " kanela-agent" ) &&
225
226
artifactFilter(`type` = " jar" )
226
- }.head
227
+ }.toList match {
228
+ case s @ Nil => throw new NoClassDefFoundError (" No kanela agent jar found" )
229
+ case h +: Nil =>
230
+ if (h.getName.matches(hasSemver)) println(" Single matching kanela-agent jar found" )
231
+ else System .err.println(" kanela-agent jar name did not contain version" )
232
+ h
233
+ case s =>
234
+ System .err.println(s " Multiple matching jars - ${s.map(f => f.getName)}" )
235
+ s.filter(_.getName.matches(hasSemver)) match {
236
+ case Nil =>
237
+ System .err.println(" No jars matching semver " )
238
+ s.head
239
+ case v +: Nil => v
240
+ case more =>
241
+ System .err.println(" Multiple jars matching semver " )
242
+ more.head
243
+ }
244
+ }
227
245
}
228
246
229
247
private def defaultPomExtra () = {
You can’t perform that action at this time.
0 commit comments