From be5329f22386b65f78113c25cafd1269c338d56e Mon Sep 17 00:00:00 2001 From: Volker Milbrandt Date: Tue, 29 Nov 2022 13:26:01 +0100 Subject: [PATCH 1/4] Fix file separator issue on Windows 10 (mvn verify) --- README.md | 22 +- .../com/squareup/wire/schema/SchemaTest.kt | 345 +++++++++--------- 2 files changed, 186 insertions(+), 181 deletions(-) diff --git a/README.md b/README.md index 36404896..3c77ec22 100644 --- a/README.md +++ b/README.md @@ -6,9 +6,13 @@ This tool does 2 things: * Modifies existing proto files by adding, modifying and removing fields, messages etc. Also support for merging proto files using the same package -# Artifacts +## Artifacts -Artifacts are pushed to maven central: https://search.maven.org/search?q=schema2proto +Artifacts are pushed to maven central: + +## Build + +Requires Maven and at least JDK 11. ## Usage @@ -28,8 +32,8 @@ any backwards incompatibility issues that may arise from modifying the xsd. You can use the tool [protolock](https://github.com/nilslice/protolock) to verify that i.e. fields have not changed name or id. -If you are using the Maven there is a plugin as well: https://github.com/salesforce/proto-backwards-compat-maven-plugin - +If you are using the Maven there is a plugin as well: + Only automatic resolving of field name/id conflicts have been implemented so far. ## Contribution @@ -38,12 +42,12 @@ See code style [CODESTYLE.md](CODESTYLE.md) ## Licensing -EUPL, see [LICENSE](LICENSE.txt) and https://en.wikipedia.org/wiki/European_Union_Public_Licence +EUPL, see [LICENSE](LICENSE.txt) and -The schema2proto-wire module is a modified copy from https://github.com/square/wire/tree/master/wire-schema that seems -to have become https://github.com/square/wire/tree/master/wire-library/wire-schema now. +The schema2proto-wire module is a modified copy from that seems +to have become now. -The schema2proto-xsom module is a modified copy from https://github.com/eclipse-ee4j/jaxb-ri/tree/master/jaxb-ri/xsom, +The schema2proto-xsom module is a modified copy from , see [original LICENSE](schema2proto-xsom/LICENSE.md) -The codebase was once based on https://github.com/tranchis/xsd2thrift but has been completely rewritten. +The codebase was once based on but has been completely rewritten. diff --git a/schema2proto-wire/src/test/java/com/squareup/wire/schema/SchemaTest.kt b/schema2proto-wire/src/test/java/com/squareup/wire/schema/SchemaTest.kt index a784fdfe..a1abdb23 100644 --- a/schema2proto-wire/src/test/java/com/squareup/wire/schema/SchemaTest.kt +++ b/schema2proto-wire/src/test/java/com/squareup/wire/schema/SchemaTest.kt @@ -15,6 +15,7 @@ */ package com.squareup.wire.schema +import java.io.File; import com.squareup.wire.schema.Options.FIELD_OPTIONS import com.squareup.wire.schema.internal.Util import org.assertj.core.api.Assertions.assertThat @@ -118,20 +119,20 @@ class SchemaTest { .schema() Assertions.assertTrue(false) } catch (expected: SchemaException) { - assertThat(expected.message).isEqualTo(""" + assertThat(expected.message).isEqualTo((""" |tag is out of range: 0 - | for field a (/source/message.proto at 2:3) - | in message Message (/source/message.proto at 1:1) + | for field a (/source""" + File.separator + """message.proto at 2:3) + | in message Message (/source""" + File.separator + """message.proto at 1:1) |tag is out of range: 19000 - | for field d (/source/message.proto at 5:3) - | in message Message (/source/message.proto at 1:1) + | for field d (/source""" + File.separator + """message.proto at 5:3) + | in message Message (/source""" + File.separator + """message.proto at 1:1) |tag is out of range: 19999 - | for field e (/source/message.proto at 6:3) - | in message Message (/source/message.proto at 1:1) + | for field e (/source""" + File.separator + """message.proto at 6:3) + | in message Message (/source""" + File.separator + """message.proto at 1:1) |tag is out of range: 536870912 - | for field h (/source/message.proto at 9:3) - | in message Message (/source/message.proto at 1:1) - """.trimMargin()) + | for field h (/source""" + File.separator + """message.proto at 9:3) + | in message Message (/source""" + File.separator + """message.proto at 1:1) + """).trimMargin()) } } @@ -155,20 +156,20 @@ class SchemaTest { .schema() Assertions.assertTrue(false) } catch (expected: SchemaException) { - assertThat(expected).hasMessage(""" + assertThat(expected).hasMessage((""" |tags are out of range: 0 to 0 - | for extensions (/source/message.proto at 2:3) - | in message Message (/source/message.proto at 1:1) + | for extensions (/source""" + File.separator + """message.proto at 2:3) + | in message Message (/source""" + File.separator + """message.proto at 1:1) |tags are out of range: 19000 to 19000 - | for extensions (/source/message.proto at 5:3) - | in message Message (/source/message.proto at 1:1) + | for extensions (/source""" + File.separator + """message.proto at 5:3) + | in message Message (/source""" + File.separator + """message.proto at 1:1) |tags are out of range: 19999 to 19999 - | for extensions (/source/message.proto at 6:3) - | in message Message (/source/message.proto at 1:1) + | for extensions (/source""" + File.separator + """message.proto at 6:3) + | in message Message (/source""" + File.separator + """message.proto at 1:1) |tags are out of range: 536870912 to 536870912 - | for extensions (/source/message.proto at 9:3) - | in message Message (/source/message.proto at 1:1) - """.trimMargin() + | for extensions (/source""" + File.separator + """message.proto at 9:3) + | in message Message (/source""" + File.separator + """message.proto at 1:1) + """).trimMargin() ) } } @@ -231,20 +232,20 @@ class SchemaTest { .schema() Assertions.assertTrue(false) } catch (expected: SchemaException) { - assertThat(expected).hasMessage(""" + assertThat(expected).hasMessage((""" |packed=true not permitted on bytes - | for field b (/source/message.proto at 3:3) - | in message Message (/source/message.proto at 1:1) + | for field b (/source""" + File.separator + """message.proto at 3:3) + | in message Message (/source""" + File.separator + """message.proto at 1:1) |packed=true not permitted on string - | for field d (/source/message.proto at 5:3) - | in message Message (/source/message.proto at 1:1) + | for field d (/source""" + File.separator + """message.proto at 5:3) + | in message Message (/source""" + File.separator + """message.proto at 1:1) |packed=true not permitted on Message - | for field f (/source/message.proto at 7:3) - | in message Message (/source/message.proto at 1:1) + | for field f (/source""" + File.separator + """message.proto at 7:3) + | in message Message (/source""" + File.separator + """message.proto at 1:1) |packed=true not permitted on bytes - | for field h (/source/message.proto at 11:3) - | in message Message (/source/message.proto at 1:1) - """.trimMargin() + | for field h (/source""" + File.separator + """message.proto at 11:3) + | in message Message (/source""" + File.separator + """message.proto at 1:1) + """).trimMargin() ) } } @@ -341,11 +342,11 @@ class SchemaTest { .schema() Assertions.assertTrue(false) } catch (expected: SchemaException) { - assertThat(expected).hasMessage(""" + assertThat(expected).hasMessage((""" |conflicting options: red, blue - | for field a (/source/message.proto at 3:3) - | in message Message (/source/message.proto at 2:1) - """.trimMargin() + | for field a (/source""" + File.separator + """message.proto at 3:3) + | in message Message (/source""" + File.separator + """message.proto at 2:1) + """).trimMargin() ) } } @@ -363,11 +364,11 @@ class SchemaTest { .schema() Assertions.assertTrue(false) } catch (expected: SchemaException) { - assertThat(expected).hasMessage(""" + assertThat(expected).hasMessage((""" |unable to resolve foo_package.Foo - | for field unknown (/source/message.proto at 2:3) - | in message Message (/source/message.proto at 1:1) - """.trimMargin() + | for field unknown (/source""" + File.separator + """message.proto at 2:3) + | in message Message (/source""" + File.separator + """message.proto at 1:1) + """).trimMargin() ) } } @@ -388,11 +389,11 @@ class SchemaTest { .schema() Assertions.assertTrue(false) } catch (expected: SchemaException) { - assertThat(expected).hasMessage(""" + assertThat(expected).hasMessage((""" |unable to resolve foo_package.Foo - | for field unknown (/source/message.proto at 4:5) - | in message Message (/source/message.proto at 1:1) - """.trimMargin() + | for field unknown (/source""" + File.separator + """message.proto at 4:5) + | in message Message (/source""" + File.separator + """message.proto at 1:1) + """).trimMargin() ) } } @@ -412,11 +413,11 @@ class SchemaTest { .schema() Assertions.assertTrue(false) } catch (expected: SchemaException) { - assertThat(expected).hasMessage(""" + assertThat(expected).hasMessage((""" |expected a message but was string - | for rpc Call (/source/service.proto at 2:3) - | in service Service (/source/service.proto at 1:1) - """.trimMargin() + | for rpc Call (/source""" + File.separator + """service.proto at 2:3) + | in service Service (/source""" + File.separator + """service.proto at 1:1) + """).trimMargin() ) } @@ -433,11 +434,11 @@ class SchemaTest { .schema() Assertions.assertTrue(false) } catch (expected: SchemaException) { - assertThat(expected).hasMessage(""" + assertThat(expected).hasMessage((""" |expected a message but was string - | for rpc Call (/source/service.proto at 2:3) - | in service Service (/source/service.proto at 1:1) - """.trimMargin() + | for rpc Call (/source""" + File.separator + """service.proto at 2:3) + | in service Service (/source""" + File.separator + """service.proto at 1:1) + """).trimMargin() ) } } @@ -457,11 +458,11 @@ class SchemaTest { .schema() Assertions.assertTrue(false) } catch (expected: SchemaException) { - assertThat(expected).hasMessage(""" + assertThat(expected).hasMessage((""" |unable to resolve foo_package.Foo - | for rpc Call (/source/service.proto at 2:3) - | in service Service (/source/service.proto at 1:1) - """.trimMargin() + | for rpc Call (/source""" + File.separator + """service.proto at 2:3) + | in service Service (/source""" + File.separator + """service.proto at 1:1) + """).trimMargin() ) } @@ -478,11 +479,11 @@ class SchemaTest { .schema() Assertions.assertTrue(false) } catch (expected: SchemaException) { - assertThat(expected).hasMessage(""" + assertThat(expected).hasMessage((""" |unable to resolve foo_package.Foo - | for rpc Call (/source/service.proto at 2:3) - | in service Service (/source/service.proto at 1:1) - """.trimMargin() + | for rpc Call (/source""" + File.separator + """service.proto at 2:3) + | in service Service (/source""" + File.separator + """service.proto at 1:1) + """).trimMargin() ) } } @@ -499,10 +500,10 @@ class SchemaTest { .schema() Assertions.assertTrue(false) } catch (expected: SchemaException) { - assertThat(expected).hasMessage(""" + assertThat(expected).hasMessage((""" |unable to resolve foo_package.Foo - | for extend (/source/extend.proto at 1:1) - """.trimMargin() + | for extend (/source""" + File.separator + """extend.proto at 1:1) + """).trimMargin() ) } } @@ -522,10 +523,10 @@ class SchemaTest { .schema() Assertions.assertTrue(false) } catch (expected: SchemaException) { - assertThat(expected).hasMessage(""" + assertThat(expected).hasMessage((""" |expected a message but was string - | for extend (/source/extend.proto at 1:1) - """.trimMargin() + | for extend (/source""" + File.separator + """extend.proto at 1:1) + """).trimMargin() ) } } @@ -545,11 +546,11 @@ class SchemaTest { .schema() Assertions.assertTrue(false) } catch (expected: SchemaException) { - assertThat(expected).hasMessage(""" + assertThat(expected).hasMessage((""" |unable to resolve foo_package.Foo - | for field unknown (/source/message.proto at 4:3) - | in message Message (/source/message.proto at 1:1) - """.trimMargin() + | for field unknown (/source""" + File.separator + """message.proto at 4:3) + | in message Message (/source""" + File.separator + """message.proto at 1:1) + """).trimMargin() ) } } @@ -568,14 +569,14 @@ class SchemaTest { .schema() Assertions.assertTrue(false) } catch (expected: SchemaException) { - assertThat(expected).hasMessage(""" + assertThat(expected).hasMessage((""" |unable to resolve foo_package.Foo - | for field unknown (/source/message.proto at 2:3) - | in message Message (/source/message.proto at 1:1) + | for field unknown (/source""" + File.separator + """message.proto at 2:3) + | in message Message (/source""" + File.separator + """message.proto at 1:1) |unable to resolve foo_package.Foo - | for field also_unknown (/source/message.proto at 3:3) - | in message Message (/source/message.proto at 1:1) - """.trimMargin() + | for field also_unknown (/source""" + File.separator + """message.proto at 3:3) + | in message Message (/source""" + File.separator + """message.proto at 1:1) + """).trimMargin() ) } } @@ -594,12 +595,12 @@ class SchemaTest { .schema() Assertions.assertTrue(false) } catch (expected: SchemaException) { - assertThat(expected).hasMessage(""" + assertThat(expected).hasMessage((""" |multiple fields share tag 1: - | 1. name1 (/source/message.proto at 2:3) - | 2. name2 (/source/message.proto at 3:3) - | for message Message (/source/message.proto at 1:1) - """.trimMargin() + | 1. name1 (/source""" + File.separator + """message.proto at 2:3) + | 2. name2 (/source""" + File.separator + """message.proto at 3:3) + | for message Message (/source""" + File.separator + """message.proto at 1:1) + """).trimMargin() ) } } @@ -620,12 +621,12 @@ class SchemaTest { .schema() Assertions.assertTrue(false) } catch (expected: SchemaException) { - assertThat(expected).hasMessage(""" + assertThat(expected).hasMessage((""" |multiple fields share tag 1: - | 1. name1 (/source/message.proto at 2:3) - | 2. name2 (/source/message.proto at 4:5) - | for message Message (/source/message.proto at 1:1) - """.trimMargin() + | 1. name1 (/source""" + File.separator + """message.proto at 2:3) + | 2. name2 (/source""" + File.separator + """message.proto at 4:5) + | for message Message (/source""" + File.separator + """message.proto at 1:1) + """).trimMargin() ) } } @@ -646,12 +647,12 @@ class SchemaTest { .schema() Assertions.assertTrue(false) } catch (expected: SchemaException) { - assertThat(expected).hasMessage(""" + assertThat(expected).hasMessage((""" |multiple fields share tag 1: - | 1. name1 (/source/message.proto at 4:3) - | 2. name2 (/source/message.proto at 5:3) - | for message Message (/source/message.proto at 1:1) - """.trimMargin() + | 1. name1 (/source""" + File.separator + """message.proto at 4:3) + | 2. name2 (/source""" + File.separator + """message.proto at 5:3) + | for message Message (/source""" + File.separator + """message.proto at 1:1) + """).trimMargin() ) } } @@ -670,12 +671,12 @@ class SchemaTest { .schema() Assertions.assertTrue(false) } catch (expected: SchemaException) { - assertThat(expected).hasMessage(""" + assertThat(expected).hasMessage((""" |multiple fields share name a: - | 1. a (/source/message.proto at 2:3) - | 2. a (/source/message.proto at 3:3) - | for message Message (/source/message.proto at 1:1) - """.trimMargin() + | 1. a (/source""" + File.separator + """message.proto at 2:3) + | 2. a (/source""" + File.separator + """message.proto at 3:3) + | for message Message (/source""" + File.separator + """message.proto at 1:1) + """).trimMargin() ) } } @@ -727,12 +728,12 @@ class SchemaTest { .schema() Assertions.assertTrue(false) } catch (expected: SchemaException) { - assertThat(expected).hasMessage(""" + assertThat(expected).hasMessage((""" |multiple fields share name a: - | 1. a (/source/extend1.proto at 3:3) - | 2. a (/source/extend2.proto at 3:3) - | for message Message (/source/message.proto at 1:1) - """.trimMargin() + | 1. a (/source""" + File.separator + """extend1.proto at 3:3) + | 2. a (/source""" + File.separator + """extend2.proto at 3:3) + | for message Message (/source""" + File.separator + """message.proto at 1:1) + """).trimMargin() ) } } @@ -790,10 +791,10 @@ class SchemaTest { .schema() Assertions.assertTrue(false) } catch (expected: SchemaException) { - assertThat(expected).hasMessage(""" + assertThat(expected).hasMessage((""" |expected a message but was Enum - | for extend (/source/extend.proto at 2:1) - """.trimMargin() + | for extend (/source""" + File.separator + """extend.proto at 2:1) + """).trimMargin() ) } } @@ -813,11 +814,11 @@ class SchemaTest { .schema() Assertions.assertTrue(false) } catch (expected: SchemaException) { - assertThat(expected).hasMessage(""" + assertThat(expected).hasMessage((""" |extension fields cannot be required - | for field a (/source/message.proto at 4:3) - | in message Message (/source/message.proto at 1:1) - """.trimMargin() + | for field a (/source""" + File.separator + """message.proto at 4:3) + | in message Message (/source""" + File.separator + """message.proto at 1:1) + """).trimMargin() ) } } @@ -835,7 +836,7 @@ class SchemaTest { .schema() Assertions.assertTrue(false) } catch (expected: IllegalStateException) { - assertThat(expected).hasMessage("Syntax error in /source/message.proto at 2:17: expected '{'") + assertThat(expected).hasMessage("Syntax error in /source" + File.separator + "message.proto at 2:17: expected '{'") } } @@ -857,12 +858,12 @@ class SchemaTest { .schema() Assertions.assertTrue(false) } catch (expected: SchemaException) { - assertThat(expected).hasMessage(""" + assertThat(expected).hasMessage((""" |multiple enums share constant VALUE: - | 1. Message.Enum1.VALUE (/source/message.proto at 3:5) - | 2. Message.Enum2.VALUE (/source/message.proto at 6:5) - | for message Message (/source/message.proto at 1:1) - """.trimMargin() + | 1. Message.Enum1.VALUE (/source""" + File.separator + """message.proto at 3:5) + | 2. Message.Enum2.VALUE (/source""" + File.separator + """message.proto at 6:5) + | for message Message (/source""" + File.separator + """message.proto at 1:1) + """).trimMargin() ) } } @@ -881,12 +882,12 @@ class SchemaTest { .schema() Assertions.assertTrue(false) } catch (expected: SchemaException) { - assertThat(expected).hasMessage(""" + assertThat(expected).hasMessage((""" |multiple enum constants share tag 1: - | 1. A (/source/message.proto at 2:3) - | 2. B (/source/message.proto at 3:3) - | for enum Enum (/source/message.proto at 1:1) - """.trimMargin() + | 1. A (/source""" + File.separator + """message.proto at 2:3) + | 2. B (/source""" + File.separator + """message.proto at 3:3) + | for enum Enum (/source""" + File.separator + """message.proto at 1:1) + """).trimMargin() ) } } @@ -906,12 +907,12 @@ class SchemaTest { .schema() Assertions.assertTrue(false) } catch (expected: SchemaException) { - assertThat(expected).hasMessage(""" + assertThat(expected).hasMessage((""" |multiple enum constants share tag 1: - | 1. A (/source/message.proto at 3:3) - | 2. B (/source/message.proto at 4:3) - | for enum Enum (/source/message.proto at 1:1) - """.trimMargin() + | 1. A (/source""" + File.separator + """message.proto at 3:3) + | 2. B (/source""" + File.separator + """message.proto at 4:3) + | for enum Enum (/source""" + File.separator + """message.proto at 1:1) + """).trimMargin() ) } } @@ -999,11 +1000,11 @@ class SchemaTest { .schema() Assertions.assertTrue(false) } catch (expected: SchemaException) { - assertThat(expected.message).isEqualTo(""" + assertThat(expected.message).isEqualTo((""" |a.proto needs to import b.proto - | for field b (/source/a.proto at 3:3) - | in message pa.A (/source/a.proto at 2:1) - """.trimMargin() + | for field b (/source""" + File.separator + """a.proto at 3:3) + | in message pa.A (/source""" + File.separator + """a.proto at 2:1) + """).trimMargin() ) } } @@ -1028,11 +1029,11 @@ class SchemaTest { .schema() Assertions.assertTrue(false) } catch (expected: SchemaException) { - assertThat(expected.message).isEqualTo(""" + assertThat(expected.message).isEqualTo((""" |a.proto needs to import b.proto - | for field b (/source/a.proto at 3:3) - | in message pa.A (/source/a.proto at 2:1) - """.trimMargin() + | for field b (/source""" + File.separator + """a.proto at 3:3) + | in message pa.A (/source""" + File.separator + """a.proto at 2:1) + """).trimMargin() ) } } @@ -1081,14 +1082,14 @@ class SchemaTest { .schema() Assertions.assertTrue(false) } catch (expected: SchemaException) { - assertThat(expected.message).isEqualTo(""" + assertThat(expected.message).isEqualTo((""" |a.proto needs to import b.proto - | for rpc Call (/source/a.proto at 3:3) - | in service pa.Service (/source/a.proto at 2:1) + | for rpc Call (/source""" + File.separator + """a.proto at 3:3) + | in service pa.Service (/source""" + File.separator + """a.proto at 2:1) |a.proto needs to import b.proto - | for rpc Call (/source/a.proto at 3:3) - | in service pa.Service (/source/a.proto at 2:1) - """.trimMargin() + | for rpc Call (/source""" + File.separator + """a.proto at 3:3) + | in service pa.Service (/source""" + File.separator + """a.proto at 2:1) + """).trimMargin() ) } } @@ -1138,10 +1139,10 @@ class SchemaTest { .schema() Assertions.assertTrue(false) } catch (expected: SchemaException) { - assertThat(expected.message).isEqualTo(""" + assertThat(expected.message).isEqualTo((""" |a.proto needs to import b.proto - | for extend pb.B (/source/a.proto at 2:1) - """.trimMargin() + | for extend pb.B (/source""" + File.separator + """a.proto at 2:1) + """).trimMargin() ) } } @@ -1174,11 +1175,11 @@ class SchemaTest { .schema() Assertions.assertTrue(false) } catch (expected: SchemaException) { - assertThat(expected.message).isEqualTo(""" + assertThat(expected.message).isEqualTo((""" |a.proto needs to import c.proto - | for field c (/source/a.proto at 4:3) - | in message pa.A (/source/a.proto at 3:1) - """.trimMargin() + | for field c (/source""" + File.separator + """a.proto at 4:3) + | in message pa.A (/source""" + File.separator + """a.proto at 3:1) + """).trimMargin() ) } } @@ -1384,11 +1385,11 @@ class SchemaTest { .schema() Assertions.assertTrue(false) } catch (expected: SchemaException) { - assertThat(expected).hasMessage(""" + assertThat(expected).hasMessage((""" |unable to resolve .b.MessageB - | for field message_b (/source/a_b_c.proto at 6:3) - | in message a.b.c.MessageC (/source/a_b_c.proto at 5:1) - """.trimMargin() + | for field message_b (/source""" + File.separator + """a_b_c.proto at 6:3) + | in message a.b.c.MessageC (/source""" + File.separator + """a_b_c.proto at 5:1) + """).trimMargin() ) } } @@ -1410,7 +1411,7 @@ class SchemaTest { .schema() Assertions.assertTrue(false) } catch (expected: IllegalStateException) { - assertThat(expected).hasMessage("/source/test.proto at 2:3: 'group' is not supported") + assertThat(expected).hasMessage("/source" + File.separator + "test.proto at 2:3: 'group' is not supported") } } @@ -1434,7 +1435,7 @@ class SchemaTest { .schema() Assertions.assertTrue(false) } catch (expected: IllegalStateException) { - assertThat(expected).hasMessage("/source/test.proto at 5:5: 'group' is not supported") + assertThat(expected).hasMessage("/source" + File.separator + "test.proto at 5:5: 'group' is not supported") } } @@ -1452,11 +1453,11 @@ class SchemaTest { .schema() Assertions.assertTrue(false) } catch (expected: SchemaException) { - assertThat(expected).hasMessage(""" - |tag 1 is reserved (/source/test.proto at 2:3) - | for field name (/source/test.proto at 3:3) - | in message Message (/source/test.proto at 1:1) - """.trimMargin() + assertThat(expected).hasMessage((""" + |tag 1 is reserved (/source""" + File.separator + """test.proto at 2:3) + | for field name (/source""" + File.separator + """test.proto at 3:3) + | in message Message (/source""" + File.separator + """test.proto at 1:1) + """).trimMargin() ) } } @@ -1475,11 +1476,11 @@ class SchemaTest { .schema() Assertions.assertTrue(false) } catch (expected: SchemaException) { - assertThat(expected).hasMessage(""" - |tag 2 is reserved (/source/test.proto at 2:3) - | for field name (/source/test.proto at 3:3) - | in message Message (/source/test.proto at 1:1) - """.trimMargin() + assertThat(expected).hasMessage((""" + |tag 2 is reserved (/source""" + File.separator + """test.proto at 2:3) + | for field name (/source""" + File.separator + """test.proto at 3:3) + | in message Message (/source""" + File.separator + """test.proto at 1:1) + """).trimMargin() ) } } @@ -1498,11 +1499,11 @@ class SchemaTest { .schema() Assertions.assertTrue(false) } catch (expected: SchemaException) { - assertThat(expected).hasMessage(""" - |name 'foo' is reserved (/source/test.proto at 2:3) - | for field foo (/source/test.proto at 3:3) - | in message Message (/source/test.proto at 1:1) - """.trimMargin() + assertThat(expected).hasMessage((""" + |name 'foo' is reserved (/source""" + File.separator + """test.proto at 2:3) + | for field foo (/source""" + File.separator + """test.proto at 3:3) + | in message Message (/source""" + File.separator + """test.proto at 1:1) + """).trimMargin() ) } } @@ -1522,14 +1523,14 @@ class SchemaTest { .schema() Assertions.assertTrue(false) } catch (expected: SchemaException) { - assertThat(expected).hasMessage(""" - |name 'foo' is reserved (/source/test.proto at 2:3) - | for field foo (/source/test.proto at 4:3) - | in message Message (/source/test.proto at 1:1) - |tag 1 is reserved (/source/test.proto at 3:3) - | for field foo (/source/test.proto at 4:3) - | in message Message (/source/test.proto at 1:1) - """.trimMargin() + assertThat(expected).hasMessage((""" + |name 'foo' is reserved (/source""" + File.separator + """test.proto at 2:3) + | for field foo (/source""" + File.separator + """test.proto at 4:3) + | in message Message (/source""" + File.separator + """test.proto at 1:1) + |tag 1 is reserved (/source""" + File.separator + """test.proto at 3:3) + | for field foo (/source""" + File.separator + """test.proto at 4:3) + | in message Message (/source""" + File.separator + """test.proto at 1:1) + """).trimMargin() ) } } From 85db428ff66a93c8e1d4421cf1e34e7c27e29f96 Mon Sep 17 00:00:00 2001 From: Volker Milbrandt Date: Tue, 29 Nov 2022 14:43:03 +0100 Subject: [PATCH 2/4] The artifact io.envoyproxy.protoc-gen-validate:pgv-java-stub:jar:0.6.13 has been relocated to build.buf.protoc-gen-validate:pgv-java-stub:jar:0.6.13 --- schema2proto-lib/pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/schema2proto-lib/pom.xml b/schema2proto-lib/pom.xml index d3312937..d7425e5b 100755 --- a/schema2proto-lib/pom.xml +++ b/schema2proto-lib/pom.xml @@ -70,9 +70,9 @@ 1.5.0 - io.envoyproxy.protoc-gen-validate + build.buf.protoc-gen-validate pgv-java-stub - 0.6.13 + 0.9.0 org.apache.commons From 24da49385a51216d705eda2dfe070fa290c91e90 Mon Sep 17 00:00:00 2001 From: Volker Milbrandt Date: Tue, 29 Nov 2022 15:00:10 +0100 Subject: [PATCH 3/4] 'toLowerCase(Locale): String' is deprecated. Use lowercase() instead --- .gitignore | 2 ++ .../entur/schema2proto/generateproto/NamespaceHelper.java | 4 ++-- .../entur/schema2proto/generateproto/ProtoSerializer.java | 6 +++--- .../compatibility/AbstractBackwardsCompatTest.java | 8 ++++---- .../squareup/wire/schema/internal/parser/FieldElement.kt | 2 +- .../squareup/wire/schema/internal/parser/GroupElement.kt | 2 +- 6 files changed, 13 insertions(+), 11 deletions(-) diff --git a/.gitignore b/.gitignore index 62da5da1..9273a717 100644 --- a/.gitignore +++ b/.gitignore @@ -26,3 +26,5 @@ dependency-reduced-pom.xml .idea/ local_config/ +*/target/ +*/bin/ \ No newline at end of file diff --git a/schema2proto-lib/src/main/java/no/entur/schema2proto/generateproto/NamespaceHelper.java b/schema2proto-lib/src/main/java/no/entur/schema2proto/generateproto/NamespaceHelper.java index 3b33a04d..33387b8c 100644 --- a/schema2proto-lib/src/main/java/no/entur/schema2proto/generateproto/NamespaceHelper.java +++ b/schema2proto-lib/src/main/java/no/entur/schema2proto/generateproto/NamespaceHelper.java @@ -52,7 +52,7 @@ public static String xmlNamespaceToProtoPackage(String namespace, String forcePr String packageName; if (forceProtoPackage != null) { - packageName = forceProtoPackage.toLowerCase(); + packageName = forceProtoPackage.lowercase(); } else if (StringUtils.trimToNull(namespace) == null) { packageName = null; } else { @@ -71,7 +71,7 @@ public static String xmlNamespaceToProtoPackage(String namespace, String forcePr LOGGER.warn("Unable to create decent package name from XML namespace {}, falling back to {} ", namespace, packageName, urnSyntaxError); } } - packageName = StringUtils.trimToNull(packageName).toLowerCase(); + packageName = StringUtils.trimToNull(packageName).lowercase(); NAMESPACE_TO_PACKAGENAME.put(namespace, packageName); } diff --git a/schema2proto-lib/src/main/java/no/entur/schema2proto/generateproto/ProtoSerializer.java b/schema2proto-lib/src/main/java/no/entur/schema2proto/generateproto/ProtoSerializer.java index 1463479b..8787edb4 100644 --- a/schema2proto-lib/src/main/java/no/entur/schema2proto/generateproto/ProtoSerializer.java +++ b/schema2proto-lib/src/main/java/no/entur/schema2proto/generateproto/ProtoSerializer.java @@ -215,7 +215,7 @@ public void serialize(Map packageToProtoFileMap, List packageToProtoFileMap, List entry : packageToProtoFileMap.entrySet()) { ProtoFile protoFile = entry.getValue(); File destFolder = createPackageFolderStructure(configuration.outputDirectory, protoFile.packageName()); - File outputFile = new File(destFolder, protoFile.location().getPath().toLowerCase()); + File outputFile = new File(destFolder, protoFile.location().getPath().lowercase()); try (Writer writer = new FileWriter(outputFile)) { writer.write(protoFile.toSchema()); @@ -560,7 +560,7 @@ private CaseFormat getCaseFormatName(String s) throws IllegalFormatException { return CaseFormat.UPPER_UNDERSCORE; } } else if (s.contains("-")) { - if (s.toLowerCase().equals(s)) { + if (s.lowercase().equals(s)) { return CaseFormat.LOWER_HYPHEN; } } else { diff --git a/schema2proto-lib/src/test/java/no/entur/schema2proto/compatibility/AbstractBackwardsCompatTest.java b/schema2proto-lib/src/test/java/no/entur/schema2proto/compatibility/AbstractBackwardsCompatTest.java index db61355a..66a9ac15 100644 --- a/schema2proto-lib/src/test/java/no/entur/schema2proto/compatibility/AbstractBackwardsCompatTest.java +++ b/schema2proto-lib/src/test/java/no/entur/schema2proto/compatibility/AbstractBackwardsCompatTest.java @@ -9,12 +9,12 @@ * Licensed under the EUPL, Version 1.1 or – as soon they will be * approved by the European Commission - subsequent versions of the * EUPL (the "Licence"); - * + * * You may not use this work except in compliance with the Licence. * You may obtain a copy of the Licence at: - * + * * http://ec.europa.eu/idabc/eupl5 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the Licence is distributed on an "AS IS" basis, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -99,7 +99,7 @@ private boolean link(Schema schema, boolean dumpIfNotLinkable, String testname) System.out.println("Dumpfolder: " + dumpFolder.getAbsolutePath()); for (ProtoFile protoFile : schema.protoFiles()) { File destFolder = createPackageFolderStructure(new File(dumpFolder, testname), protoFile.packageName()); - File outputFile = new File(destFolder, protoFile.name().toLowerCase(Locale.ROOT)); + File outputFile = new File(destFolder, protoFile.name().lowercase(Locale.ROOT)); try (Writer writer = new FileWriter(outputFile)) { writer.write(protoFile.toSchema()); } diff --git a/schema2proto-wire/src/main/java/com/squareup/wire/schema/internal/parser/FieldElement.kt b/schema2proto-wire/src/main/java/com/squareup/wire/schema/internal/parser/FieldElement.kt index 89754463..2e8b55fb 100644 --- a/schema2proto-wire/src/main/java/com/squareup/wire/schema/internal/parser/FieldElement.kt +++ b/schema2proto-wire/src/main/java/com/squareup/wire/schema/internal/parser/FieldElement.kt @@ -35,7 +35,7 @@ data class FieldElement( appendDocumentation(this, documentation) if (label != null) { - append("${label.name.toLowerCase(Locale.US)} ") + append("${label.name.lowercase(Locale.US)} ") } append("$type $name = $tag") diff --git a/schema2proto-wire/src/main/java/com/squareup/wire/schema/internal/parser/GroupElement.kt b/schema2proto-wire/src/main/java/com/squareup/wire/schema/internal/parser/GroupElement.kt index 1a0c45fa..c5996b7a 100644 --- a/schema2proto-wire/src/main/java/com/squareup/wire/schema/internal/parser/GroupElement.kt +++ b/schema2proto-wire/src/main/java/com/squareup/wire/schema/internal/parser/GroupElement.kt @@ -32,7 +32,7 @@ data class GroupElement( fun toSchema() = buildString { appendDocumentation(this, documentation) if (label != null) { - append("${label.name.toLowerCase(Locale.US)} ") + append("${label.name.lowercase(Locale.US)} ") } append("group $name = $tag {") if (fields.isNotEmpty()) { From 3cba731c98dd6f18459794ca52f3bc0bf764dadf Mon Sep 17 00:00:00 2001 From: Volker Milbrandt Date: Tue, 29 Nov 2022 16:08:24 +0100 Subject: [PATCH 4/4] additional file separators --- .../entur/schema2proto/generateproto/ProtoSerializer.java | 8 ++++---- .../compatibility/AbstractBackwardsCompatTest.java | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/schema2proto-lib/src/main/java/no/entur/schema2proto/generateproto/ProtoSerializer.java b/schema2proto-lib/src/main/java/no/entur/schema2proto/generateproto/ProtoSerializer.java index 8787edb4..7ff6844f 100644 --- a/schema2proto-lib/src/main/java/no/entur/schema2proto/generateproto/ProtoSerializer.java +++ b/schema2proto-lib/src/main/java/no/entur/schema2proto/generateproto/ProtoSerializer.java @@ -7,12 +7,12 @@ * Licensed under the EUPL, Version 1.1 or – as soon they will be * approved by the European Commission - subsequent versions of the * EUPL (the "Licence"); - * + * * You may not use this work except in compliance with the Licence. * You may obtain a copy of the Licence at: - * + * * http://ec.europa.eu/idabc/eupl5 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the Licence is distributed on an "AS IS" basis, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -877,7 +877,7 @@ private void computeLocalImports(Map packageToProtoFileMap, P // Add import ProtoFile fileToImport = packageToProtoFileMap.get(packageName); if (fileToImport != null) { - imports.add(getPathFromPackageNameAndType(packageName, messageType) + "/" + fileToImport.location().getPath()); + imports.add(getPathFromPackageNameAndType(packageName, messageType) + File.separator + fileToImport.location().getPath()); } else { LOGGER.error("Tried to create import for field packageName {}, but no such protofile exist", packageName); } diff --git a/schema2proto-lib/src/test/java/no/entur/schema2proto/compatibility/AbstractBackwardsCompatTest.java b/schema2proto-lib/src/test/java/no/entur/schema2proto/compatibility/AbstractBackwardsCompatTest.java index 66a9ac15..e257a23c 100644 --- a/schema2proto-lib/src/test/java/no/entur/schema2proto/compatibility/AbstractBackwardsCompatTest.java +++ b/schema2proto-lib/src/test/java/no/entur/schema2proto/compatibility/AbstractBackwardsCompatTest.java @@ -51,9 +51,9 @@ public abstract class AbstractBackwardsCompatTest { protected void verify(String testname, boolean failOnRemovedFields, String protoFile) throws IOException { ProtolockBackwardsCompatibilityChecker checker = new ProtolockBackwardsCompatibilityChecker(); - checker.init(new File(testdataBaseDirectory + "/" + testname + "/" + sourceFolder + "/" + lockFile)); + checker.init(new File(String.join(File.pathSeparator, new[] { testdataBaseDirectory, testname, source, lockFile }))); - Schema sourceSchema = loadSchema(new File(testdataBaseDirectory + "/" + testname + "/" + sourceFolder)); + Schema sourceSchema = loadSchema(new File(String.join(File.pathSeparator, new[] { testdataBaseDirectory, testname, sourceFolder }))); link(sourceSchema, false, testname); ProtoFile sourceProtofile = sourceSchema.protoFile(protoFile); @@ -63,7 +63,7 @@ protected void verify(String testname, boolean failOnRemovedFields, String proto boolean linkedOk = link(sourceSchema, true, testname); assertTrue(linkedOk); - Schema expectedSchema = loadSchema(new File(testdataBaseDirectory + "/" + testname + "/" + expectedFolder)); + Schema expectedSchema = loadSchema(new File(String.join(File.pathSeparator, new[] { testdataBaseDirectory, testname, expectedFolder }))); link(expectedSchema, false, testname); ProtoFile expectedProtofile = expectedSchema.protoFile(protoFile);