xkrogen commented on a change in pull request #31741:
URL: https://github.com/apache/spark/pull/31741#discussion_r587931199



##########
File path: 
core/src/test/scala/org/apache/spark/deploy/SparkSubmitUtilsSuite.scala
##########
@@ -277,4 +279,35 @@ class SparkSubmitUtilsSuite extends SparkFunSuite with 
BeforeAndAfterAll {
         .exists(r.findFirstIn(_).isDefined), "resolution files should be 
cleaned")
     }
   }
+
+  test("SPARK-34624: should ignore non-jar dependencies") {
+    val main = MavenCoordinate("my.great.lib", "mylib", "0.1")
+    val dep = "my.great.dep:mydep:0.5"
+
+    IvyTestUtils.withRepository(main, Some(dep), None) { repo =>
+      // IvyTestUtils.withRepository does not have an easy way for creating 
non-jar dependencies
+      // So we let it create the jar dependency in `mylib-0.1.pom`, and then 
modify the pom
+      // to change the type of the transitive to `pom`
+      val mainPom = new 
File(URI.create(repo).resolve("my/great/lib/mylib/0.1/mylib-0.1.pom"))
+      val source = Source.fromFile(mainPom)
+      val modifiedPom = new File(s"$tempIvyPath/modified-mylib-0.1.pom")
+      val sink = new PrintWriter(modifiedPom)
+      source.getLines()
+        .map(l => if (l.trim == "<artifactId>mydep</artifactId>") 
s"$l<type>pom</type>" else l)
+        // scalastyle:off println
+        .foreach(sink.println)
+        // scalastyle:on println
+      source.close()
+      sink.close()
+      modifiedPom.renameTo(mainPom)

Review comment:
       Can we simplify this a bit with the use of NIO `Files`:
   ```
         val mainPom = 
Paths.get(URI.create(repo)).resolve("my/great/lib/mylib/0.1/mylib-0.1.pom")
         val lines = java.nio.file.Files.lines(mainPom).iterator.asScala
             .map(l => if (l.trim == "<artifactId>mydep</artifactId>") 
s"$l<type>pom</type>" else l)
             .toList
         java.nio.file.Files.write(mainPom, lines.asJava)
   ```
   (you can do a rename import on NIO Files to avoid the full path name here, 
or just get rid of the Guava `Files` import -- looks like there is only one 
usage in this file)




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]



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

Reply via email to