Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix file separator issue on Windows 10 (mvn verify) #395

Open
wants to merge 5 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,5 @@ dependency-reduced-pom.xml

.idea/
local_config/
*/target/
*/bin/
22 changes: 13 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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: <https://search.maven.org/search?q=schema2proto>

## Build

Requires Maven and at least JDK 11.

## Usage

Expand All @@ -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: <https://github.com/salesforce/proto-backwards-compat-maven-plugin>

Only automatic resolving of field name/id conflicts have been implemented so far.

## Contribution
Expand All @@ -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 <https://en.wikipedia.org/wiki/European_Union_Public_Licence>

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 <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-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 <https://github.com/eclipse-ee4j/jaxb-ri/tree/master/jaxb-ri/xsom>,
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 <https://github.com/tranchis/xsd2thrift> but has been completely rewritten.
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -215,7 +215,7 @@ public void serialize(Map<String, ProtoFile> packageToProtoFileMap, List<LocalTy
ProtoFile protoFile = packageToProtoFileMap.entrySet().iterator().next().getValue();
File destFolder = createPackageFolderStructure(configuration.outputDirectory, protoFile.packageName());

File outputFile = new File(destFolder, configuration.outputFilename.toLowerCase());
File outputFile = new File(destFolder, configuration.outputFilename.lowercase());
try (Writer writer = new FileWriter(outputFile)) {
writer.write(protoFile.toSchema());

Expand All @@ -227,7 +227,7 @@ public void serialize(Map<String, ProtoFile> packageToProtoFileMap, List<LocalTy
for (Entry<String, ProtoFile> 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());
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -877,7 +877,7 @@ private void computeLocalImports(Map<String, ProtoFile> 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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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);

Expand All @@ -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);

Expand Down Expand Up @@ -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());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand Down
Loading