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

    https://github.com/apache/spark/pull/15119#discussion_r95272071
  
    --- 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 --
    
    It was in there before and I think it's nice to get confirmation that your 
additional was added with that alias, in case the artifact you need isn't 
resolved.  It will print out all the info like this
    ```
    bin/run-example --repositories www.somerepo.com --packages some:package:1.0 
SparkPi
    Listening for transport dt_socket at address: 5005
    www.somerepo.com added as a remote repository with the name: repo-1
    Ivy Default Cache set to: /home/bryan/.ivy2/cache
    The jars for the packages stored in: /home/bryan/.ivy2/jars
    :: loading settings :: url = 
jar:file:/home/bryan/git/spark/assembly/target/scala-2.11/jars/ivy-2.4.0.jar!/org/apache/ivy/core/settings/ivysettings.xml
    some#package added as a dependency
    :: resolving dependencies :: org.apache.spark#spark-submit-parent;1.0
        confs: [default]
    :: resolution report :: resolve 1540ms :: artifacts dl 0ms
        :: modules in use:
        ---------------------------------------------------------------------
        |                  |            modules            ||   artifacts   |
        |       conf       | number| search|dwnlded|evicted|| number|dwnlded|
        ---------------------------------------------------------------------
        |      default     |   1   |   0   |   0   |   0   ||   0   |   0   |
        ---------------------------------------------------------------------
    
    :: problems summary ::
    :::: WARNINGS
                ::::::::::::::::::::::::::::::::::::::::::::::
    
                ::          UNRESOLVED DEPENDENCIES         ::
    
                ::::::::::::::::::::::::::::::::::::::::::::::
    
                :: some#package;1.0: repo-1: unable to get resource for 
some#package;1.0: res=www.somerepo.com/some/package/1.0/package-1.0.pom: 
java.net.MalformedURLException: no protocol: 
www.somerepo.com/some/package/1.0/package-1.0.pom
    
                ::::::::::::::::::::::::::::::::::::::::::::::
    ```


---
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 [email protected] or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to