diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 68473d1afd..4a9749c317 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -150,7 +150,7 @@ jobs: run: | ./gradlew generateSwiftTests --stacktrace --warning-mode all if [ ! -z "$(git status --porcelain)" ]; then git diff; echo -e "\nGenerated files changed. Did you run ./gradlew generateSwiftProtos and generateSwiftTests?"; exit 1; fi - ./gradlew :wire-tests-swift:build --stacktrace --warning-mode all + ./gradlew -p wire-tests-swift build --stacktrace --warning-mode all - name: Test Swift Package Manager run: swift test diff --git a/.gitignore b/.gitignore index 9edc6c3181..186f3dcc75 100644 --- a/.gitignore +++ b/.gitignore @@ -20,6 +20,9 @@ gradlew.bat # Maven plugin*.xml +# SPM +.build + # Special Mkdocs files docs/3.x docs/changelog.md diff --git a/Package.swift b/Package.swift index a1af1b8153..cd45ff78f0 100644 --- a/Package.swift +++ b/Package.swift @@ -31,12 +31,12 @@ let package = Package( .target( name: "WireTests", dependencies: ["Wire"], - path: "wire-tests-swift/src/main/swift" + path: "wire-tests-swift/no-manifest/src/main/swift" ), .testTarget( name: "WireCompilerTests", dependencies: ["WireTests"], - path: "wire-tests-swift/src/test/swift" + path: "wire-tests-swift/no-manifest/src/test/swift" ), ], swiftLanguageVersions: [.v5] diff --git a/build.gradle.kts b/build.gradle.kts index 73e31c2ed1..f695c60c31 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -60,7 +60,11 @@ allprojects { subprojects { if (name != "wire-golden-files" && name != "wire-tests-proto3-swift" && - name != "wire-tests-swift" + name != "wire-tests-swift" && + name != "no-manifest" && + name != "module_one" && + name != "module_two" && + name != "module_three" ) { apply(plugin = "com.diffplug.spotless") configure { @@ -143,7 +147,8 @@ subprojects { project.name.endsWith("-benchmarks") || project.name.contains("golden") || project.name.contains("protoc") || - project.displayName.contains("sample") + project.displayName.contains("sample") || + project.displayName.contains("wire-tests-swift") ) ) { apply(plugin = "checkstyle") diff --git a/gen-tests.gradle.kts b/gen-tests.gradle.kts index cb71778d8e..5bff382f9a 100644 --- a/gen-tests.gradle.kts +++ b/gen-tests.gradle.kts @@ -414,8 +414,25 @@ val generateSwiftProto3Tests by tasks.creating(JavaExec::class) { ) } +val generateSwiftProto2ManifestTests by tasks.creating(JavaExec::class) { + val swiftOut = "wire-tests-swift/manifest" + + group = "Generate Tests" + description = "Generates Swift classes from the test protos using a manifest" + classpath = wire + mainClass.set("com.squareup.wire.WireCompiler") + args = listOf( + "--proto_path=wire-tests/src/commonTest/proto/kotlin", + "--swift_out=$swiftOut", + "--experimental-module-manifest=wire-tests/src/commonTest/proto/kotlin/swift_modules_manifest.yaml", + "swift_module_one.proto", + "swift_module_two.proto", + "swift_module_three.proto", + ) +} + val generateSwiftProto2Tests by tasks.creating(JavaExec::class) { - val swiftOut = "wire-tests-swift/src/main/swift/" + val swiftOut = "wire-tests-swift/no-manifest/src/main/swift" doFirst { val outFile = file(swiftOut) outFile.deleteRecursively() @@ -461,6 +478,7 @@ val generateSwiftTests by tasks.creating { group = "Generate Tests" description = "Generates Swift classes from the test protos" dependsOn( + generateSwiftProto2ManifestTests, generateSwiftProto2Tests, generateSwiftProto3Tests, ":wire-runtime-swift:generateTestProtos" diff --git a/settings.gradle.kts b/settings.gradle.kts index 48a2aeebb8..d2d37c9322 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -22,6 +22,10 @@ include(":wire-tests") if (startParameter.projectProperties.get("swift") != "false") { include(":wire-runtime-swift") include(":wire-tests-swift") + include(":wire-tests-swift:no-manifest") + include(":wire-tests-swift:manifest:module_one") + include(":wire-tests-swift:manifest:module_two") + include(":wire-tests-swift:manifest:module_three") include(":wire-tests-proto3-swift") } diff --git a/wire-swift-generator/src/main/java/com/squareup/wire/swift/SwiftGenerator.kt b/wire-swift-generator/src/main/java/com/squareup/wire/swift/SwiftGenerator.kt index a859697dea..dc2ceaedad 100644 --- a/wire-swift-generator/src/main/java/com/squareup/wire/swift/SwiftGenerator.kt +++ b/wire-swift-generator/src/main/java/com/squareup/wire/swift/SwiftGenerator.kt @@ -1206,6 +1206,13 @@ class SwiftGenerator private constructor( if (typeName is DeclaredTypeName) { imports.add(typeName.moduleName) } + if (typeName is ParameterizedTypeName) { + typeName.typeArguments.forEach { declaredTypeName -> + if (declaredTypeName is DeclaredTypeName) { + imports.add(declaredTypeName.moduleName) + } + } + } val property = PropertySpec.varBuilder(field.name, field.typeName, visibility) if (!forStorageType && field.documentation.isNotBlank()) { diff --git a/wire-tests-swift/build.gradle.kts b/wire-tests-swift/build.gradle.kts index f01a9c90aa..affc84d95e 100644 --- a/wire-tests-swift/build.gradle.kts +++ b/wire-tests-swift/build.gradle.kts @@ -1,32 +1,20 @@ -plugins { - id("swift-library") - id("xcode") - id("xctest") -} - -library { - dependencies { - api(projects.wireRuntimeSwift) - } - - module.set("WireTests") -} - -afterEvaluate { - tasks.withType(SwiftCompile::class).all { - // Include the ${DEVELOPER_DIR}/usr/lib as we also need to use libXCTestSwiftSupport.dylib as of - // Xcode 12.5: - // https://forums.swift.org/t/why-xcode-12-5b-cannot-find-xctassertequal-in-scope-in-playground/44411 - val developerDir = compilerArgs.get().extractDeveloperDir() ?: return@all - compilerArgs.add("-I$developerDir/usr/lib") - } +subprojects { + afterEvaluate { + tasks.withType(SwiftCompile::class).all { + // Include the ${DEVELOPER_DIR}/usr/lib as we also need to use libXCTestSwiftSupport.dylib as of + // Xcode 12.5: + // https://forums.swift.org/t/why-xcode-12-5b-cannot-find-xctassertequal-in-scope-in-playground/44411 + val developerDir = compilerArgs.get().extractDeveloperDir() ?: return@all + compilerArgs.add("-I$developerDir/usr/lib") + } - tasks.withType(LinkMachOBundle::class).all { - // Include the ${DEVELOPER_DIR}/usr/lib as we also need to use libXCTestSwiftSupport.dylib as of - // Xcode 12.5: - // https://forums.swift.org/t/why-xcode-12-5b-cannot-find-xctassertequal-in-scope-in-playground/44411 - val developerDir = linkerArgs.get().extractDeveloperDir() ?: return@all - linkerArgs.add("-L$developerDir/usr/lib") + tasks.withType(LinkMachOBundle::class).all { + // Include the ${DEVELOPER_DIR}/usr/lib as we also need to use libXCTestSwiftSupport.dylib as of + // Xcode 12.5: + // https://forums.swift.org/t/why-xcode-12-5b-cannot-find-xctassertequal-in-scope-in-playground/44411 + val developerDir = linkerArgs.get().extractDeveloperDir() ?: return@all + linkerArgs.add("-L$developerDir/usr/lib") + } } } diff --git a/wire-tests-swift/manifest/module_one/SwiftModuleOneType.swift b/wire-tests-swift/manifest/module_one/SwiftModuleOneType.swift new file mode 100644 index 0000000000..7ade0670aa --- /dev/null +++ b/wire-tests-swift/manifest/module_one/SwiftModuleOneType.swift @@ -0,0 +1,25 @@ +// Code generated by Wire protocol buffer compiler, do not edit. +// Source: squareup.protos.kotlin.swift_modules.SwiftModuleOneType in swift_module_one.proto +import Foundation +import Wire + +public enum SwiftModuleOneType : UInt32, CaseIterable, ProtoEnum { + + case DO_NOT_USE = 0 + case ONE = 1 + case TWO = 2 + + public var description: String { + switch self { + case .DO_NOT_USE: return "DO_NOT_USE" + case .ONE: return "ONE" + case .TWO: return "TWO" + } + } + +} + +#if swift(>=5.5) +extension SwiftModuleOneType : Sendable { +} +#endif diff --git a/wire-tests-swift/manifest/module_one/build.gradle.kts b/wire-tests-swift/manifest/module_one/build.gradle.kts new file mode 100644 index 0000000000..bb75712b26 --- /dev/null +++ b/wire-tests-swift/manifest/module_one/build.gradle.kts @@ -0,0 +1,15 @@ +plugins { + id("swift-library") + id("xcode") + id("xctest") +} + +library { + dependencies { + api(projects.wireRuntimeSwift) + } + + module.set("module_one") + + source.from(file(".")) +} diff --git a/wire-tests-swift/manifest/module_three/SwiftModuleThreeMessage.swift b/wire-tests-swift/manifest/module_three/SwiftModuleThreeMessage.swift new file mode 100644 index 0000000000..2b4148a284 --- /dev/null +++ b/wire-tests-swift/manifest/module_three/SwiftModuleThreeMessage.swift @@ -0,0 +1,190 @@ +// Code generated by Wire protocol buffer compiler, do not edit. +// Source: squareup.protos.kotlin.swift_modules.SwiftModuleThreeMessage in swift_module_three.proto +import Foundation +import Wire +import module_one + +public struct SwiftModuleThreeMessage { + + public var name: String? + public var unknownFields: Foundation.Data = .init() + + public init(configure: (inout Self) -> Swift.Void = { _ in }) { + configure(&self) + } + +} + +#if WIRE_INCLUDE_MEMBERWISE_INITIALIZER +extension SwiftModuleThreeMessage { + + @_disfavoredOverload + @available(*, deprecated) + public init(name: Swift.String? = nil) { + self.name = name + } + +} +#endif + +#if !WIRE_REMOVE_EQUATABLE +extension SwiftModuleThreeMessage : Equatable { +} +#endif + +#if !WIRE_REMOVE_HASHABLE +extension SwiftModuleThreeMessage : Hashable { +} +#endif + +#if swift(>=5.5) +extension SwiftModuleThreeMessage : Sendable { +} +#endif + +extension SwiftModuleThreeMessage : ProtoMessage { + + public static func protoMessageTypeURL() -> Swift.String { + return "type.googleapis.com/squareup.protos.kotlin.swift_modules.SwiftModuleThreeMessage" + } + +} + +extension SwiftModuleThreeMessage : Proto2Codable { + + public init(from protoReader: Wire.ProtoReader) throws { + var name: Swift.String? = nil + + let token = try protoReader.beginMessage() + while let tag = try protoReader.nextTag(token: token) { + switch tag { + case 1: name = try protoReader.decode(Swift.String.self) + default: try protoReader.readUnknownField(tag: tag) + } + } + self.unknownFields = try protoReader.endMessage(token: token) + + self.name = name + } + + public func encode(to protoWriter: Wire.ProtoWriter) throws { + try protoWriter.encode(tag: 1, value: self.name) + try protoWriter.writeUnknownFields(unknownFields) + } + +} + +#if !WIRE_REMOVE_CODABLE +extension SwiftModuleThreeMessage : Codable { + + public init(from decoder: Swift.Decoder) throws { + let container = try decoder.container(keyedBy: Wire.StringLiteralCodingKeys.self) + self.name = try container.decodeIfPresent(Swift.String.self, forKey: "name") + } + + public func encode(to encoder: Swift.Encoder) throws { + var container = encoder.container(keyedBy: Wire.StringLiteralCodingKeys.self) + + try container.encodeIfPresent(self.name, forKey: "name") + } + +} +#endif + +/** + * Subtypes within SwiftModuleThreeMessage + */ +extension SwiftModuleThreeMessage { + + public struct NestedMessage { + + public var map_string_types: [Swift.String : module_one.SwiftModuleOneType] = [:] + public var unknownFields: Foundation.Data = .init() + + public init(configure: (inout Self) -> Swift.Void = { _ in }) { + configure(&self) + } + + } + +} + +#if WIRE_INCLUDE_MEMBERWISE_INITIALIZER +extension SwiftModuleThreeMessage.NestedMessage { + + @_disfavoredOverload + @available(*, deprecated) + public init(map_string_types: [Swift.String : module_one.SwiftModuleOneType] = [:]) { + self.map_string_types = map_string_types + } + +} +#endif + +#if !WIRE_REMOVE_EQUATABLE +extension SwiftModuleThreeMessage.NestedMessage : Equatable { +} +#endif + +#if !WIRE_REMOVE_HASHABLE +extension SwiftModuleThreeMessage.NestedMessage : Hashable { +} +#endif + +#if swift(>=5.5) +extension SwiftModuleThreeMessage.NestedMessage : Sendable { +} +#endif + +extension SwiftModuleThreeMessage.NestedMessage : ProtoMessage { + + public static func protoMessageTypeURL() -> Swift.String { + return "type.googleapis.com/squareup.protos.kotlin.swift_modules.SwiftModuleThreeMessage.NestedMessage" + } + +} + +extension SwiftModuleThreeMessage.NestedMessage : Proto2Codable { + + public init(from protoReader: Wire.ProtoReader) throws { + var map_string_types: [Swift.String : module_one.SwiftModuleOneType] = [:] + + let token = try protoReader.beginMessage() + while let tag = try protoReader.nextTag(token: token) { + switch tag { + case 2: try protoReader.decode(into: &map_string_types) + default: try protoReader.readUnknownField(tag: tag) + } + } + self.unknownFields = try protoReader.endMessage(token: token) + + self.map_string_types = map_string_types + } + + public func encode(to protoWriter: Wire.ProtoWriter) throws { + try protoWriter.encode(tag: 2, value: self.map_string_types) + try protoWriter.writeUnknownFields(unknownFields) + } + +} + +#if !WIRE_REMOVE_CODABLE +extension SwiftModuleThreeMessage.NestedMessage : Codable { + + public init(from decoder: Swift.Decoder) throws { + let container = try decoder.container(keyedBy: Wire.StringLiteralCodingKeys.self) + self.map_string_types = try container.decodeProtoMap([Swift.String : module_one.SwiftModuleOneType].self, firstOfKeys: "mapStringTypes", "map_string_types") + } + + public func encode(to encoder: Swift.Encoder) throws { + var container = encoder.container(keyedBy: Wire.StringLiteralCodingKeys.self) + let preferCamelCase = encoder.protoKeyNameEncodingStrategy == .camelCase + let includeDefaults = encoder.protoDefaultValuesEncodingStrategy == .include + + if includeDefaults || !self.map_string_types.isEmpty { + try container.encodeProtoMap(self.map_string_types, forKey: preferCamelCase ? "mapStringTypes" : "map_string_types") + } + } + +} +#endif diff --git a/wire-tests-swift/manifest/module_three/build.gradle.kts b/wire-tests-swift/manifest/module_three/build.gradle.kts new file mode 100644 index 0000000000..372b654efd --- /dev/null +++ b/wire-tests-swift/manifest/module_three/build.gradle.kts @@ -0,0 +1,16 @@ +plugins { + id("swift-library") + id("xcode") + id("xctest") +} + +library { + dependencies { + api(projects.wireRuntimeSwift) + implementation(projects.wireTestsSwift.manifest.moduleOne) + } + + module.set("module_three") + + source.from(file(".")) +} diff --git a/wire-tests-swift/manifest/module_two/SwiftModuleTwoMessage.swift b/wire-tests-swift/manifest/module_two/SwiftModuleTwoMessage.swift new file mode 100644 index 0000000000..bcf34c5ad6 --- /dev/null +++ b/wire-tests-swift/manifest/module_two/SwiftModuleTwoMessage.swift @@ -0,0 +1,189 @@ +// Code generated by Wire protocol buffer compiler, do not edit. +// Source: squareup.protos.kotlin.swift_modules.SwiftModuleTwoMessage in swift_module_two.proto +import Foundation +import Wire +import module_one + +public struct SwiftModuleTwoMessage { + + public var name: String? + public var unknownFields: Foundation.Data = .init() + + public init(configure: (inout Self) -> Swift.Void = { _ in }) { + configure(&self) + } + +} + +#if WIRE_INCLUDE_MEMBERWISE_INITIALIZER +extension SwiftModuleTwoMessage { + + @_disfavoredOverload + @available(*, deprecated) + public init(name: Swift.String? = nil) { + self.name = name + } + +} +#endif + +#if !WIRE_REMOVE_EQUATABLE +extension SwiftModuleTwoMessage : Equatable { +} +#endif + +#if !WIRE_REMOVE_HASHABLE +extension SwiftModuleTwoMessage : Hashable { +} +#endif + +#if swift(>=5.5) +extension SwiftModuleTwoMessage : Sendable { +} +#endif + +extension SwiftModuleTwoMessage : ProtoMessage { + + public static func protoMessageTypeURL() -> Swift.String { + return "type.googleapis.com/squareup.protos.kotlin.swift_modules.SwiftModuleTwoMessage" + } + +} + +extension SwiftModuleTwoMessage : Proto2Codable { + + public init(from protoReader: Wire.ProtoReader) throws { + var name: Swift.String? = nil + + let token = try protoReader.beginMessage() + while let tag = try protoReader.nextTag(token: token) { + switch tag { + case 1: name = try protoReader.decode(Swift.String.self) + default: try protoReader.readUnknownField(tag: tag) + } + } + self.unknownFields = try protoReader.endMessage(token: token) + + self.name = name + } + + public func encode(to protoWriter: Wire.ProtoWriter) throws { + try protoWriter.encode(tag: 1, value: self.name) + try protoWriter.writeUnknownFields(unknownFields) + } + +} + +#if !WIRE_REMOVE_CODABLE +extension SwiftModuleTwoMessage : Codable { + + public init(from decoder: Swift.Decoder) throws { + let container = try decoder.container(keyedBy: Wire.StringLiteralCodingKeys.self) + self.name = try container.decodeIfPresent(Swift.String.self, forKey: "name") + } + + public func encode(to encoder: Swift.Encoder) throws { + var container = encoder.container(keyedBy: Wire.StringLiteralCodingKeys.self) + + try container.encodeIfPresent(self.name, forKey: "name") + } + +} +#endif + +/** + * Subtypes within SwiftModuleTwoMessage + */ +extension SwiftModuleTwoMessage { + + public struct NestedMessage { + + public var types: [module_one.SwiftModuleOneType] = [] + public var unknownFields: Foundation.Data = .init() + + public init(configure: (inout Self) -> Swift.Void = { _ in }) { + configure(&self) + } + + } + +} + +#if WIRE_INCLUDE_MEMBERWISE_INITIALIZER +extension SwiftModuleTwoMessage.NestedMessage { + + @_disfavoredOverload + @available(*, deprecated) + public init(types: [module_one.SwiftModuleOneType] = []) { + self.types = types + } + +} +#endif + +#if !WIRE_REMOVE_EQUATABLE +extension SwiftModuleTwoMessage.NestedMessage : Equatable { +} +#endif + +#if !WIRE_REMOVE_HASHABLE +extension SwiftModuleTwoMessage.NestedMessage : Hashable { +} +#endif + +#if swift(>=5.5) +extension SwiftModuleTwoMessage.NestedMessage : Sendable { +} +#endif + +extension SwiftModuleTwoMessage.NestedMessage : ProtoMessage { + + public static func protoMessageTypeURL() -> Swift.String { + return "type.googleapis.com/squareup.protos.kotlin.swift_modules.SwiftModuleTwoMessage.NestedMessage" + } + +} + +extension SwiftModuleTwoMessage.NestedMessage : Proto2Codable { + + public init(from protoReader: Wire.ProtoReader) throws { + var types: [module_one.SwiftModuleOneType] = [] + + let token = try protoReader.beginMessage() + while let tag = try protoReader.nextTag(token: token) { + switch tag { + case 2: try protoReader.decode(into: &types) + default: try protoReader.readUnknownField(tag: tag) + } + } + self.unknownFields = try protoReader.endMessage(token: token) + + self.types = types + } + + public func encode(to protoWriter: Wire.ProtoWriter) throws { + try protoWriter.encode(tag: 2, value: self.types) + try protoWriter.writeUnknownFields(unknownFields) + } + +} + +#if !WIRE_REMOVE_CODABLE +extension SwiftModuleTwoMessage.NestedMessage : Codable { + + public init(from decoder: Swift.Decoder) throws { + let container = try decoder.container(keyedBy: Wire.StringLiteralCodingKeys.self) + self.types = try container.decodeProtoArray(module_one.SwiftModuleOneType.self, forKey: "types") + } + + public func encode(to encoder: Swift.Encoder) throws { + var container = encoder.container(keyedBy: Wire.StringLiteralCodingKeys.self) + let includeDefaults = encoder.protoDefaultValuesEncodingStrategy == .include + + if includeDefaults || !self.types.isEmpty { + try container.encodeProtoArray(self.types, forKey: "types") + } + } + +} +#endif diff --git a/wire-tests-swift/manifest/module_two/build.gradle.kts b/wire-tests-swift/manifest/module_two/build.gradle.kts new file mode 100644 index 0000000000..324a6412a5 --- /dev/null +++ b/wire-tests-swift/manifest/module_two/build.gradle.kts @@ -0,0 +1,16 @@ +plugins { + id("swift-library") + id("xcode") + id("xctest") +} + +library { + dependencies { + api(projects.wireRuntimeSwift) + implementation(projects.wireTestsSwift.manifest.moduleOne) + } + + module.set("module_two") + + source.from(file(".")) +} diff --git a/wire-tests-swift/no-manifest/build.gradle.kts b/wire-tests-swift/no-manifest/build.gradle.kts new file mode 100644 index 0000000000..e0d24f438e --- /dev/null +++ b/wire-tests-swift/no-manifest/build.gradle.kts @@ -0,0 +1,13 @@ +plugins { + id("swift-library") + id("xcode") + id("xctest") +} + +library { + dependencies { + api(projects.wireRuntimeSwift) + } + + module.set("WireTests") +} diff --git a/wire-tests-swift/src/main/swift/AllTypes.swift b/wire-tests-swift/no-manifest/src/main/swift/AllTypes.swift similarity index 100% rename from wire-tests-swift/src/main/swift/AllTypes.swift rename to wire-tests-swift/no-manifest/src/main/swift/AllTypes.swift diff --git a/wire-tests-swift/src/main/swift/DeprecatedEnum.swift b/wire-tests-swift/no-manifest/src/main/swift/DeprecatedEnum.swift similarity index 100% rename from wire-tests-swift/src/main/swift/DeprecatedEnum.swift rename to wire-tests-swift/no-manifest/src/main/swift/DeprecatedEnum.swift diff --git a/wire-tests-swift/src/main/swift/DeprecatedProto.swift b/wire-tests-swift/no-manifest/src/main/swift/DeprecatedProto.swift similarity index 100% rename from wire-tests-swift/src/main/swift/DeprecatedProto.swift rename to wire-tests-swift/no-manifest/src/main/swift/DeprecatedProto.swift diff --git a/wire-tests-swift/src/main/swift/EmbeddedMessage.swift b/wire-tests-swift/no-manifest/src/main/swift/EmbeddedMessage.swift similarity index 100% rename from wire-tests-swift/src/main/swift/EmbeddedMessage.swift rename to wire-tests-swift/no-manifest/src/main/swift/EmbeddedMessage.swift diff --git a/wire-tests-swift/src/main/swift/EnumVersionOne.swift b/wire-tests-swift/no-manifest/src/main/swift/EnumVersionOne.swift similarity index 100% rename from wire-tests-swift/src/main/swift/EnumVersionOne.swift rename to wire-tests-swift/no-manifest/src/main/swift/EnumVersionOne.swift diff --git a/wire-tests-swift/src/main/swift/EnumVersionTwo.swift b/wire-tests-swift/no-manifest/src/main/swift/EnumVersionTwo.swift similarity index 100% rename from wire-tests-swift/src/main/swift/EnumVersionTwo.swift rename to wire-tests-swift/no-manifest/src/main/swift/EnumVersionTwo.swift diff --git a/wire-tests-swift/src/main/swift/ExternalMessage.swift b/wire-tests-swift/no-manifest/src/main/swift/ExternalMessage.swift similarity index 100% rename from wire-tests-swift/src/main/swift/ExternalMessage.swift rename to wire-tests-swift/no-manifest/src/main/swift/ExternalMessage.swift diff --git a/wire-tests-swift/src/main/swift/FooBar.swift b/wire-tests-swift/no-manifest/src/main/swift/FooBar.swift similarity index 100% rename from wire-tests-swift/src/main/swift/FooBar.swift rename to wire-tests-swift/no-manifest/src/main/swift/FooBar.swift diff --git a/wire-tests-swift/src/main/swift/ForeignEnum.swift b/wire-tests-swift/no-manifest/src/main/swift/ForeignEnum.swift similarity index 100% rename from wire-tests-swift/src/main/swift/ForeignEnum.swift rename to wire-tests-swift/no-manifest/src/main/swift/ForeignEnum.swift diff --git a/wire-tests-swift/src/main/swift/ForeignMessage.swift b/wire-tests-swift/no-manifest/src/main/swift/ForeignMessage.swift similarity index 100% rename from wire-tests-swift/src/main/swift/ForeignMessage.swift rename to wire-tests-swift/no-manifest/src/main/swift/ForeignMessage.swift diff --git a/wire-tests-swift/src/main/swift/Form.swift b/wire-tests-swift/no-manifest/src/main/swift/Form.swift similarity index 100% rename from wire-tests-swift/src/main/swift/Form.swift rename to wire-tests-swift/no-manifest/src/main/swift/Form.swift diff --git a/wire-tests-swift/src/main/swift/Mappy.swift b/wire-tests-swift/no-manifest/src/main/swift/Mappy.swift similarity index 100% rename from wire-tests-swift/src/main/swift/Mappy.swift rename to wire-tests-swift/no-manifest/src/main/swift/Mappy.swift diff --git a/wire-tests-swift/src/main/swift/MappyTwo.swift b/wire-tests-swift/no-manifest/src/main/swift/MappyTwo.swift similarity index 100% rename from wire-tests-swift/src/main/swift/MappyTwo.swift rename to wire-tests-swift/no-manifest/src/main/swift/MappyTwo.swift diff --git a/wire-tests-swift/src/main/swift/MessageUsingMultipleEnums.swift b/wire-tests-swift/no-manifest/src/main/swift/MessageUsingMultipleEnums.swift similarity index 100% rename from wire-tests-swift/src/main/swift/MessageUsingMultipleEnums.swift rename to wire-tests-swift/no-manifest/src/main/swift/MessageUsingMultipleEnums.swift diff --git a/wire-tests-swift/src/main/swift/MessageWithOptions.swift b/wire-tests-swift/no-manifest/src/main/swift/MessageWithOptions.swift similarity index 100% rename from wire-tests-swift/src/main/swift/MessageWithOptions.swift rename to wire-tests-swift/no-manifest/src/main/swift/MessageWithOptions.swift diff --git a/wire-tests-swift/src/main/swift/MessageWithStatus.swift b/wire-tests-swift/no-manifest/src/main/swift/MessageWithStatus.swift similarity index 100% rename from wire-tests-swift/src/main/swift/MessageWithStatus.swift rename to wire-tests-swift/no-manifest/src/main/swift/MessageWithStatus.swift diff --git a/wire-tests-swift/src/main/swift/ModelEvaluation.swift b/wire-tests-swift/no-manifest/src/main/swift/ModelEvaluation.swift similarity index 100% rename from wire-tests-swift/src/main/swift/ModelEvaluation.swift rename to wire-tests-swift/no-manifest/src/main/swift/ModelEvaluation.swift diff --git a/wire-tests-swift/src/main/swift/NestedVersionOne.swift b/wire-tests-swift/no-manifest/src/main/swift/NestedVersionOne.swift similarity index 100% rename from wire-tests-swift/src/main/swift/NestedVersionOne.swift rename to wire-tests-swift/no-manifest/src/main/swift/NestedVersionOne.swift diff --git a/wire-tests-swift/src/main/swift/NestedVersionTwo.swift b/wire-tests-swift/no-manifest/src/main/swift/NestedVersionTwo.swift similarity index 100% rename from wire-tests-swift/src/main/swift/NestedVersionTwo.swift rename to wire-tests-swift/no-manifest/src/main/swift/NestedVersionTwo.swift diff --git a/wire-tests-swift/src/main/swift/NoFields.swift b/wire-tests-swift/no-manifest/src/main/swift/NoFields.swift similarity index 100% rename from wire-tests-swift/src/main/swift/NoFields.swift rename to wire-tests-swift/no-manifest/src/main/swift/NoFields.swift diff --git a/wire-tests-swift/src/main/swift/OneOfMessage.swift b/wire-tests-swift/no-manifest/src/main/swift/OneOfMessage.swift similarity index 100% rename from wire-tests-swift/src/main/swift/OneOfMessage.swift rename to wire-tests-swift/no-manifest/src/main/swift/OneOfMessage.swift diff --git a/wire-tests-swift/src/main/swift/OptionalEnumUser.swift b/wire-tests-swift/no-manifest/src/main/swift/OptionalEnumUser.swift similarity index 100% rename from wire-tests-swift/src/main/swift/OptionalEnumUser.swift rename to wire-tests-swift/no-manifest/src/main/swift/OptionalEnumUser.swift diff --git a/wire-tests-swift/src/main/swift/OtherMessageWithStatus.swift b/wire-tests-swift/no-manifest/src/main/swift/OtherMessageWithStatus.swift similarity index 100% rename from wire-tests-swift/src/main/swift/OtherMessageWithStatus.swift rename to wire-tests-swift/no-manifest/src/main/swift/OtherMessageWithStatus.swift diff --git a/wire-tests-swift/src/main/swift/OuterMessage.swift b/wire-tests-swift/no-manifest/src/main/swift/OuterMessage.swift similarity index 100% rename from wire-tests-swift/src/main/swift/OuterMessage.swift rename to wire-tests-swift/no-manifest/src/main/swift/OuterMessage.swift diff --git a/wire-tests-swift/src/main/swift/Percents.swift b/wire-tests-swift/no-manifest/src/main/swift/Percents.swift similarity index 100% rename from wire-tests-swift/src/main/swift/Percents.swift rename to wire-tests-swift/no-manifest/src/main/swift/Percents.swift diff --git a/wire-tests-swift/src/main/swift/Person.swift b/wire-tests-swift/no-manifest/src/main/swift/Person.swift similarity index 100% rename from wire-tests-swift/src/main/swift/Person.swift rename to wire-tests-swift/no-manifest/src/main/swift/Person.swift diff --git a/wire-tests-swift/src/main/swift/RedactedOneOf.swift b/wire-tests-swift/no-manifest/src/main/swift/RedactedOneOf.swift similarity index 100% rename from wire-tests-swift/src/main/swift/RedactedOneOf.swift rename to wire-tests-swift/no-manifest/src/main/swift/RedactedOneOf.swift diff --git a/wire-tests-swift/src/main/swift/Thing.swift b/wire-tests-swift/no-manifest/src/main/swift/Thing.swift similarity index 100% rename from wire-tests-swift/src/main/swift/Thing.swift rename to wire-tests-swift/no-manifest/src/main/swift/Thing.swift diff --git a/wire-tests-swift/src/main/swift/VersionOne.swift b/wire-tests-swift/no-manifest/src/main/swift/VersionOne.swift similarity index 100% rename from wire-tests-swift/src/main/swift/VersionOne.swift rename to wire-tests-swift/no-manifest/src/main/swift/VersionOne.swift diff --git a/wire-tests-swift/src/main/swift/VersionTwo.swift b/wire-tests-swift/no-manifest/src/main/swift/VersionTwo.swift similarity index 100% rename from wire-tests-swift/src/main/swift/VersionTwo.swift rename to wire-tests-swift/no-manifest/src/main/swift/VersionTwo.swift diff --git a/wire-tests-swift/src/main/swift/VeryLongProtoNameCausingBrokenLineBreaks.swift b/wire-tests-swift/no-manifest/src/main/swift/VeryLongProtoNameCausingBrokenLineBreaks.swift similarity index 100% rename from wire-tests-swift/src/main/swift/VeryLongProtoNameCausingBrokenLineBreaks.swift rename to wire-tests-swift/no-manifest/src/main/swift/VeryLongProtoNameCausingBrokenLineBreaks.swift diff --git a/wire-tests-swift/src/test/swift/JsonLitmusTest.swift b/wire-tests-swift/no-manifest/src/test/swift/JsonLitmusTest.swift similarity index 100% rename from wire-tests-swift/src/test/swift/JsonLitmusTest.swift rename to wire-tests-swift/no-manifest/src/test/swift/JsonLitmusTest.swift diff --git a/wire-tests/src/commonTest/proto/kotlin/swift_module_one.proto b/wire-tests/src/commonTest/proto/kotlin/swift_module_one.proto new file mode 100644 index 0000000000..b875dc3316 --- /dev/null +++ b/wire-tests/src/commonTest/proto/kotlin/swift_module_one.proto @@ -0,0 +1,24 @@ +/* + * Copyright 2023 Square Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +syntax = "proto2"; + +package squareup.protos.kotlin.swift_modules; + +enum SwiftModuleOneType { + DO_NOT_USE = 0; + ONE = 1; + TWO = 2; +} diff --git a/wire-tests/src/commonTest/proto/kotlin/swift_module_three.proto b/wire-tests/src/commonTest/proto/kotlin/swift_module_three.proto new file mode 100644 index 0000000000..53555a481f --- /dev/null +++ b/wire-tests/src/commonTest/proto/kotlin/swift_module_three.proto @@ -0,0 +1,28 @@ +/* + * Copyright 2023 Square Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +syntax = "proto2"; + +package squareup.protos.kotlin.swift_modules; + +import "swift_module_one.proto"; + +message SwiftModuleThreeMessage { + optional string name = 1; + + message NestedMessage { + map map_string_types = 2; + } +} diff --git a/wire-tests/src/commonTest/proto/kotlin/swift_module_two.proto b/wire-tests/src/commonTest/proto/kotlin/swift_module_two.proto new file mode 100644 index 0000000000..aef0a83faf --- /dev/null +++ b/wire-tests/src/commonTest/proto/kotlin/swift_module_two.proto @@ -0,0 +1,28 @@ +/* + * Copyright 2023 Square Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +syntax = "proto2"; + +package squareup.protos.kotlin.swift_modules; + +import "swift_module_one.proto"; + +message SwiftModuleTwoMessage { + optional string name = 1; + + message NestedMessage { + repeated SwiftModuleOneType types = 2; + } +} diff --git a/wire-tests/src/commonTest/proto/kotlin/swift_modules_manifest.yaml b/wire-tests/src/commonTest/proto/kotlin/swift_modules_manifest.yaml new file mode 100644 index 0000000000..c3eabdb411 --- /dev/null +++ b/wire-tests/src/commonTest/proto/kotlin/swift_modules_manifest.yaml @@ -0,0 +1,34 @@ +# +# Copyright 2023 Square Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +#/ + +# Used between swift_module_one.proto, swift_module_two.proto and swift_module_three.proto + +--- +module_one: + roots: + - squareup.protos.kotlin.swift_modules.SwiftModuleOneType +module_two: + roots: + - squareup.protos.kotlin.swift_modules.SwiftModuleTwoMessage + - squareup.protos.kotlin.swift_modules.SwiftModuleTwoMessage.NestedMessage + dependencies: + - module_one +module_three: + roots: + - squareup.protos.kotlin.swift_modules.SwiftModuleThreeMessage + - squareup.protos.kotlin.swift_modules.SwiftModuleThreeMessage.NestedMessage + dependencies: + - module_one