-
Notifications
You must be signed in to change notification settings - Fork 28.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[SPARK-7205] Support .ivy2/local
and .m2/repositories/
in --packages
#5755
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -722,13 +722,31 @@ private[deploy] object SparkSubmitUtils { | |
/** | ||
* Extracts maven coordinates from a comma-delimited string | ||
* @param remoteRepos Comma-delimited string of remote repositories | ||
* @param ivySettings The Ivy settings for this session | ||
* @return A ChainResolver used by Ivy to search for and resolve dependencies. | ||
*/ | ||
def createRepoResolvers(remoteRepos: Option[String]): ChainResolver = { | ||
def createRepoResolvers(remoteRepos: Option[String], ivySettings: IvySettings): ChainResolver = { | ||
// We need a chain resolver if we want to check multiple repositories | ||
val cr = new ChainResolver | ||
cr.setName("list") | ||
|
||
val localM2 = new IBiblioResolver | ||
localM2.setM2compatible(true) | ||
val m2Path = ".m2" + File.separator + "repository" + File.separator | ||
localM2.setRoot(new File(System.getProperty("user.home"), m2Path).toURI.toString) | ||
localM2.setUsepoms(true) | ||
localM2.setName("local-m2-cache") | ||
cr.add(localM2) | ||
|
||
val localIvy = new IBiblioResolver | ||
localIvy.setRoot(new File(ivySettings.getDefaultIvyUserDir, | ||
"local" + File.separator).toURI.toString) | ||
val ivyPattern = Seq("[organisation]", "[module]", "[revision]", "[type]s", | ||
"[artifact](-[classifier]).[ext]").mkString(File.separator) | ||
localIvy.setPattern(ivyPattern) | ||
localIvy.setName("local-ivy-cache") | ||
cr.add(localIvy) | ||
|
||
// the biblio resolver resolves POM declared dependencies | ||
val br: IBiblioResolver = new IBiblioResolver | ||
br.setM2compatible(true) | ||
|
@@ -761,8 +779,7 @@ private[deploy] object SparkSubmitUtils { | |
|
||
/** | ||
* Output a comma-delimited list of paths for the downloaded jars to be added to the classpath | ||
* (will append to jars in SparkSubmit). The name of the jar is given | ||
* after a '!' by Ivy. It also sometimes contains '(bundle)' after '.jar'. Remove that as well. | ||
* (will append to jars in SparkSubmit). | ||
* @param artifacts Sequence of dependencies that were resolved and retrieved | ||
* @param cacheDirectory directory where jars are cached | ||
* @return a comma-delimited list of paths for the dependencies | ||
|
@@ -771,10 +788,9 @@ private[deploy] object SparkSubmitUtils { | |
artifacts: Array[AnyRef], | ||
cacheDirectory: File): String = { | ||
artifacts.map { artifactInfo => | ||
val artifactString = artifactInfo.toString | ||
val jarName = artifactString.drop(artifactString.lastIndexOf("!") + 1) | ||
val artifact = artifactInfo.asInstanceOf[Artifact].getModuleRevisionId | ||
cacheDirectory.getAbsolutePath + File.separator + | ||
jarName.substring(0, jarName.lastIndexOf(".jar") + 4) | ||
s"${artifact.getOrganisation}_${artifact.getName}-${artifact.getRevision}.jar" | ||
}.mkString(",") | ||
} | ||
|
||
|
@@ -856,6 +872,7 @@ private[deploy] object SparkSubmitUtils { | |
if (alternateIvyCache.trim.isEmpty) { | ||
new File(ivySettings.getDefaultIvyUserDir, "jars") | ||
} else { | ||
ivySettings.setDefaultIvyUserDir(new File(alternateIvyCache)) | ||
ivySettings.setDefaultCache(new File(alternateIvyCache, "cache")) | ||
new File(alternateIvyCache, "jars") | ||
} | ||
|
@@ -865,7 +882,7 @@ private[deploy] object SparkSubmitUtils { | |
// create a pattern matcher | ||
ivySettings.addMatcher(new GlobPatternMatcher) | ||
// create the dependency resolvers | ||
val repoResolver = createRepoResolvers(remoteRepos) | ||
val repoResolver = createRepoResolvers(remoteRepos, ivySettings) | ||
ivySettings.addResolver(repoResolver) | ||
ivySettings.setDefaultResolver(repoResolver.getName) | ||
|
||
|
@@ -899,7 +916,8 @@ private[deploy] object SparkSubmitUtils { | |
} | ||
// retrieve all resolved dependencies | ||
ivy.retrieve(rr.getModuleDescriptor.getModuleRevisionId, | ||
packagesDirectory.getAbsolutePath + File.separator + "[artifact](-[classifier]).[ext]", | ||
packagesDirectory.getAbsolutePath + File.separator + | ||
"[organization]_[artifact]-[revision].[ext]", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What is the reason we got rid of I saw some discussions about this. For example,
|
||
retrieveOptions.setConfs(Array(ivyConfName))) | ||
System.setOut(sysOut) | ||
resolveDependencyPaths(rr.getArtifacts.toArray, packagesDirectory) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you sure that you can point ivy to a maven repository like this? Ivy and maven use different format for laying out directory structures (does setUsepoms just make this work?). I'd make sure you explicitly test this locally with the .m2 folder.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah I guess that comes with
setM2compatible
.