Fix comparison for SdkAndMockLibraryProjectDescriptor
There's no known problems connected with this change, but wrong comparison might cause tests flakiness. `allowKotlinPackage` and `classpath` fields were not included.
This commit is contained in:
+20
-19
@@ -33,41 +33,47 @@ import org.jetbrains.kotlin.utils.PathUtil;
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
import static java.util.Collections.emptyList;
|
import static java.util.Collections.emptyList;
|
||||||
|
|
||||||
public class SdkAndMockLibraryProjectDescriptor extends KotlinLightProjectDescriptor {
|
public class SdkAndMockLibraryProjectDescriptor extends KotlinLightProjectDescriptor {
|
||||||
public static final String LIBRARY_NAME = "myKotlinLib";
|
public static final String LIBRARY_NAME = "myKotlinLib";
|
||||||
|
|
||||||
private final String sourcesPath;
|
|
||||||
private final boolean withSources;
|
private final boolean withSources;
|
||||||
private final boolean withRuntime;
|
private final boolean withRuntime;
|
||||||
private final boolean isJsLibrary;
|
private final boolean isJsLibrary;
|
||||||
private final boolean allowKotlinPackage;
|
private final boolean allowKotlinPackage;
|
||||||
|
private final String sourcesPath;
|
||||||
private final List<String> classpath;
|
private final List<String> classpath;
|
||||||
|
|
||||||
public SdkAndMockLibraryProjectDescriptor(String sourcesPath, boolean withSources) {
|
public SdkAndMockLibraryProjectDescriptor(@NotNull String sourcesPath, boolean withSources) {
|
||||||
this(sourcesPath, withSources, false, false, false);
|
this(sourcesPath, withSources, false, false, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public SdkAndMockLibraryProjectDescriptor(
|
public SdkAndMockLibraryProjectDescriptor(
|
||||||
String sourcesPath, boolean withSources, boolean withRuntime, boolean isJsLibrary, boolean allowKotlinPackage) {
|
@NotNull String sourcesPath,
|
||||||
|
boolean withSources, boolean withRuntime, boolean isJsLibrary, boolean allowKotlinPackage
|
||||||
|
) {
|
||||||
this(sourcesPath, withSources, withRuntime, isJsLibrary, allowKotlinPackage, emptyList());
|
this(sourcesPath, withSources, withRuntime, isJsLibrary, allowKotlinPackage, emptyList());
|
||||||
}
|
}
|
||||||
|
|
||||||
public SdkAndMockLibraryProjectDescriptor(
|
public SdkAndMockLibraryProjectDescriptor(
|
||||||
String sourcesPath, boolean withSources, boolean withRuntime, boolean isJsLibrary, boolean allowKotlinPackage, List<String> classpath
|
@NotNull String sourcesPath,
|
||||||
|
boolean withSources, boolean withRuntime, boolean isJsLibrary, boolean allowKotlinPackage,
|
||||||
|
@NotNull List<String> classpath
|
||||||
) {
|
) {
|
||||||
this.sourcesPath = sourcesPath;
|
|
||||||
this.withSources = withSources;
|
this.withSources = withSources;
|
||||||
this.withRuntime = withRuntime;
|
this.withRuntime = withRuntime;
|
||||||
this.isJsLibrary = isJsLibrary;
|
this.isJsLibrary = isJsLibrary;
|
||||||
this.allowKotlinPackage = allowKotlinPackage;
|
this.allowKotlinPackage = allowKotlinPackage;
|
||||||
|
this.sourcesPath = sourcesPath;
|
||||||
this.classpath = classpath;
|
this.classpath = classpath;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void configureModule(@NotNull Module module, @NotNull ModifiableRootModel model) {
|
public void configureModule(@NotNull Module module, @NotNull ModifiableRootModel model) {
|
||||||
|
@SuppressWarnings("SpellCheckingInspection")
|
||||||
List<String> extraOptions = allowKotlinPackage ? Collections.singletonList("-Xallow-kotlin-package") : emptyList();
|
List<String> extraOptions = allowKotlinPackage ? Collections.singletonList("-Xallow-kotlin-package") : emptyList();
|
||||||
File libraryJar =
|
File libraryJar =
|
||||||
isJsLibrary
|
isJsLibrary
|
||||||
@@ -75,7 +81,8 @@ public class SdkAndMockLibraryProjectDescriptor extends KotlinLightProjectDescri
|
|||||||
: MockLibraryUtil.compileJvmLibraryToJar(sourcesPath, LIBRARY_NAME, withSources, true, extraOptions, classpath);
|
: MockLibraryUtil.compileJvmLibraryToJar(sourcesPath, LIBRARY_NAME, withSources, true, extraOptions, classpath);
|
||||||
String jarUrl = getJarUrl(libraryJar);
|
String jarUrl = getJarUrl(libraryJar);
|
||||||
|
|
||||||
Library.ModifiableModel libraryModel = model.getModuleLibraryTable().getModifiableModel().createLibrary(LIBRARY_NAME).getModifiableModel();
|
Library.ModifiableModel libraryModel =
|
||||||
|
model.getModuleLibraryTable().getModifiableModel().createLibrary(LIBRARY_NAME).getModifiableModel();
|
||||||
libraryModel.addRoot(jarUrl, OrderRootType.CLASSES);
|
libraryModel.addRoot(jarUrl, OrderRootType.CLASSES);
|
||||||
if (withRuntime && !isJsLibrary) {
|
if (withRuntime && !isJsLibrary) {
|
||||||
libraryModel.addRoot(getJarUrl(PathUtil.getKotlinPathsForDistDirectory().getStdlibPath()), OrderRootType.CLASSES);
|
libraryModel.addRoot(getJarUrl(PathUtil.getKotlinPathsForDistDirectory().getStdlibPath()), OrderRootType.CLASSES);
|
||||||
@@ -108,23 +115,17 @@ public class SdkAndMockLibraryProjectDescriptor extends KotlinLightProjectDescri
|
|||||||
public boolean equals(Object o) {
|
public boolean equals(Object o) {
|
||||||
if (this == o) return true;
|
if (this == o) return true;
|
||||||
if (o == null || getClass() != o.getClass()) return false;
|
if (o == null || getClass() != o.getClass()) return false;
|
||||||
|
|
||||||
SdkAndMockLibraryProjectDescriptor that = (SdkAndMockLibraryProjectDescriptor) o;
|
SdkAndMockLibraryProjectDescriptor that = (SdkAndMockLibraryProjectDescriptor) o;
|
||||||
|
return withSources == that.withSources &&
|
||||||
if (withSources != that.withSources) return false;
|
withRuntime == that.withRuntime &&
|
||||||
if (withRuntime != that.withRuntime) return false;
|
isJsLibrary == that.isJsLibrary &&
|
||||||
if (isJsLibrary != that.isJsLibrary) return false;
|
allowKotlinPackage == that.allowKotlinPackage &&
|
||||||
if (!sourcesPath.equals(that.sourcesPath)) return false;
|
sourcesPath.equals(that.sourcesPath) &&
|
||||||
|
classpath.equals(that.classpath);
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
int result = sourcesPath.hashCode();
|
return Objects.hash(withSources, withRuntime, isJsLibrary, allowKotlinPackage, sourcesPath, classpath);
|
||||||
result = 31 * result + (withSources ? 1 : 0);
|
|
||||||
result = 31 * result + (withRuntime ? 1 : 0);
|
|
||||||
result = 31 * result + (isJsLibrary ? 1 : 0);
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user