Skip to content

Commit

Permalink
Merge pull request #451 from adpi2/fix-7710
Browse files Browse the repository at this point in the history
[1.10.x] Exclude custom extra from pom dependency
  • Loading branch information
adpi2 authored Oct 7, 2024
2 parents 8d71f66 + a4d2b9c commit ee7e17a
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,7 @@ object PomExtraDependencyAttributes {
item.getQualifiedExtraAttributes.asInstanceOf[java.util.Map[String, String]].asScala.toMap
}
def filterCustomExtra(item: ExtendableItem, include: Boolean): Map[String, String] =
(qualifiedExtra(item) filterKeys { k =>
qualifiedIsExtra(k) == include
}).toMap
qualifiedExtra(item).filterKeys { k => qualifiedIsExtra(k) == include }.toMap

def qualifiedIsExtra(k: String): Boolean =
k.endsWith(ScalaVersionKey) || k.endsWith(SbtVersionKey)
Expand All @@ -107,17 +105,27 @@ object PomExtraDependencyAttributes {

/**
* Creates the "extra" property values for DependencyDescriptors that can be written into a maven pom
* so we don't loose the information.
* so we don't lose the information.
* @param s
* @return
*/
def writeDependencyExtra(s: Seq[DependencyDescriptor]): Seq[String] =
s.flatMap { dd =>
val revId = dd.getDependencyRevisionId
if (filterCustomExtra(revId, include = true).isEmpty)
val filteredExtra = filterCustomExtra(revId, include = true)
if (filteredExtra.isEmpty)
Nil
else
revId.encodeToString :: Nil
else {
import scala.collection.JavaConverters._
val revId0 = ModuleRevisionId.newInstance(
revId.getOrganisation,
revId.getName,
revId.getBranch,
revId.getRevision,
filteredExtra.asJava
)
revId0.encodeToString :: Nil
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ package sbt.internal.librarymanagement
import sbt.librarymanagement._
import sbt.librarymanagement.syntax._
import sbt.librarymanagement.ivy.UpdateOptions
import Resolver._

object ModuleResolversTest extends BaseIvySpecification {
override final val resolvers = Vector(
DefaultMavenRepository,
JavaNet2Repository,
JCenterRepository,
MavenRepository(
"JFrog OSS Releases",
"https://releases.jfrog.io/artifactory/oss-releases/"
),
Resolver.sbtPluginRepo("releases")
)

Expand Down

0 comments on commit ee7e17a

Please sign in to comment.