From f5e946c0b2275ee6acc9761b3b0c3274ad920a88 Mon Sep 17 00:00:00 2001 From: Sebastian Sellmair Date: Thu, 27 Jul 2023 16:22:18 +0200 Subject: [PATCH] [Gradle] IdeaKotlinProjectCoordinates: Replace 'buildId' with 'buildName' and 'buildPath' ^KT-58157 In Progress --- .../IdeaKotlinProjectCoordinatesProto.java | 389 ++++++++++++++---- ...otlinProjectCoordinatesProtoOrBuilder.java | 59 ++- .../idea/proto/generated/tcs/ProtoTcs.java | 63 +-- .../IdeaKotlinProjectCoordinatesProtoKt.kt | 74 +++- .../proto/tcs/IdeaKotlinProjectCoordinates.kt | 19 +- .../src/main/proto/proto_tcs.proto | 3 +- ...linDependencyBackwardsCompatibilityTest.kt | 32 +- ...tlinProjectCoordinatesSerializationTest.kt | 41 ++ ...otlinSourceCoordinatesSerializationTest.kt | 14 + .../api/kotlin-gradle-plugin-idea.api | 7 + .../tcs/IdeaKotlinDependencyCoordinates.kt | 111 ++++- .../tcs/IdeaKotlinSourceDependencyMatcher.kt | 5 +- .../tcs/TestIdeaKotlinInstances.kt | 1 + 13 files changed, 671 insertions(+), 147 deletions(-) create mode 100644 libraries/tools/kotlin-gradle-plugin-idea-proto/src/test/kotlin/org/jetbrains/kotlin/gradle/idea/proto/tcs/IdeaKotlinProjectCoordinatesSerializationTest.kt diff --git a/libraries/tools/kotlin-gradle-plugin-idea-proto/src/generated/java/org/jetbrains/kotlin/gradle/idea/proto/generated/tcs/IdeaKotlinProjectCoordinatesProto.java b/libraries/tools/kotlin-gradle-plugin-idea-proto/src/generated/java/org/jetbrains/kotlin/gradle/idea/proto/generated/tcs/IdeaKotlinProjectCoordinatesProto.java index dae8989cf25..117a46722b5 100644 --- a/libraries/tools/kotlin-gradle-plugin-idea-proto/src/generated/java/org/jetbrains/kotlin/gradle/idea/proto/generated/tcs/IdeaKotlinProjectCoordinatesProto.java +++ b/libraries/tools/kotlin-gradle-plugin-idea-proto/src/generated/java/org/jetbrains/kotlin/gradle/idea/proto/generated/tcs/IdeaKotlinProjectCoordinatesProto.java @@ -16,7 +16,8 @@ private static final long serialVersionUID = 0L; super(builder); } private IdeaKotlinProjectCoordinatesProto() { - buildId_ = ""; + buildName_ = ""; + buildPath_ = ""; projectPath_ = ""; projectName_ = ""; } @@ -47,46 +48,116 @@ private static final long serialVersionUID = 0L; } private int bitField0_; - public static final int BUILD_ID_FIELD_NUMBER = 1; - private volatile java.lang.Object buildId_; + public static final int BUILD_NAME_FIELD_NUMBER = 1; + private volatile java.lang.Object buildName_; /** - * optional string build_id = 1; - * @return Whether the buildId field is set. + *
+   * Renamed from 'build_id' to 'build_name' in 1.9.20
+   * 
+ * + * optional string build_name = 1; + * @return Whether the buildName field is set. */ @java.lang.Override - public boolean hasBuildId() { + public boolean hasBuildName() { return ((bitField0_ & 0x00000001) != 0); } /** - * optional string build_id = 1; - * @return The buildId. + *
+   * Renamed from 'build_id' to 'build_name' in 1.9.20
+   * 
+ * + * optional string build_name = 1; + * @return The buildName. */ @java.lang.Override - public java.lang.String getBuildId() { - java.lang.Object ref = buildId_; + public java.lang.String getBuildName() { + java.lang.Object ref = buildName_; if (ref instanceof java.lang.String) { return (java.lang.String) ref; } else { com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; java.lang.String s = bs.toStringUtf8(); - buildId_ = s; + buildName_ = s; return s; } } /** - * optional string build_id = 1; - * @return The bytes for buildId. + *
+   * Renamed from 'build_id' to 'build_name' in 1.9.20
+   * 
+ * + * optional string build_name = 1; + * @return The bytes for buildName. */ @java.lang.Override public com.google.protobuf.ByteString - getBuildIdBytes() { - java.lang.Object ref = buildId_; + getBuildNameBytes() { + java.lang.Object ref = buildName_; if (ref instanceof java.lang.String) { com.google.protobuf.ByteString b = com.google.protobuf.ByteString.copyFromUtf8( (java.lang.String) ref); - buildId_ = b; + buildName_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int BUILD_PATH_FIELD_NUMBER = 4; + private volatile java.lang.Object buildPath_; + /** + *
+   * Added in 1.9.20
+   * 
+ * + * optional string build_path = 4; + * @return Whether the buildPath field is set. + */ + @java.lang.Override + public boolean hasBuildPath() { + return ((bitField0_ & 0x00000002) != 0); + } + /** + *
+   * Added in 1.9.20
+   * 
+ * + * optional string build_path = 4; + * @return The buildPath. + */ + @java.lang.Override + public java.lang.String getBuildPath() { + java.lang.Object ref = buildPath_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + buildPath_ = s; + return s; + } + } + /** + *
+   * Added in 1.9.20
+   * 
+ * + * optional string build_path = 4; + * @return The bytes for buildPath. + */ + @java.lang.Override + public com.google.protobuf.ByteString + getBuildPathBytes() { + java.lang.Object ref = buildPath_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + buildPath_ = b; return b; } else { return (com.google.protobuf.ByteString) ref; @@ -101,7 +172,7 @@ private static final long serialVersionUID = 0L; */ @java.lang.Override public boolean hasProjectPath() { - return ((bitField0_ & 0x00000002) != 0); + return ((bitField0_ & 0x00000004) != 0); } /** * optional string project_path = 2; @@ -147,7 +218,7 @@ private static final long serialVersionUID = 0L; */ @java.lang.Override public boolean hasProjectName() { - return ((bitField0_ & 0x00000004) != 0); + return ((bitField0_ & 0x00000008) != 0); } /** * optional string project_name = 3; @@ -200,14 +271,17 @@ private static final long serialVersionUID = 0L; public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { if (((bitField0_ & 0x00000001) != 0)) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 1, buildId_); - } - if (((bitField0_ & 0x00000002) != 0)) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 2, projectPath_); + com.google.protobuf.GeneratedMessageV3.writeString(output, 1, buildName_); } if (((bitField0_ & 0x00000004) != 0)) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 2, projectPath_); + } + if (((bitField0_ & 0x00000008) != 0)) { com.google.protobuf.GeneratedMessageV3.writeString(output, 3, projectName_); } + if (((bitField0_ & 0x00000002) != 0)) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 4, buildPath_); + } getUnknownFields().writeTo(output); } @@ -218,14 +292,17 @@ private static final long serialVersionUID = 0L; size = 0; if (((bitField0_ & 0x00000001) != 0)) { - size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, buildId_); - } - if (((bitField0_ & 0x00000002) != 0)) { - size += com.google.protobuf.GeneratedMessageV3.computeStringSize(2, projectPath_); + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, buildName_); } if (((bitField0_ & 0x00000004) != 0)) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(2, projectPath_); + } + if (((bitField0_ & 0x00000008) != 0)) { size += com.google.protobuf.GeneratedMessageV3.computeStringSize(3, projectName_); } + if (((bitField0_ & 0x00000002) != 0)) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(4, buildPath_); + } size += getUnknownFields().getSerializedSize(); memoizedSize = size; return size; @@ -241,10 +318,15 @@ private static final long serialVersionUID = 0L; } org.jetbrains.kotlin.gradle.idea.proto.generated.tcs.IdeaKotlinProjectCoordinatesProto other = (org.jetbrains.kotlin.gradle.idea.proto.generated.tcs.IdeaKotlinProjectCoordinatesProto) obj; - if (hasBuildId() != other.hasBuildId()) return false; - if (hasBuildId()) { - if (!getBuildId() - .equals(other.getBuildId())) return false; + if (hasBuildName() != other.hasBuildName()) return false; + if (hasBuildName()) { + if (!getBuildName() + .equals(other.getBuildName())) return false; + } + if (hasBuildPath() != other.hasBuildPath()) return false; + if (hasBuildPath()) { + if (!getBuildPath() + .equals(other.getBuildPath())) return false; } if (hasProjectPath() != other.hasProjectPath()) return false; if (hasProjectPath()) { @@ -267,9 +349,13 @@ private static final long serialVersionUID = 0L; } int hash = 41; hash = (19 * hash) + getDescriptor().hashCode(); - if (hasBuildId()) { - hash = (37 * hash) + BUILD_ID_FIELD_NUMBER; - hash = (53 * hash) + getBuildId().hashCode(); + if (hasBuildName()) { + hash = (37 * hash) + BUILD_NAME_FIELD_NUMBER; + hash = (53 * hash) + getBuildName().hashCode(); + } + if (hasBuildPath()) { + hash = (37 * hash) + BUILD_PATH_FIELD_NUMBER; + hash = (53 * hash) + getBuildPath().hashCode(); } if (hasProjectPath()) { hash = (37 * hash) + PROJECT_PATH_FIELD_NUMBER; @@ -407,12 +493,14 @@ private static final long serialVersionUID = 0L; @java.lang.Override public Builder clear() { super.clear(); - buildId_ = ""; + buildName_ = ""; bitField0_ = (bitField0_ & ~0x00000001); - projectPath_ = ""; + buildPath_ = ""; bitField0_ = (bitField0_ & ~0x00000002); - projectName_ = ""; + projectPath_ = ""; bitField0_ = (bitField0_ & ~0x00000004); + projectName_ = ""; + bitField0_ = (bitField0_ & ~0x00000008); return this; } @@ -444,14 +532,18 @@ private static final long serialVersionUID = 0L; if (((from_bitField0_ & 0x00000001) != 0)) { to_bitField0_ |= 0x00000001; } - result.buildId_ = buildId_; + result.buildName_ = buildName_; if (((from_bitField0_ & 0x00000002) != 0)) { to_bitField0_ |= 0x00000002; } - result.projectPath_ = projectPath_; + result.buildPath_ = buildPath_; if (((from_bitField0_ & 0x00000004) != 0)) { to_bitField0_ |= 0x00000004; } + result.projectPath_ = projectPath_; + if (((from_bitField0_ & 0x00000008) != 0)) { + to_bitField0_ |= 0x00000008; + } result.projectName_ = projectName_; result.bitField0_ = to_bitField0_; onBuilt(); @@ -502,18 +594,23 @@ private static final long serialVersionUID = 0L; public Builder mergeFrom(org.jetbrains.kotlin.gradle.idea.proto.generated.tcs.IdeaKotlinProjectCoordinatesProto other) { if (other == org.jetbrains.kotlin.gradle.idea.proto.generated.tcs.IdeaKotlinProjectCoordinatesProto.getDefaultInstance()) return this; - if (other.hasBuildId()) { + if (other.hasBuildName()) { bitField0_ |= 0x00000001; - buildId_ = other.buildId_; + buildName_ = other.buildName_; + onChanged(); + } + if (other.hasBuildPath()) { + bitField0_ |= 0x00000002; + buildPath_ = other.buildPath_; onChanged(); } if (other.hasProjectPath()) { - bitField0_ |= 0x00000002; + bitField0_ |= 0x00000004; projectPath_ = other.projectPath_; onChanged(); } if (other.hasProjectName()) { - bitField0_ |= 0x00000004; + bitField0_ |= 0x00000008; projectName_ = other.projectName_; onChanged(); } @@ -544,20 +641,25 @@ private static final long serialVersionUID = 0L; done = true; break; case 10: { - buildId_ = input.readStringRequireUtf8(); + buildName_ = input.readStringRequireUtf8(); bitField0_ |= 0x00000001; break; } // case 10 case 18: { projectPath_ = input.readStringRequireUtf8(); - bitField0_ |= 0x00000002; + bitField0_ |= 0x00000004; break; } // case 18 case 26: { projectName_ = input.readStringRequireUtf8(); - bitField0_ |= 0x00000004; + bitField0_ |= 0x00000008; break; } // case 26 + case 34: { + buildPath_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00000002; + break; + } // case 34 default: { if (!super.parseUnknownField(input, extensionRegistry, tag)) { done = true; // was an endgroup tag @@ -575,85 +677,216 @@ private static final long serialVersionUID = 0L; } private int bitField0_; - private java.lang.Object buildId_ = ""; + private java.lang.Object buildName_ = ""; /** - * optional string build_id = 1; - * @return Whether the buildId field is set. + *
+     * Renamed from 'build_id' to 'build_name' in 1.9.20
+     * 
+ * + * optional string build_name = 1; + * @return Whether the buildName field is set. */ - public boolean hasBuildId() { + public boolean hasBuildName() { return ((bitField0_ & 0x00000001) != 0); } /** - * optional string build_id = 1; - * @return The buildId. + *
+     * Renamed from 'build_id' to 'build_name' in 1.9.20
+     * 
+ * + * optional string build_name = 1; + * @return The buildName. */ - public java.lang.String getBuildId() { - java.lang.Object ref = buildId_; + public java.lang.String getBuildName() { + java.lang.Object ref = buildName_; if (!(ref instanceof java.lang.String)) { com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; java.lang.String s = bs.toStringUtf8(); - buildId_ = s; + buildName_ = s; return s; } else { return (java.lang.String) ref; } } /** - * optional string build_id = 1; - * @return The bytes for buildId. + *
+     * Renamed from 'build_id' to 'build_name' in 1.9.20
+     * 
+ * + * optional string build_name = 1; + * @return The bytes for buildName. */ public com.google.protobuf.ByteString - getBuildIdBytes() { - java.lang.Object ref = buildId_; + getBuildNameBytes() { + java.lang.Object ref = buildName_; if (ref instanceof String) { com.google.protobuf.ByteString b = com.google.protobuf.ByteString.copyFromUtf8( (java.lang.String) ref); - buildId_ = b; + buildName_ = b; return b; } else { return (com.google.protobuf.ByteString) ref; } } /** - * optional string build_id = 1; - * @param value The buildId to set. + *
+     * Renamed from 'build_id' to 'build_name' in 1.9.20
+     * 
+ * + * optional string build_name = 1; + * @param value The buildName to set. * @return This builder for chaining. */ - public Builder setBuildId( + public Builder setBuildName( java.lang.String value) { if (value == null) { throw new NullPointerException(); } bitField0_ |= 0x00000001; - buildId_ = value; + buildName_ = value; onChanged(); return this; } /** - * optional string build_id = 1; + *
+     * Renamed from 'build_id' to 'build_name' in 1.9.20
+     * 
+ * + * optional string build_name = 1; * @return This builder for chaining. */ - public Builder clearBuildId() { + public Builder clearBuildName() { bitField0_ = (bitField0_ & ~0x00000001); - buildId_ = getDefaultInstance().getBuildId(); + buildName_ = getDefaultInstance().getBuildName(); onChanged(); return this; } /** - * optional string build_id = 1; - * @param value The bytes for buildId to set. + *
+     * Renamed from 'build_id' to 'build_name' in 1.9.20
+     * 
+ * + * optional string build_name = 1; + * @param value The bytes for buildName to set. * @return This builder for chaining. */ - public Builder setBuildIdBytes( + public Builder setBuildNameBytes( com.google.protobuf.ByteString value) { if (value == null) { throw new NullPointerException(); } checkByteStringIsUtf8(value); bitField0_ |= 0x00000001; - buildId_ = value; + buildName_ = value; + onChanged(); + return this; + } + + private java.lang.Object buildPath_ = ""; + /** + *
+     * Added in 1.9.20
+     * 
+ * + * optional string build_path = 4; + * @return Whether the buildPath field is set. + */ + public boolean hasBuildPath() { + return ((bitField0_ & 0x00000002) != 0); + } + /** + *
+     * Added in 1.9.20
+     * 
+ * + * optional string build_path = 4; + * @return The buildPath. + */ + public java.lang.String getBuildPath() { + java.lang.Object ref = buildPath_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + buildPath_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + *
+     * Added in 1.9.20
+     * 
+ * + * optional string build_path = 4; + * @return The bytes for buildPath. + */ + public com.google.protobuf.ByteString + getBuildPathBytes() { + java.lang.Object ref = buildPath_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + buildPath_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + *
+     * Added in 1.9.20
+     * 
+ * + * optional string build_path = 4; + * @param value The buildPath to set. + * @return This builder for chaining. + */ + public Builder setBuildPath( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000002; + buildPath_ = value; + onChanged(); + return this; + } + /** + *
+     * Added in 1.9.20
+     * 
+ * + * optional string build_path = 4; + * @return This builder for chaining. + */ + public Builder clearBuildPath() { + bitField0_ = (bitField0_ & ~0x00000002); + buildPath_ = getDefaultInstance().getBuildPath(); + onChanged(); + return this; + } + /** + *
+     * Added in 1.9.20
+     * 
+ * + * optional string build_path = 4; + * @param value The bytes for buildPath to set. + * @return This builder for chaining. + */ + public Builder setBuildPathBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + bitField0_ |= 0x00000002; + buildPath_ = value; onChanged(); return this; } @@ -664,7 +897,7 @@ private static final long serialVersionUID = 0L; * @return Whether the projectPath field is set. */ public boolean hasProjectPath() { - return ((bitField0_ & 0x00000002) != 0); + return ((bitField0_ & 0x00000004) != 0); } /** * optional string project_path = 2; @@ -709,7 +942,7 @@ private static final long serialVersionUID = 0L; if (value == null) { throw new NullPointerException(); } - bitField0_ |= 0x00000002; + bitField0_ |= 0x00000004; projectPath_ = value; onChanged(); return this; @@ -719,7 +952,7 @@ private static final long serialVersionUID = 0L; * @return This builder for chaining. */ public Builder clearProjectPath() { - bitField0_ = (bitField0_ & ~0x00000002); + bitField0_ = (bitField0_ & ~0x00000004); projectPath_ = getDefaultInstance().getProjectPath(); onChanged(); return this; @@ -735,7 +968,7 @@ private static final long serialVersionUID = 0L; throw new NullPointerException(); } checkByteStringIsUtf8(value); - bitField0_ |= 0x00000002; + bitField0_ |= 0x00000004; projectPath_ = value; onChanged(); return this; @@ -747,7 +980,7 @@ private static final long serialVersionUID = 0L; * @return Whether the projectName field is set. */ public boolean hasProjectName() { - return ((bitField0_ & 0x00000004) != 0); + return ((bitField0_ & 0x00000008) != 0); } /** * optional string project_name = 3; @@ -792,7 +1025,7 @@ private static final long serialVersionUID = 0L; if (value == null) { throw new NullPointerException(); } - bitField0_ |= 0x00000004; + bitField0_ |= 0x00000008; projectName_ = value; onChanged(); return this; @@ -802,7 +1035,7 @@ private static final long serialVersionUID = 0L; * @return This builder for chaining. */ public Builder clearProjectName() { - bitField0_ = (bitField0_ & ~0x00000004); + bitField0_ = (bitField0_ & ~0x00000008); projectName_ = getDefaultInstance().getProjectName(); onChanged(); return this; @@ -818,7 +1051,7 @@ private static final long serialVersionUID = 0L; throw new NullPointerException(); } checkByteStringIsUtf8(value); - bitField0_ |= 0x00000004; + bitField0_ |= 0x00000008; projectName_ = value; onChanged(); return this; diff --git a/libraries/tools/kotlin-gradle-plugin-idea-proto/src/generated/java/org/jetbrains/kotlin/gradle/idea/proto/generated/tcs/IdeaKotlinProjectCoordinatesProtoOrBuilder.java b/libraries/tools/kotlin-gradle-plugin-idea-proto/src/generated/java/org/jetbrains/kotlin/gradle/idea/proto/generated/tcs/IdeaKotlinProjectCoordinatesProtoOrBuilder.java index ecfbd3122c4..a7d5edf654b 100644 --- a/libraries/tools/kotlin-gradle-plugin-idea-proto/src/generated/java/org/jetbrains/kotlin/gradle/idea/proto/generated/tcs/IdeaKotlinProjectCoordinatesProtoOrBuilder.java +++ b/libraries/tools/kotlin-gradle-plugin-idea-proto/src/generated/java/org/jetbrains/kotlin/gradle/idea/proto/generated/tcs/IdeaKotlinProjectCoordinatesProtoOrBuilder.java @@ -8,21 +8,62 @@ public interface IdeaKotlinProjectCoordinatesProtoOrBuilder extends com.google.protobuf.MessageOrBuilder { /** - * optional string build_id = 1; - * @return Whether the buildId field is set. + *
+   * Renamed from 'build_id' to 'build_name' in 1.9.20
+   * 
+ * + * optional string build_name = 1; + * @return Whether the buildName field is set. */ - boolean hasBuildId(); + boolean hasBuildName(); /** - * optional string build_id = 1; - * @return The buildId. + *
+   * Renamed from 'build_id' to 'build_name' in 1.9.20
+   * 
+ * + * optional string build_name = 1; + * @return The buildName. */ - java.lang.String getBuildId(); + java.lang.String getBuildName(); /** - * optional string build_id = 1; - * @return The bytes for buildId. + *
+   * Renamed from 'build_id' to 'build_name' in 1.9.20
+   * 
+ * + * optional string build_name = 1; + * @return The bytes for buildName. */ com.google.protobuf.ByteString - getBuildIdBytes(); + getBuildNameBytes(); + + /** + *
+   * Added in 1.9.20
+   * 
+ * + * optional string build_path = 4; + * @return Whether the buildPath field is set. + */ + boolean hasBuildPath(); + /** + *
+   * Added in 1.9.20
+   * 
+ * + * optional string build_path = 4; + * @return The buildPath. + */ + java.lang.String getBuildPath(); + /** + *
+   * Added in 1.9.20
+   * 
+ * + * optional string build_path = 4; + * @return The bytes for buildPath. + */ + com.google.protobuf.ByteString + getBuildPathBytes(); /** * optional string project_path = 2; diff --git a/libraries/tools/kotlin-gradle-plugin-idea-proto/src/generated/java/org/jetbrains/kotlin/gradle/idea/proto/generated/tcs/ProtoTcs.java b/libraries/tools/kotlin-gradle-plugin-idea-proto/src/generated/java/org/jetbrains/kotlin/gradle/idea/proto/generated/tcs/ProtoTcs.java index 92b529dbc34..f11e76a34d2 100644 --- a/libraries/tools/kotlin-gradle-plugin-idea-proto/src/generated/java/org/jetbrains/kotlin/gradle/idea/proto/generated/tcs/ProtoTcs.java +++ b/libraries/tools/kotlin-gradle-plugin-idea-proto/src/generated/java/org/jetbrains/kotlin/gradle/idea/proto/generated/tcs/ProtoTcs.java @@ -139,36 +139,37 @@ public final class ProtoTcs { "\n\013coordinates\030\003 \001(\0132W.org.jetbrains.kotl" + "in.gradle.idea.proto.generated.tcs.IdeaK" + "otlinProjectCoordinatesProtoH\002\210\001\001B\t\n\007_ex" + - "trasB\007\n\005_typeB\016\n\014_coordinates\"\237\001\n!IdeaKo" + - "tlinProjectCoordinatesProto\022\025\n\010build_id\030" + - "\001 \001(\tH\000\210\001\001\022\031\n\014project_path\030\002 \001(\tH\001\210\001\001\022\031\n" + - "\014project_name\030\003 \001(\tH\002\210\001\001B\013\n\t_build_idB\017\n" + - "\r_project_pathB\017\n\r_project_name\"\240\003\n Idea" + - "KotlinBinaryCoordinatesProto\022\022\n\005group\030\001 " + - "\001(\tH\000\210\001\001\022\023\n\006module\030\002 \001(\tH\001\210\001\001\022\024\n\007version" + - "\030\003 \001(\tH\002\210\001\001\022\034\n\017source_set_name\030\004 \001(\tH\003\210\001" + - "\001\022k\n\014capabilities\030\005 \003(\0132U.org.jetbrains." + - "kotlin.gradle.idea.proto.generated.tcs.I" + - "deaKotlinBinaryCapabilityProto\022n\n\nattrib" + - "utes\030\006 \001(\0132U.org.jetbrains.kotlin.gradle" + - ".idea.proto.generated.tcs.IdeaKotlinBina" + - "ryAttributesProtoH\004\210\001\001B\010\n\006_groupB\t\n\007_mod" + - "uleB\n\n\010_versionB\022\n\020_source_set_nameB\r\n\013_" + - "attributes\"}\n\037IdeaKotlinBinaryCapability" + - "Proto\022\022\n\005group\030\001 \001(\tH\000\210\001\001\022\021\n\004name\030\002 \001(\tH" + - "\001\210\001\001\022\024\n\007version\030\003 \001(\tH\002\210\001\001B\010\n\006_groupB\007\n\005" + - "_nameB\n\n\010_version\"\317\001\n\037IdeaKotlinBinaryAt" + - "tributesProto\022y\n\nattributes\030\001 \003(\0132e.org." + - "jetbrains.kotlin.gradle.idea.proto.gener" + - "ated.tcs.IdeaKotlinBinaryAttributesProto" + - ".AttributesEntry\0321\n\017AttributesEntry\022\013\n\003k" + - "ey\030\001 \001(\t\022\r\n\005value\030\002 \001(\t:\0028\001\"\317\001\n IdeaKotl" + - "inSourceCoordinatesProto\022m\n\007project\030\001 \001(" + - "\0132W.org.jetbrains.kotlin.gradle.idea.pro" + - "to.generated.tcs.IdeaKotlinProjectCoordi" + - "natesProtoH\000\210\001\001\022\034\n\017source_set_name\030\002 \001(\t" + - "H\001\210\001\001B\n\n\010_projectB\022\n\020_source_set_nameB\002P" + - "\001b\006proto3" + "trasB\007\n\005_typeB\016\n\014_coordinates\"\313\001\n!IdeaKo" + + "tlinProjectCoordinatesProto\022\027\n\nbuild_nam" + + "e\030\001 \001(\tH\000\210\001\001\022\027\n\nbuild_path\030\004 \001(\tH\001\210\001\001\022\031\n" + + "\014project_path\030\002 \001(\tH\002\210\001\001\022\031\n\014project_name" + + "\030\003 \001(\tH\003\210\001\001B\r\n\013_build_nameB\r\n\013_build_pat" + + "hB\017\n\r_project_pathB\017\n\r_project_name\"\240\003\n " + + "IdeaKotlinBinaryCoordinatesProto\022\022\n\005grou" + + "p\030\001 \001(\tH\000\210\001\001\022\023\n\006module\030\002 \001(\tH\001\210\001\001\022\024\n\007ver" + + "sion\030\003 \001(\tH\002\210\001\001\022\034\n\017source_set_name\030\004 \001(\t" + + "H\003\210\001\001\022k\n\014capabilities\030\005 \003(\0132U.org.jetbra" + + "ins.kotlin.gradle.idea.proto.generated.t" + + "cs.IdeaKotlinBinaryCapabilityProto\022n\n\nat" + + "tributes\030\006 \001(\0132U.org.jetbrains.kotlin.gr" + + "adle.idea.proto.generated.tcs.IdeaKotlin" + + "BinaryAttributesProtoH\004\210\001\001B\010\n\006_groupB\t\n\007" + + "_moduleB\n\n\010_versionB\022\n\020_source_set_nameB" + + "\r\n\013_attributes\"}\n\037IdeaKotlinBinaryCapabi" + + "lityProto\022\022\n\005group\030\001 \001(\tH\000\210\001\001\022\021\n\004name\030\002 " + + "\001(\tH\001\210\001\001\022\024\n\007version\030\003 \001(\tH\002\210\001\001B\010\n\006_group" + + "B\007\n\005_nameB\n\n\010_version\"\317\001\n\037IdeaKotlinBina" + + "ryAttributesProto\022y\n\nattributes\030\001 \003(\0132e." + + "org.jetbrains.kotlin.gradle.idea.proto.g" + + "enerated.tcs.IdeaKotlinBinaryAttributesP" + + "roto.AttributesEntry\0321\n\017AttributesEntry\022" + + "\013\n\003key\030\001 \001(\t\022\r\n\005value\030\002 \001(\t:\0028\001\"\317\001\n Idea" + + "KotlinSourceCoordinatesProto\022m\n\007project\030" + + "\001 \001(\0132W.org.jetbrains.kotlin.gradle.idea" + + ".proto.generated.tcs.IdeaKotlinProjectCo" + + "ordinatesProtoH\000\210\001\001\022\034\n\017source_set_name\030\002" + + " \001(\tH\001\210\001\001B\n\n\010_projectB\022\n\020_source_set_nam" + + "eB\002P\001b\006proto3" }; descriptor = com.google.protobuf.Descriptors.FileDescriptor .internalBuildGeneratedFileFrom(descriptorData, @@ -216,7 +217,7 @@ public final class ProtoTcs { internal_static_org_jetbrains_kotlin_gradle_idea_proto_generated_tcs_IdeaKotlinProjectCoordinatesProto_fieldAccessorTable = new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( internal_static_org_jetbrains_kotlin_gradle_idea_proto_generated_tcs_IdeaKotlinProjectCoordinatesProto_descriptor, - new java.lang.String[] { "BuildId", "ProjectPath", "ProjectName", "BuildId", "ProjectPath", "ProjectName", }); + new java.lang.String[] { "BuildName", "BuildPath", "ProjectPath", "ProjectName", "BuildName", "BuildPath", "ProjectPath", "ProjectName", }); internal_static_org_jetbrains_kotlin_gradle_idea_proto_generated_tcs_IdeaKotlinBinaryCoordinatesProto_descriptor = getDescriptor().getMessageTypes().get(7); internal_static_org_jetbrains_kotlin_gradle_idea_proto_generated_tcs_IdeaKotlinBinaryCoordinatesProto_fieldAccessorTable = new diff --git a/libraries/tools/kotlin-gradle-plugin-idea-proto/src/generated/kotlin/org/jetbrains/kotlin/gradle/idea/proto/generated/tcs/IdeaKotlinProjectCoordinatesProtoKt.kt b/libraries/tools/kotlin-gradle-plugin-idea-proto/src/generated/kotlin/org/jetbrains/kotlin/gradle/idea/proto/generated/tcs/IdeaKotlinProjectCoordinatesProtoKt.kt index 3af5667c17d..95680e9504d 100644 --- a/libraries/tools/kotlin-gradle-plugin-idea-proto/src/generated/kotlin/org/jetbrains/kotlin/gradle/idea/proto/generated/tcs/IdeaKotlinProjectCoordinatesProtoKt.kt +++ b/libraries/tools/kotlin-gradle-plugin-idea-proto/src/generated/kotlin/org/jetbrains/kotlin/gradle/idea/proto/generated/tcs/IdeaKotlinProjectCoordinatesProtoKt.kt @@ -23,27 +23,75 @@ object IdeaKotlinProjectCoordinatesProtoKt { internal fun _build(): org.jetbrains.kotlin.gradle.idea.proto.generated.tcs.IdeaKotlinProjectCoordinatesProto = _builder.build() /** - * optional string build_id = 1; + *
+     * Renamed from 'build_id' to 'build_name' in 1.9.20
+     * 
+ * + * optional string build_name = 1; */ - var buildId: kotlin.String - @JvmName("getBuildId") - get() = _builder.getBuildId() - @JvmName("setBuildId") + var buildName: kotlin.String + @JvmName("getBuildName") + get() = _builder.getBuildName() + @JvmName("setBuildName") set(value) { - _builder.setBuildId(value) + _builder.setBuildName(value) } /** - * optional string build_id = 1; + *
+     * Renamed from 'build_id' to 'build_name' in 1.9.20
+     * 
+ * + * optional string build_name = 1; */ - fun clearBuildId() { - _builder.clearBuildId() + fun clearBuildName() { + _builder.clearBuildName() } /** - * optional string build_id = 1; - * @return Whether the buildId field is set. + *
+     * Renamed from 'build_id' to 'build_name' in 1.9.20
+     * 
+ * + * optional string build_name = 1; + * @return Whether the buildName field is set. */ - fun hasBuildId(): kotlin.Boolean { - return _builder.hasBuildId() + fun hasBuildName(): kotlin.Boolean { + return _builder.hasBuildName() + } + + /** + *
+     * Added in 1.9.20
+     * 
+ * + * optional string build_path = 4; + */ + var buildPath: kotlin.String + @JvmName("getBuildPath") + get() = _builder.getBuildPath() + @JvmName("setBuildPath") + set(value) { + _builder.setBuildPath(value) + } + /** + *
+     * Added in 1.9.20
+     * 
+ * + * optional string build_path = 4; + */ + fun clearBuildPath() { + _builder.clearBuildPath() + } + /** + *
+     * Added in 1.9.20
+     * 
+ * + * optional string build_path = 4; + * @return Whether the buildPath field is set. + */ + fun hasBuildPath(): kotlin.Boolean { + return _builder.hasBuildPath() } /** diff --git a/libraries/tools/kotlin-gradle-plugin-idea-proto/src/main/kotlin/org/jetbrains/kotlin/gradle/idea/proto/tcs/IdeaKotlinProjectCoordinates.kt b/libraries/tools/kotlin-gradle-plugin-idea-proto/src/main/kotlin/org/jetbrains/kotlin/gradle/idea/proto/tcs/IdeaKotlinProjectCoordinates.kt index 63a9ecd21f6..4bd0a967462 100644 --- a/libraries/tools/kotlin-gradle-plugin-idea-proto/src/main/kotlin/org/jetbrains/kotlin/gradle/idea/proto/tcs/IdeaKotlinProjectCoordinates.kt +++ b/libraries/tools/kotlin-gradle-plugin-idea-proto/src/main/kotlin/org/jetbrains/kotlin/gradle/idea/proto/tcs/IdeaKotlinProjectCoordinates.kt @@ -11,15 +11,28 @@ import org.jetbrains.kotlin.gradle.idea.tcs.IdeaKotlinProjectCoordinates internal fun IdeaKotlinProjectCoordinatesProto(coordinates: IdeaKotlinProjectCoordinates): IdeaKotlinProjectCoordinatesProto { return ideaKotlinProjectCoordinatesProto { - this.buildId = coordinates.buildId + this.buildName = coordinates.buildName + this.buildPath = coordinates.buildPath this.projectPath = coordinates.projectPath this.projectName = coordinates.projectName } } internal fun IdeaKotlinProjectCoordinates(proto: IdeaKotlinProjectCoordinatesProto): IdeaKotlinProjectCoordinates { - return IdeaKotlinProjectCoordinates( - buildId = proto.buildId, + return if (proto.hasBuildPath()) IdeaKotlinProjectCoordinates( + buildName = proto.buildName, + buildPath = proto.buildPath, + projectPath = proto.projectPath, + projectName = proto.projectName + ) + /* + Coordinates were encoded w/o 'buildPath'. + This can happen if e.g. the data was produced by an older Kotlin Gradle Plugin (before 1.9.20), + or if the Kotlin Gradle Plugin was used with older Gradle versions (before 8.2), where this information was not present. + In this case, we will create the coordinates using the approximation used before 1.9.20: buildName is used as 'buildId' + */ + else @Suppress("DEPRECATION") IdeaKotlinProjectCoordinates( + buildId = proto.buildName, projectPath = proto.projectPath, projectName = proto.projectName ) diff --git a/libraries/tools/kotlin-gradle-plugin-idea-proto/src/main/proto/proto_tcs.proto b/libraries/tools/kotlin-gradle-plugin-idea-proto/src/main/proto/proto_tcs.proto index ae5e3c3dbfe..2767927de06 100644 --- a/libraries/tools/kotlin-gradle-plugin-idea-proto/src/main/proto/proto_tcs.proto +++ b/libraries/tools/kotlin-gradle-plugin-idea-proto/src/main/proto/proto_tcs.proto @@ -49,7 +49,8 @@ message IdeaKotlinProjectArtifactDependencyProto { } message IdeaKotlinProjectCoordinatesProto { - optional string build_id = 1; + optional string build_name = 1; // Renamed from 'build_id' to 'build_name' in 1.9.20 + optional string build_path = 4; // Added in 1.9.20 optional string project_path = 2; optional string project_name = 3; } diff --git a/libraries/tools/kotlin-gradle-plugin-idea-proto/src/test/kotlin/org/jetbrains/kotlin/gradle/idea/proto/tcs/IdeaKotlinDependencyBackwardsCompatibilityTest.kt b/libraries/tools/kotlin-gradle-plugin-idea-proto/src/test/kotlin/org/jetbrains/kotlin/gradle/idea/proto/tcs/IdeaKotlinDependencyBackwardsCompatibilityTest.kt index 09eb952b829..ec10e8bc704 100644 --- a/libraries/tools/kotlin-gradle-plugin-idea-proto/src/test/kotlin/org/jetbrains/kotlin/gradle/idea/proto/tcs/IdeaKotlinDependencyBackwardsCompatibilityTest.kt +++ b/libraries/tools/kotlin-gradle-plugin-idea-proto/src/test/kotlin/org/jetbrains/kotlin/gradle/idea/proto/tcs/IdeaKotlinDependencyBackwardsCompatibilityTest.kt @@ -7,10 +7,7 @@ package org.jetbrains.kotlin.gradle.idea.proto.tcs import org.jetbrains.kotlin.gradle.idea.proto.classLoaderForBackwardsCompatibleClasses import org.jetbrains.kotlin.gradle.idea.serialize.IdeaKotlinSerializationLogger -import org.jetbrains.kotlin.gradle.idea.tcs.IdeaKotlinProjectArtifactDependency -import org.jetbrains.kotlin.gradle.idea.tcs.IdeaKotlinResolvedBinaryDependency -import org.jetbrains.kotlin.gradle.idea.tcs.IdeaKotlinSourceDependency -import org.jetbrains.kotlin.gradle.idea.tcs.IdeaKotlinUnresolvedBinaryDependency +import org.jetbrains.kotlin.gradle.idea.tcs.* import org.jetbrains.kotlin.gradle.idea.testFixtures.tcs.TestIdeaKotlinDependencySerializer import org.jetbrains.kotlin.gradle.idea.testFixtures.tcs.TestIdeaKotlinInstances import org.jetbrains.kotlin.gradle.idea.testFixtures.utils.copy @@ -54,8 +51,16 @@ class IdeaKotlinDependencyBackwardsCompatibilityTest { val deserializedCopied = deserialized.copy() assertEquals(dependency.type, deserializedCopied.type) - assertEquals(dependency.coordinates, deserializedCopied.coordinates) assertEquals(dependency.extras, deserializedCopied.extras) + + /* Check if coordinates are equals: Note the old class does not contain buildPath and buildName in project coordinates */ + run { + assertEquals(dependency.coordinates.sourceSetName, deserializedCopied.coordinates.sourceSetName) + assertProjectCoordinatesEquals( + dependency.coordinates.project, + deserialized.callMethod("getCoordinates").callMethod("getProject") + ) + } } @Test @@ -66,11 +71,24 @@ class IdeaKotlinDependencyBackwardsCompatibilityTest { val deserializedCopied = deserialized.copy() assertEquals(dependency.type, deserializedCopied.type) - assertEquals(dependency.coordinates, deserializedCopied.coordinates) assertEquals(dependency.extras, deserializedCopied.extras) + assertProjectCoordinatesEquals(dependency.coordinates, deserialized.callMethod("getCoordinates")) } } +private fun assertProjectCoordinatesEquals( + expected: IdeaKotlinProjectCoordinates, deserialized: Any, +) { + val deserializedBuildId = deserialized.callMethod("getBuildId") + val deserializedProjectPath = deserialized.callMethod("getProjectPath") + val deserializedProjectName = deserialized.callMethod("getProjectName") + @Suppress("DEPRECATION") + assertEquals(expected.buildId, deserializedBuildId) + assertEquals(expected.buildName, deserializedBuildId) + assertEquals(expected.projectPath, deserializedProjectPath) + assertEquals(expected.projectName, deserializedProjectName) +} + private fun deserializeIdeaKotlinDependencyWithBackwardsCompatibleClasses(project: ByteArray): Any { val classLoader = classLoaderForBackwardsCompatibleClasses() val serializer = TestIdeaKotlinDependencySerializer(classLoader) @@ -92,3 +110,5 @@ private fun deserializeIdeaKotlinDependencyWithBackwardsCompatibleClasses(projec return deserialized } + +private fun Any.callMethod(name: String) = javaClass.getDeclaredMethod(name).invoke(this) \ No newline at end of file diff --git a/libraries/tools/kotlin-gradle-plugin-idea-proto/src/test/kotlin/org/jetbrains/kotlin/gradle/idea/proto/tcs/IdeaKotlinProjectCoordinatesSerializationTest.kt b/libraries/tools/kotlin-gradle-plugin-idea-proto/src/test/kotlin/org/jetbrains/kotlin/gradle/idea/proto/tcs/IdeaKotlinProjectCoordinatesSerializationTest.kt new file mode 100644 index 00000000000..4cef00be7ac --- /dev/null +++ b/libraries/tools/kotlin-gradle-plugin-idea-proto/src/test/kotlin/org/jetbrains/kotlin/gradle/idea/proto/tcs/IdeaKotlinProjectCoordinatesSerializationTest.kt @@ -0,0 +1,41 @@ +/* + * Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.gradle.idea.proto.tcs + +import org.jetbrains.kotlin.gradle.idea.proto.AbstractSerializationTest +import org.jetbrains.kotlin.gradle.idea.proto.generated.tcs.IdeaKotlinProjectCoordinatesProto +import org.jetbrains.kotlin.gradle.idea.tcs.IdeaKotlinProjectCoordinates +import kotlin.test.Test + +class IdeaKotlinProjectCoordinatesSerializationTest : AbstractSerializationTest() { + override fun serialize(value: IdeaKotlinProjectCoordinates): ByteArray { + return IdeaKotlinProjectCoordinatesProto(value).toByteArray() + } + + override fun deserialize(data: ByteArray): IdeaKotlinProjectCoordinates { + return IdeaKotlinProjectCoordinates(IdeaKotlinProjectCoordinatesProto.parseFrom(data)) + } + + @Test + fun `test - only buildId provided`() = testSerialization( + @Suppress("DEPRECATION") + IdeaKotlinProjectCoordinates( + buildId = "myBuildId", + projectPath = "myProjectPath", + projectName = "myProjetName" + ) + ) + + @Test + fun `test - only buildPath and buildName provided`() = testSerialization( + IdeaKotlinProjectCoordinates( + buildPath = "myBuildId", + buildName = "myBuildName", + projectPath = "myProjectPath", + projectName = "myProjetName" + ) + ) +} \ No newline at end of file diff --git a/libraries/tools/kotlin-gradle-plugin-idea-proto/src/test/kotlin/org/jetbrains/kotlin/gradle/idea/proto/tcs/IdeaKotlinSourceCoordinatesSerializationTest.kt b/libraries/tools/kotlin-gradle-plugin-idea-proto/src/test/kotlin/org/jetbrains/kotlin/gradle/idea/proto/tcs/IdeaKotlinSourceCoordinatesSerializationTest.kt index b4eb89ec805..68fb66bbf6b 100644 --- a/libraries/tools/kotlin-gradle-plugin-idea-proto/src/test/kotlin/org/jetbrains/kotlin/gradle/idea/proto/tcs/IdeaKotlinSourceCoordinatesSerializationTest.kt +++ b/libraries/tools/kotlin-gradle-plugin-idea-proto/src/test/kotlin/org/jetbrains/kotlin/gradle/idea/proto/tcs/IdeaKotlinSourceCoordinatesSerializationTest.kt @@ -18,6 +18,7 @@ class IdeaKotlinSourceCoordinatesSerializationTest : AbstractSerializationTest (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V + public fun (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V public final fun component1 ()Ljava/lang/String; public final fun component2 ()Ljava/lang/String; public final fun component3 ()Ljava/lang/String; public final fun copy (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Lorg/jetbrains/kotlin/gradle/idea/tcs/IdeaKotlinProjectCoordinates; + public final fun copy (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Lorg/jetbrains/kotlin/gradle/idea/tcs/IdeaKotlinProjectCoordinates; public static synthetic fun copy$default (Lorg/jetbrains/kotlin/gradle/idea/tcs/IdeaKotlinProjectCoordinates;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ILjava/lang/Object;)Lorg/jetbrains/kotlin/gradle/idea/tcs/IdeaKotlinProjectCoordinates; + public static synthetic fun copy$default (Lorg/jetbrains/kotlin/gradle/idea/tcs/IdeaKotlinProjectCoordinates;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ILjava/lang/Object;)Lorg/jetbrains/kotlin/gradle/idea/tcs/IdeaKotlinProjectCoordinates; public fun equals (Ljava/lang/Object;)Z public final fun getBuildId ()Ljava/lang/String; + public final fun getBuildName ()Ljava/lang/String; + public final fun getBuildPath ()Ljava/lang/String; public final fun getProjectName ()Ljava/lang/String; public final fun getProjectPath ()Ljava/lang/String; public fun hashCode ()I @@ -477,6 +482,8 @@ public final class org/jetbrains/kotlin/gradle/idea/tcs/IdeaKotlinSourceCoordina public static synthetic fun copy$default (Lorg/jetbrains/kotlin/gradle/idea/tcs/IdeaKotlinSourceCoordinates;Lorg/jetbrains/kotlin/gradle/idea/tcs/IdeaKotlinProjectCoordinates;Ljava/lang/String;ILjava/lang/Object;)Lorg/jetbrains/kotlin/gradle/idea/tcs/IdeaKotlinSourceCoordinates; public fun equals (Ljava/lang/Object;)Z public final fun getBuildId ()Ljava/lang/String; + public final fun getBuildName ()Ljava/lang/String; + public final fun getBuildPath ()Ljava/lang/String; public final fun getProject ()Lorg/jetbrains/kotlin/gradle/idea/tcs/IdeaKotlinProjectCoordinates; public final fun getProjectName ()Ljava/lang/String; public final fun getProjectPath ()Ljava/lang/String; diff --git a/libraries/tools/kotlin-gradle-plugin-idea/src/main/kotlin/org/jetbrains/kotlin/gradle/idea/tcs/IdeaKotlinDependencyCoordinates.kt b/libraries/tools/kotlin-gradle-plugin-idea/src/main/kotlin/org/jetbrains/kotlin/gradle/idea/tcs/IdeaKotlinDependencyCoordinates.kt index e52c758768f..8a0467af288 100644 --- a/libraries/tools/kotlin-gradle-plugin-idea/src/main/kotlin/org/jetbrains/kotlin/gradle/idea/tcs/IdeaKotlinDependencyCoordinates.kt +++ b/libraries/tools/kotlin-gradle-plugin-idea/src/main/kotlin/org/jetbrains/kotlin/gradle/idea/tcs/IdeaKotlinDependencyCoordinates.kt @@ -213,13 +213,114 @@ class IdeaKotlinBinaryCoordinates( } } -data class IdeaKotlinProjectCoordinates( - val buildId: String, + +class IdeaKotlinProjectCoordinates( + val buildName: String, + val buildPath: String, val projectPath: String, val projectName: String, ) : Serializable, IdeaKotlinDependencyCoordinates { + + /** + * Keeping binary compatibility! + */ + @Deprecated("Use 'buildName' or 'buildPath' instead") + val buildId: String get() = buildName + + /** + * Keeping binary compatibility! + */ + @Deprecated("Use constructor with 'buildName' and 'buildPath' instead") + constructor( + buildId: String, + projectPath: String, + projectName: String, + ) : this( + buildName = buildId, + buildPath = if (buildId.startsWith(":")) buildId else ":$buildId", + projectPath = projectPath, + projectName = projectName + ) + + /** + * Keeping binary compatibility! + */ + @Suppress("DEPRECATION") + @Deprecated("Use copy method with 'buildName' and 'buildPath' instead", level = DeprecationLevel.ERROR) + fun copy( + buildId: String = this.buildId, + projectPath: String = this.projectPath, + projectName: String = this.projectName, + ): IdeaKotlinProjectCoordinates { + return if (this.buildId != buildId) { + IdeaKotlinProjectCoordinates( + buildId = buildId, + projectPath = projectPath, + projectName = projectName + ) + } else { + IdeaKotlinProjectCoordinates( + buildName = buildName, + buildPath = buildPath, + projectPath = projectPath, + projectName = projectName + ) + } + } + + /** + * Keeping binary compatibility! + */ + @Deprecated("Please reference the property directly!", level = DeprecationLevel.ERROR) + @Suppress("DEPRECATION") + operator fun component1() = buildId + + /** + * Keeping binary compatibility! + */ + @Deprecated("Please reference the property directly!", level = DeprecationLevel.ERROR) + operator fun component2() = projectPath + + /** + * Keeping binary compatibility! + */ + @Deprecated("Please reference the property directly!", level = DeprecationLevel.ERROR) + operator fun component3() = projectName + + fun copy( + buildName: String = this.buildName, + buildPath: String = this.buildPath, + projectPath: String = this.projectPath, + projectName: String = this.projectName, + ): IdeaKotlinProjectCoordinates { + return IdeaKotlinProjectCoordinates( + buildName = buildName, + buildPath = buildPath, + projectPath = projectPath, + projectName = projectName + ) + } + + override fun equals(other: Any?): Boolean { + if (this === other) return true + if (other !is IdeaKotlinProjectCoordinates) return false + if (other.buildName != this.buildName) return false + if (other.buildPath != this.buildPath) return false + if (other.projectPath != this.projectPath) return false + if (other.projectName != this.projectName) return false + return true + } + + override fun hashCode(): Int { + var result = buildName.hashCode() + result = 31 * result + buildPath.hashCode() + result = 31 * result + projectPath.hashCode() + result = 31 * result + projectName.hashCode() + return result + } + override fun toString(): String { - return "${buildId.takeIf { it != ":" }?.plus(":").orEmpty()}$projectPath" + return "${projectPath.takeIf { it != ":" }?.plus(":").orEmpty()}$projectPath" } internal companion object { @@ -232,7 +333,11 @@ data class IdeaKotlinSourceCoordinates( val sourceSetName: String, ) : IdeaKotlinDependencyCoordinates { + @Deprecated("Use 'buildPath' instead") + @Suppress("DEPRECATION") val buildId: String get() = project.buildId + val buildName: String get() = project.buildName + val buildPath: String get() = project.buildPath val projectPath: String get() = project.projectPath val projectName: String get() = project.projectName diff --git a/libraries/tools/kotlin-gradle-plugin-idea/src/testFixtures/kotlin/org/jetbrains/kotlin/gradle/idea/testFixtures/tcs/IdeaKotlinSourceDependencyMatcher.kt b/libraries/tools/kotlin-gradle-plugin-idea/src/testFixtures/kotlin/org/jetbrains/kotlin/gradle/idea/testFixtures/tcs/IdeaKotlinSourceDependencyMatcher.kt index 4edd24cb9aa..05a3f187190 100644 --- a/libraries/tools/kotlin-gradle-plugin-idea/src/testFixtures/kotlin/org/jetbrains/kotlin/gradle/idea/testFixtures/tcs/IdeaKotlinSourceDependencyMatcher.kt +++ b/libraries/tools/kotlin-gradle-plugin-idea/src/testFixtures/kotlin/org/jetbrains/kotlin/gradle/idea/testFixtures/tcs/IdeaKotlinSourceDependencyMatcher.kt @@ -10,7 +10,7 @@ import org.jetbrains.kotlin.gradle.idea.tcs.IdeaKotlinSourceDependency internal class IdeaKotlinSourceDependencyMatcher( val type: IdeaKotlinSourceDependency.Type, - val buildId: String, + val buildName: String, val projectPath: String, val sourceSetName: String ) : IdeaKotlinDependencyMatcher { @@ -20,9 +20,8 @@ internal class IdeaKotlinSourceDependencyMatcher( override fun matches(dependency: IdeaKotlinDependency): Boolean { if (dependency !is IdeaKotlinSourceDependency) return false return dependency.type == type && - dependency.coordinates.buildId == buildId && + dependency.coordinates.buildName == buildName && dependency.coordinates.projectPath == projectPath && dependency.coordinates.sourceSetName == sourceSetName } } - diff --git a/libraries/tools/kotlin-gradle-plugin-idea/src/testFixtures/kotlin/org/jetbrains/kotlin/gradle/idea/testFixtures/tcs/TestIdeaKotlinInstances.kt b/libraries/tools/kotlin-gradle-plugin-idea/src/testFixtures/kotlin/org/jetbrains/kotlin/gradle/idea/testFixtures/tcs/TestIdeaKotlinInstances.kt index 069034b08e1..abcb1a6d5bd 100644 --- a/libraries/tools/kotlin-gradle-plugin-idea/src/testFixtures/kotlin/org/jetbrains/kotlin/gradle/idea/testFixtures/tcs/TestIdeaKotlinInstances.kt +++ b/libraries/tools/kotlin-gradle-plugin-idea/src/testFixtures/kotlin/org/jetbrains/kotlin/gradle/idea/testFixtures/tcs/TestIdeaKotlinInstances.kt @@ -19,6 +19,7 @@ object TestIdeaKotlinInstances { extrasKeyOf() withValue "Cash" ) + @Suppress("DEPRECATION") val simpleProjectCoordinates = IdeaKotlinProjectCoordinates( buildId = "myBuildId", projectPath = "my:project:path",