@@ -143,10 +143,25 @@ object OSGi {
143143 " !scala.util.parsing.*" ,
144144 scalaImport(scalaVersion))
145145 def pekkoImport (version : String , packageName : String = " org.apache.pekko.*" ) = {
146+ // see https://github.com/apache/pekko/issues/2509 for background
147+ // on why the version that is input might not be in the expected format
146148 val versionComponents = version.split('.' )
147- val nextMinorVersion = versionComponents(1 ).toInt + 1
148- versionedImport(packageName, s " ${versionComponents.head}. ${versionComponents(1 )}" ,
149- s " ${versionComponents.head}. $nextMinorVersion" )
149+ if (versionComponents.length < 2 ) {
150+ useDefaultImportRange(version, packageName)
151+ } else {
152+ try {
153+ val nextMinorVersion = versionComponents(1 ).toInt + 1
154+ versionedImport(packageName, s " ${versionComponents.head}. ${versionComponents(1 )}" ,
155+ s " ${versionComponents.head}. $nextMinorVersion" )
156+ } catch {
157+ case _ : NumberFormatException =>
158+ useDefaultImportRange(version, packageName)
159+ }
160+ }
161+ }
162+ private def useDefaultImportRange (version : String , packageName : String ) = {
163+ System .err.println(s " Invalid Pekko version: $version for OSGi import package versioning, defaulting to [0.0,10.0) " )
164+ versionedImport(packageName, " 0.0" , " 10.0" )
150165 }
151166 def configImport (packageName : String = " com.typesafe.config.*" ) = versionedImport(packageName, " 1.4.0" , " 1.5.0" )
152167 def scalaImport (version : String ) = {
0 commit comments