Skip to content

Commit

Permalink
[Improve] maven dependency check improvement
Browse files Browse the repository at this point in the history
  • Loading branch information
benjobs committed Nov 11, 2023
1 parent 33c1629 commit 5fb3c6c
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,20 +51,27 @@ public static MavenDependency of(String dependency) {
return new MavenDependency();
}

public boolean eq(MavenDependency that) {
if (that == null) {
@Override
public boolean equals(Object that) {
if (this == that) {
return true;
}

if (that == null || getClass() != that.getClass()) {
return false;
}

if (this.pom.size() != that.pom.size()
|| this.jar.size() != that.jar.size()
|| !this.pom.containsAll(that.pom)) {
MavenDependency thatDep = (MavenDependency) that;

if (this.pom.size() != thatDep.pom.size()
|| this.jar.size() != thatDep.jar.size()
|| !this.pom.containsAll(thatDep.pom)) {
return false;
}

File localJar = WebUtils.getAppTempDir();
File localUploads = new File(Workspace.local().APP_UPLOADS());
HashSet<String> otherJars = new HashSet<>(that.jar);
HashSet<String> otherJars = new HashSet<>(thatDep.jar);
for (String jarName : jar) {
if (!otherJars.contains(jarName)
|| !FileUtils.equals(new File(localJar, jarName), new File(localUploads, jarName))) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public boolean equals(Object o) {
this.exclusions == null ? Collections.emptySet() : this.exclusions;
Set<MavenExclusion> thatEx =
that.exclusions == null ? Collections.emptySet() : that.exclusions;
return thisEx.containsAll(thatEx);
return thisEx.size() == thatEx.size() && thisEx.containsAll(thatEx);
}
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public ChangedType checkChange(FlinkSql target) {
MavenDependency thisDependency = MavenDependency.of(this.getDependency());
MavenDependency targetDependency = MavenDependency.of(target.getDependency());

boolean depDifference = !thisDependency.eq(targetDependency);
boolean depDifference = !thisDependency.equals(targetDependency);
if (sqlDifference && depDifference) {
return ChangedType.ALL;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -856,7 +856,7 @@ public boolean update(Application appParam) {
MavenDependency thisDependency = MavenDependency.of(appParam.getDependency());
MavenDependency targetDependency = MavenDependency.of(application.getDependency());

if (!thisDependency.eq(targetDependency)) {
if (!thisDependency.equals(targetDependency)) {
application.setDependency(appParam.getDependency());
application.setBuild(true);
} else if (!ObjectUtils.safeEquals(application.getJar(), appParam.getJar())) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import { fetchUpload } from '/@/api/flink/app/app';
import { fetchUploadJars } from '/@/api/flink/app/flinkHistory';
import UploadJobJar from './UploadJobJar.vue';
import { fetchFlinkEnv } from '/@/api/flink/setting/flinkEnv';

interface DependencyType {
artifactId: string;
Expand Down Expand Up @@ -89,7 +90,12 @@
Swal.fire('Failed', t('flink.app.dependencyError'), 'error');
return;
}
const scalaVersion = props.flinkEnvs.find((v) => v.id === versionId)?.scalaVersion;

let flinkEnv = props.flinkEnvs || [];
if (props.flinkEnvs?.length == 0) {
flinkEnv = await fetchFlinkEnv();
}
const scalaVersion = flinkEnv.find((v) => v.id === versionId)?.scalaVersion;
if (props.value == null || props.value.trim() === '') {
return;
}
Expand Down

0 comments on commit 5fb3c6c

Please sign in to comment.