diff --git a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/bean/MavenDependency.java b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/bean/MavenDependency.java index 16b6ea2156..ec6bb14a84 100644 --- a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/bean/MavenDependency.java +++ b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/bean/MavenDependency.java @@ -31,7 +31,6 @@ import java.io.File; import java.util.Collections; -import java.util.HashSet; import java.util.List; import java.util.Set; import java.util.stream.Collectors; @@ -71,9 +70,8 @@ public boolean equals(Object that) { File localJar = WebUtils.getAppTempDir(); File localUploads = new File(Workspace.local().APP_UPLOADS()); - HashSet otherJars = new HashSet<>(thatDep.jar); for (String jarName : jar) { - if (!otherJars.contains(jarName) + if (!thatDep.jar.contains(jarName) || !FileUtils.equals(new File(localJar, jarName), new File(localUploads, jarName))) { return false; } diff --git a/streampark-flink/streampark-flink-packer/src/main/scala/org/apache/streampark/flink/packer/maven/MavenTool.scala b/streampark-flink/streampark-flink-packer/src/main/scala/org/apache/streampark/flink/packer/maven/MavenTool.scala index 35f9857688..a56f413218 100644 --- a/streampark-flink/streampark-flink-packer/src/main/scala/org/apache/streampark/flink/packer/maven/MavenTool.scala +++ b/streampark-flink/streampark-flink-packer/src/main/scala/org/apache/streampark/flink/packer/maven/MavenTool.scala @@ -193,57 +193,55 @@ object MavenTool extends Logger { */ @throws[Exception] def resolveArtifacts(mavenArtifacts: Set[Artifact]): Set[File] = { - if (mavenArtifacts == null) Set.empty[File]; - else { - val (repoSystem, session) = getMavenEndpoint() - val artifacts = mavenArtifacts.map( - e => { - new DefaultArtifact( - e.groupId, - e.artifactId, - e.classifier, - "jar", - e.version) -> e.extensions - }) - logInfo(s"start resolving dependencies: ${artifacts.mkString}") - - val remoteRepos = getRemoteRepos() - // read relevant artifact descriptor info - // plz don't simplify the following lambda syntax to maintain the readability of the code. - val dependenciesArtifacts = artifacts - .map( - artifact => new ArtifactDescriptorRequest(artifact._1, remoteRepos, null) -> artifact._2) - .map(descReq => repoSystem.readArtifactDescriptor(session, descReq._1) -> descReq._2) - .flatMap( - descResult => { - descResult._1.getDependencies.filter( - d => { - val ga = s"${d.getArtifact.getGroupId}:${d.getArtifact.getArtifactId}" - val exclusion = descResult._2.contains(ga) - if (exclusion) { - val art = descResult._1.getArtifact - val name = s"${art.getGroupId}:${art.getArtifactId}" - logInfo(s"[MavenTool] $name dependencies exclusion $ga") + if (mavenArtifacts == null) { + return Set.empty[File] + } + + val (repoSystem, session) = getMavenEndpoint() + val artifacts = mavenArtifacts.map( + e => { + new DefaultArtifact(e.groupId, e.artifactId, e.classifier, "jar", e.version) -> e.extensions + }) + + logInfo(s"start resolving dependencies: ${artifacts.mkString}") + + val remoteRepos = getRemoteRepos() + // read relevant artifact descriptor info + // plz don't simplify the following lambda syntax to maintain the readability of the code. + val dependenciesArtifacts = artifacts + .map(artifact => new ArtifactDescriptorRequest(artifact._1, remoteRepos, null) -> artifact._2) + .map(descReq => repoSystem.readArtifactDescriptor(session, descReq._1) -> descReq._2) + .flatMap( + result => + result._1.getDependencies + .filter( + dep => { + dep.getScope match { + case "compile" if !excludeArtifact.exists(_.filter(dep.getArtifact)) => + val ga = s"${dep.getArtifact.getGroupId}:${dep.getArtifact.getArtifactId}" + val exclusion = result._2.contains(ga) + if (exclusion) { + val art = result._1.getArtifact + val name = s"${art.getGroupId}:${art.getArtifactId}" + logInfo(s"[MavenTool] $name dependencies exclusion $ga") + } + !exclusion + case _ => false } - !exclusion }) - }) - .filter(_.getScope == "compile") - .filter(x => !excludeArtifact.exists(_.filter(x.getArtifact))) - .map(_.getArtifact) - - val mergedArtifacts = artifacts.map(_._1) ++ dependenciesArtifacts - - logInfo(s"resolved dependencies: ${mergedArtifacts.mkString}") - - // download artifacts - val artReqs = - mergedArtifacts.map(artifact => new ArtifactRequest(artifact, remoteRepos, null)) - repoSystem - .resolveArtifacts(session, artReqs) - .map(_.getArtifact.getFile) - .toSet - } + .map(_.getArtifact)) + + val mergedArtifacts = artifacts.map(_._1) ++ dependenciesArtifacts + + logInfo(s"resolved dependencies: ${mergedArtifacts.mkString}") + + // download artifacts + val artReqs = + mergedArtifacts.map(artifact => new ArtifactRequest(artifact, remoteRepos, null)) + repoSystem + .resolveArtifacts(session, artReqs) + .map(_.getArtifact.getFile) + .toSet } /** create composite maven endpoint */