@@ -734,13 +734,31 @@ private[deploy] object SparkSubmitUtils {
734
734
/**
735
735
* Extracts maven coordinates from a comma-delimited string
736
736
* @param remoteRepos Comma-delimited string of remote repositories
737
+ * @param ivySettings The Ivy settings for this session
737
738
* @return A ChainResolver used by Ivy to search for and resolve dependencies.
738
739
*/
739
- def createRepoResolvers (remoteRepos : Option [String ]): ChainResolver = {
740
+ def createRepoResolvers (remoteRepos : Option [String ], ivySettings : IvySettings ): ChainResolver = {
740
741
// We need a chain resolver if we want to check multiple repositories
741
742
val cr = new ChainResolver
742
743
cr.setName(" list" )
743
744
745
+ val localM2 = new IBiblioResolver
746
+ localM2.setM2compatible(true )
747
+ val m2Path = " .m2" + File .separator + " repository" + File .separator
748
+ localM2.setRoot(new File (System .getProperty(" user.home" ), m2Path).toURI.toString)
749
+ localM2.setUsepoms(true )
750
+ localM2.setName(" local-m2-cache" )
751
+ cr.add(localM2)
752
+
753
+ val localIvy = new IBiblioResolver
754
+ localIvy.setRoot(new File (ivySettings.getDefaultIvyUserDir,
755
+ " local" + File .separator).toURI.toString)
756
+ val ivyPattern = Seq (" [organisation]" , " [module]" , " [revision]" , " [type]s" ,
757
+ " [artifact](-[classifier]).[ext]" ).mkString(File .separator)
758
+ localIvy.setPattern(ivyPattern)
759
+ localIvy.setName(" local-ivy-cache" )
760
+ cr.add(localIvy)
761
+
744
762
// the biblio resolver resolves POM declared dependencies
745
763
val br : IBiblioResolver = new IBiblioResolver
746
764
br.setM2compatible(true )
@@ -773,8 +791,7 @@ private[deploy] object SparkSubmitUtils {
773
791
774
792
/**
775
793
* Output a comma-delimited list of paths for the downloaded jars to be added to the classpath
776
- * (will append to jars in SparkSubmit). The name of the jar is given
777
- * after a '!' by Ivy. It also sometimes contains '(bundle)' after '.jar'. Remove that as well.
794
+ * (will append to jars in SparkSubmit).
778
795
* @param artifacts Sequence of dependencies that were resolved and retrieved
779
796
* @param cacheDirectory directory where jars are cached
780
797
* @return a comma-delimited list of paths for the dependencies
@@ -783,10 +800,9 @@ private[deploy] object SparkSubmitUtils {
783
800
artifacts : Array [AnyRef ],
784
801
cacheDirectory : File ): String = {
785
802
artifacts.map { artifactInfo =>
786
- val artifactString = artifactInfo.toString
787
- val jarName = artifactString.drop(artifactString.lastIndexOf(" !" ) + 1 )
803
+ val artifact = artifactInfo.asInstanceOf [Artifact ].getModuleRevisionId
788
804
cacheDirectory.getAbsolutePath + File .separator +
789
- jarName.substring( 0 , jarName.lastIndexOf( " . jar" ) + 4 )
805
+ s " ${artifact.getOrganisation} _ ${artifact.getName} - ${artifact.getRevision} . jar"
790
806
}.mkString(" ," )
791
807
}
792
808
@@ -868,6 +884,7 @@ private[deploy] object SparkSubmitUtils {
868
884
if (alternateIvyCache.trim.isEmpty) {
869
885
new File (ivySettings.getDefaultIvyUserDir, " jars" )
870
886
} else {
887
+ ivySettings.setDefaultIvyUserDir(new File (alternateIvyCache))
871
888
ivySettings.setDefaultCache(new File (alternateIvyCache, " cache" ))
872
889
new File (alternateIvyCache, " jars" )
873
890
}
@@ -877,7 +894,7 @@ private[deploy] object SparkSubmitUtils {
877
894
// create a pattern matcher
878
895
ivySettings.addMatcher(new GlobPatternMatcher )
879
896
// create the dependency resolvers
880
- val repoResolver = createRepoResolvers(remoteRepos)
897
+ val repoResolver = createRepoResolvers(remoteRepos, ivySettings )
881
898
ivySettings.addResolver(repoResolver)
882
899
ivySettings.setDefaultResolver(repoResolver.getName)
883
900
@@ -911,7 +928,8 @@ private[deploy] object SparkSubmitUtils {
911
928
}
912
929
// retrieve all resolved dependencies
913
930
ivy.retrieve(rr.getModuleDescriptor.getModuleRevisionId,
914
- packagesDirectory.getAbsolutePath + File .separator + " [artifact](-[classifier]).[ext]" ,
931
+ packagesDirectory.getAbsolutePath + File .separator +
932
+ " [organization]_[artifact]-[revision].[ext]" ,
915
933
retrieveOptions.setConfs(Array (ivyConfName)))
916
934
System .setOut(sysOut)
917
935
resolveDependencyPaths(rr.getArtifacts.toArray, packagesDirectory)
0 commit comments