Github user brkyvz commented on a diff in the pull request:

    https://github.com/apache/spark/pull/15119#discussion_r95267649
  
    --- Diff: core/src/main/scala/org/apache/spark/deploy/SparkSubmit.scala ---
    @@ -974,23 +967,102 @@ private[spark] object SparkSubmitUtils {
         }
       }
     
    +  /**
    +   * Build Ivy Settings using options with default resolvers
    +   * @param remoteRepos Comma-delimited string of remote repositories 
other than maven central
    +   * @param ivyPath The path to the local ivy repository
    +   * @return An IvySettings object
    +   */
    +  def buildIvySettings(remoteRepos: Option[String], ivyPath: 
Option[String]): IvySettings = {
    +    val ivySettings: IvySettings = new IvySettings
    +    processIvyPathArg(ivySettings, ivyPath)
    +
    +    // create a pattern matcher
    +    ivySettings.addMatcher(new GlobPatternMatcher)
    +    // create the dependency resolvers
    +    val repoResolver = 
createRepoResolvers(ivySettings.getDefaultIvyUserDir)
    +    ivySettings.addResolver(repoResolver)
    +    ivySettings.setDefaultResolver(repoResolver.getName)
    +    processRemoteRepoArg(ivySettings, remoteRepos)
    +    ivySettings
    +  }
    +
    +  /**
    +   * Load Ivy settings from a given filename, using supplied resolvers
    +   * @param settingsFile Path to Ivy settings file
    +   * @param remoteRepos Comma-delimited string of remote repositories 
other than maven central
    +   * @param ivyPath The path to the local ivy repository
    +   * @return An IvySettings object
    +   */
    +  def loadIvySettings(
    +      settingsFile: String,
    +      remoteRepos: Option[String],
    +      ivyPath: Option[String]): IvySettings = {
    +    val file = new File(settingsFile)
    +    require(file.exists(), s"Ivy settings file $file does not exist")
    +    require(file.isFile(), s"Ivy settings file $file is not a normal file")
    +    val ivySettings: IvySettings = new IvySettings
    +    try {
    +      ivySettings.load(file)
    +    } catch {
    +      case e @ (_: IOException | _: ParseException) =>
    +        throw new SparkException(s"Failed when loading Ivy settings from 
$settingsFile", e)
    +    }
    +    processIvyPathArg(ivySettings, ivyPath)
    +    processRemoteRepoArg(ivySettings, remoteRepos)
    +    ivySettings
    +  }
    +
    +  /* Set ivy settings for location of cache, if option is supplied */
    +  private def processIvyPathArg(ivySettings: IvySettings, ivyPath: 
Option[String]): Unit = {
    +    ivyPath.filterNot(_.trim.isEmpty).foreach { alternateIvyDir =>
    +      ivySettings.setDefaultIvyUserDir(new File(alternateIvyDir))
    +      ivySettings.setDefaultCache(new File(alternateIvyDir, "cache"))
    +    }
    +  }
    +
    +  /* Add any optional additional remote repositories */
    +  private def processRemoteRepoArg(ivySettings: IvySettings, remoteRepos: 
Option[String]): Unit = {
    +    remoteRepos.filterNot(_.trim.isEmpty).map(_.split(",")).foreach { 
repositoryList =>
    +      val cr = new ChainResolver
    +      cr.setName("user-list")
    +
    +      // add current default resolver, if any
    +      Option(ivySettings.getDefaultResolver).foreach(cr.add)
    +
    +      // add additional repositories, last resolution in chain takes 
precedence
    +      repositoryList.zipWithIndex.foreach { case (repo, i) =>
    +        val brr: IBiblioResolver = new IBiblioResolver
    +        brr.setM2compatible(true)
    +        brr.setUsepoms(true)
    +        brr.setRoot(repo)
    +        brr.setName(s"repo-${i + 1}")
    +        cr.add(brr)
    +        // scalastyle:off println
    +        printStream.println(s"$repo added as a remote repository with the 
name: ${brr.getName}")
    --- End diff --
    
    That's used in testing IIRC and is helpful in debugging


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to